Is it possible that I copy folders from my project to a certain location during some maven phase? and does anybody know how?
+1
A:
Take a look at the maven-antrun plugin. You can copy a file in any maven phase like this:
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<id>copy</id>
<phase>compile</phase>
<configuration>
<tasks>
<copy file="myFileSource" tofile="MyFileDest"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
mort
2010-08-06 12:33:47
+2
A:
The Maven way of doing this would be using the copy-resources
goal in maven-resources-plugin
From http://maven.apache.org/plugins/maven-resources-plugin/examples/copy-resources.html
<project>
...
<build>
<plugins>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4.3</version>
<executions>
<execution>
<id>copy-resources</id>
<!-- here the phase you need -->
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/extra-resources</outputDirectory>
<resources>
<resource>
<directory>src/non-packaged-resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
...
</build>
...
</project>
JoseK
2010-08-06 12:37:51
I would prefer this solution, before using the `ant-run` plugin.
codedevour
2010-08-06 12:44:39
Are there any benefits from using the maven resource plugin? I prefer doing this with the ant-run plugin because it allows you to handle single files and to rename them and it is a bit shorter - although it's still a lot of xml to write to simply copy a file...
mort
2010-08-06 12:45:33
@mort - no particular benefits. But my *personal* preference is to use Maven plugins where available rather than antrun.
JoseK
2010-08-06 12:52:39
@JoseK: Why do you want to avoid antrun? My opinion is that antrun is just a maven plugin like all the others. Furthermore, ant and maven together sometimes really do the best job.
mort
2010-08-06 14:19:25