Hello awesome community, I'd like to use your help once more by understanding how can I copy file during maven package phase. For example, Lets say I create a jar called myCustom.jar and I need to copy it to:
- ${basedir}\firstLocation
- ${basedir}\secondLocation
As for now I'm using maven-dependency-plugin like this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>package</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.company.group</groupId>
<artifactId>artifact-id</artifactId>
<version>${project.version}</version>
<type>jar</type>
<outputDirectory>${basedir}/firstLocation</outputDirectory>
<destFileName>myCustom.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>com.company.group</groupId>
<artifactId>artifact-id</artifactId>
<version>${project.version}</version>
<type>jar</type>
<outputDirectory>${basedir}/secondLocation</outputDirectory>
<destFileName>myCustom.jar</destFileName>
</artifactItem>
...
...
<artifactItems>
<configuration>
<execution>
<executions>
This solution works but I will end up with an endless spaghetti pom which is a nightmare to maintain. I tried the following:
<artifactItem>
<groupId>com.company.group</groupId>
<artifactId>artifact-id</artifactId>
<version>${project.version}</version>
<type>jar</type>
<outputDirectory>${basedir}/firstLocation</outputDirectory>
<outputDirectory>${basedir}/secondLocation</outputDirectory>
<destFileName>myCustom.jar</destFileName>
But it didn't copy anything (There were no failures in log either :)
Any idea how can I achieve this goal and keep my pom as short and clear as possible?