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?
The maven deploy plugin can be used to deploy either files or projects to the remote repository for sharing it with other developers and projects. There are various methods can be used to deploy your artifact to the remote repository by using a maven deploy plugin.
The deploy is the last phase of the maven lifecycle. In this phase, the build is completed and the current project is being copied to the remote repository. This makes the built project available for other projects to add as dependency or developers.
There are various methods can be used to deploy your artifact to the remote repository by using a maven deploy plugin. One of the most basic ones is using the FTP to deploy artifacts in the maven project while using the deploy plugin.
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.
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
.
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