I want to use the maven-dependency plugin to copy EAR files from all submodules of my multi-module project into a directory related to the root directory of the entire project.
That is, my layout is similar to this, the names are changed:
to-deploy/ my-project/ ear-module-a/ ear-module-b/ more-modules-1/ ear-module-c/ ear-module-d/ more-modules-2/ ear-module-e/ ear-module-f/ ...
And I want all EAR files to be copied from the target directories of their respective modules on my-project/../to-deploy , so I get
to-deploy/ ear-module-a.ear ear-module-b.ear ear-module-c.ear ear-module-d.ear ear-module-e.ear ear-module-f.ear my-project/ ...
I could do this with a relative path in each ear module, for example:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>copy</id> <phase>install</phase> <goals> <goal>copy</goal> </goals> <configuration> <artifactItems> <artifactItem> <groupId>${project.groupId}</groupId> <artifactId>${project.artifactId}</artifactId> <version>${project.version}</version> <type>ear</type> <outputDirectory>../../to-deploy</outputDirectory> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin>
But I do not want to specify a relative path in the <outputDirectory> element. I would prefer something like ${reactor.root.directory}/../to-deploy , but I can't find anything like it.
Also, I would prefer some way to inherit this maven-dependency-plugin configuration, so I don't need to specify it for each EAR module.
I also tried to inherit a custom property from the pom root:
<properties> <myproject.root>${basedir}</myproject.root> </properties>
But when I tried to use ${myproject.root} in the ear POM module, ${basedir} will resolve based on the ear module.
Also, I found http://labs.consol.de/lang/de/blog/maven/project-root-path-in-a-maven-multi-module-project/ , where he suggested that every developer and presumably, the continuous integration server should configure the root directory in the profiles. xml, but I do not consider this a solution.
So, is there an easy way to find the root of a multi-module project?