Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I include the mvn deploy:deploy-file in the pom or settings.xml instead of cli goal

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?

like image 737
user171943 Avatar asked Feb 02 '16 16:02

user171943


People also ask

What is the Maven deploy plugin?

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.

What is the deploy phase in Maven?

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.

How to deploy artifacts to a remote repository using Maven deploy plugin?

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.

How do I deploy a JAR file in Maven?

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.


Video Answer


1 Answers

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.

like image 97
Tunaki Avatar answered Sep 22 '22 16:09

Tunaki