I need to deploy a custom jar to Artifactory along with the jar generated from my Java project. Currently the only method I can find is through command line goal using:
mvn deploy:deploy-file -DgroupId=<group-id> \
-DartifactId=<artifact-id> \
-Dversion=<version> \
-Dpackaging=<type-of-packaging> \
-Dfile=<path-to-file> \
-Durl=<url-of-the-repository-to-deploy>
Is there a way of including this in the pom file? As a plugin or something?
Sure. Just define an execution of the maven-deploy-plugin:deploy-file
goal bound to the deploy
phase, configured with your values. When deploying your project, this execution will be invoked and the JAR will be deployed.
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>deploy-file</id>
<phase>deploy</phase>
<goals>
<goal>deploy-file</goal>
</goals>
<configuration>
<file><!-- path-to-file --></file>
<url><!-- url-of-the-repository-to-deploy --></url>
<groupId><!-- group-id --></groupId>
<artifactId><!-- artifact-id --></artifactId>
<version><!-- version --></version>
<packaging><!-- type-of-packaging --></packaging>
</configuration>
</execution>
</executions>
</plugin>
Note that you will probably need to add a repositoryId
also. This is the server id to map on the <id>
under the <server>
section of the settings.xml
.