The deploy plugin has all the necessary features:
You can set the G/A/V coordinates in its configuration and deploy any number of additional artifacts to any coordinates you want. It does not, though, automatically deploy to the repository-URLs given in your distributionManagement
section.
To avoid duplication, I finally resorted to the GMaven plugin, used it to check the project version (does it end in -SNAPSHOT
) and set a new property with the URL taken directly from the corresponding section of the distributionManagement
.
Here's the configuration for both plugins:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<executions>
<execution>
<id>choose-target-repository</id>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
if (project.version.endsWith("-SNAPSHOT")){
project.properties.targetrepository = project.distributionManagement.snapshotRepository.url;
}
else {
project.properties.targetrepository = project.distributionManagement.repository.url;
}
</source>
</configuration>
</execution>
</executions>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<configuration>
<skip>true</skip>
</configuration>
<executions>
<execution>
<id>deploy-myclassifier</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file>
${project.build.directory}/${project.artifactId}-${project.version}-myclassifier.zip
</file>
<groupId>${project.groupId}</groupId>
<artifactId>myprojectname</artifactId>
<version>${project.version}</version>
<classifier>myclassifier</classifier>
<repositoryId>nexus</repositoryId>
<url>http://url-to-nexus</url>
</configuration>
</execution>
</executions>
</plugin>