I have a directory structure like the following:
root/ui/
root/ui/pom.xml
root/ui/build.xml
root/ui/_idea/{files that I want copied are here}
root/ui/ssui/pom.xml (An inner module)
In my POM file, I'm trying to call the ant file using
<tasks>
<ant antfile="build.xml" target="copyIntelliJFiles"/>
</tasks>
And my build.xml contains
<project name="ui-parent" default="copyIntelliJFiles" basedir=".">
<target name="copyIntelliJFiles">
<copy todir="." overwrite="true">
<fileset dir="_idea"/>
</copy>
</target>
</project>
However, when I run mvn install
from /root/ui
, I get the following error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.6:run (create-intellij-project-files) on project ssui-parent: An Ant BuildException has occured: The following error occurred while executing this line: [ERROR] java.io.FileNotFoundException: /root/ui/ssui/build.xml (No such file or directory) [ERROR] -> [Help 1]
It seems to be running it from /root/ui/ssui
instead of where the pom.xml
is.
Debugging Done
If I change my
pom.xml
to instead point to../build.xml
, the error message becomes:java.io.FileNotFoundException: /root/build.xml (No such file or directory)
If I remove the sub-module definition in
/root/ui/pom.xml
, then the path is recognized correctly (but I need the submodules)If I change the build.xml reference to
${basedir}/build.xml
, I get the same error:java.io.FileNotFoundException: /root/ui/ssui/build.xml
and it also works if I remove the sub-moduleTried the solution at Maven2 property that indicates the parent directory by creating a
ui.rootdir
property in bothui/pom.xml
(as${basedir}
) and inui/ssui/pom.xml
(as${basedir}/..
) and referenced${ui.rootdir}/build.xml
fromui/pom.xml
. Same error.
Any suggestions are welcome, but I can't restructure my directories, except for where the folder that is going to be copied lives. I did look at Usage of maven ${basedir} in multi-module setup but didn't figure out how it would solve my problem.
I created a zip file that illustrates the problem. If you run mvn install
you'll notice that an error occurs from within the sub module, though it does run fine in the top level module (and copies the file in my folder)