I want to use the maven-dependency-plugin to copy EAR-files from all sub-modules of my multi-module project to a directory that is relative to the root directory of the entire project.
That is, my layout looks similar to this, names 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 the EAR-files to be copied from the target-directories of their respective modules to my-project/../to-deploy
so i end up with
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 it with a relative path in each ear-module, like so:
<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'd rather not specify a relative path in the <outputDirectory>
element.
I'd prefer something like ${reactor.root.directory}/../to-deploy
, but i can't find anything like this.
Also, i'd prefer if there was some way to inherit this maven-dependency-plugin configuration so i don't have to specify it for each EAR-module.
I also tried inheriting a custom property from the root pom:
<properties>
<myproject.root>${basedir}</myproject.root>
</properties>
But when i tried to use ${myproject.root}
in the ear-module POM's, the ${basedir}
would resolve to the basedir of the ear-module.
Also, i found http://labs.consol.de/lang/de/blog/maven/project-root-path-in-a-maven-multi-module-project/ where it's suggested that each developer and presumably the continuous integration server should configure the root directory in a profiles.xml file, but i don't consider it a solution.
So is there an easy way to find the root of a multi-module project?