Reputation: 3653
I am trying to copy two separate directories and their files in different locations directories using maven and not able to achieve this, can any body help here?
**src/com/smepath ---- > buildDirectory/install/****
**src/com/someotherpath -----> buildDirectory/xsd/****
Although there is a related question here (Best practices for copying files with Maven) but doesn't solve my problem.
I am trying to change following solution viz.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/install</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/common/install</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/${env}/install</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Like if I make one more similar entry for let say my second directory locations xsd
then second one overrides first.
Also using an extra <excution>
within <executions>
or an extra <configuration>
also not working.
Upvotes: 0
Views: 171
Reputation: 3653
Although I am using extra <execution>
solution as suggested by @azurefrog but I was also able to achieve this using following solution.
Here I am putting my both directories install
and xsd
in a resources
directory and using the stuff further viz.
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/resources</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/common</directory>
<includes>
<include>install*/**</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/${env}</directory>
<includes>
<include>install*/**</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/common</directory>
<includes>
<include>xsd*/**</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 0
Reputation: 10945
Adding a second <execution>
to your pom should work.
My guess is that you aren't specifying a unique <id>
for each phase.
I have my project laid out like so:
src/main/resources/foo
|_a.txt
|_b.txt
src/main/resources/bar
|_c.txt
src/main/resources/baz
|_d.txt
src/main/resources/fum
|_e.txt
|_f.txt
After a clean validate
I end up with my files copied like so:
target/location-1
|_a.txt
|_b.txt
|_c.txt
target/location-2
|_d.txt
|_e.txt
|_f.txt
using the following plugin definition in my pom.xml
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>copy-resources-1</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/location-1</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/foo</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/bar</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-resources-2</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/location-2</outputDirectory>
<resources>
<resource>
<directory>src/main/resources/baz</directory>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources/fum</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
You should be able to use the above as an example to get your install and xsd files copied.
Upvotes: 2