I used maven-dependency-plugin to copy the current artifact into a custom directory :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>copy-to-dsf-server</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>${project.groupId}</groupId>
<artifactId>${project.artifactId}</artifactId>
<version>${project.version}</version>
</artifactItem>
</artifactItems>
<outputDirectory>${tomcat.dsf.dir}/lib/pacifisc</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
But when the artifact version changes I have two versions of the same jar into the destination directory. How can I delete the old version ?
Regards, Arnaud
public class ArtifactItem extends Object implements org.apache.maven.shared.transfer.dependencies.DependableCoordinate. ArtifactItem represents information specified in the plugin configuration section for each artifact.
The dependency:copy goal can also be used to copy the just built artifact to a custom location if desired. It must be bound to any phase after the package phase so that the artifact exists in the repository.
Description: Goal that resolves the project dependencies from the repository.
The Clean Plugin is used when you want to remove files generated at build-time in a project's directory.
I finally used the maven-clean-plugin :
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<executions>
<execution>
<id>clean-dsf-server</id>
<phase>package</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<filesets>
<directory>${tomcat.dsf.dir}/lib/pacifisc</directory>
<includes>
<include>${project.artifactId}*.jar</include>
</includes>
</filesets>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With