Question

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

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top