Guide to deploying 3rd party JARs to remote repository

Same concept of the install:install-file goal of the maven-install-plugin where the 3rd party JAR is installed in the local repository. But this time the JAR will be installed both in the local and remote repository.

To deploy a 3rd party JAR, use the deploy:deploy-file goal under maven-deploy-plugin.

First, the wagon-provider(wagon-ftp, wagon-file, etc..) must be placed to your ${maven.home}/lib.

Then execute the command:

mvn deploy:deploy-file -DgroupId=<group-id> \
  -DartifactId=<artifact-id> \
  -Dversion=<version> \
  -Dpackaging=<type-of-packaging> \
  -Dfile=<path-to-file> \
  -DrepositoryId=<id-to-map-on-server-section-of-settings.xml> \
  -Durl=<url-of-the-repository-to-deploy>

Deploying a 3rd party JAR with a generic POM

By default, deploy:deploy-file generates a generic POM(.pom) to be deployed together with the 3rd party JAR. To disable this feature we should set the generatePOM argument to false.

-DgeneratePom=false

Deploying a 3rd party JAR with a customized POM

If a POM already exists for the third party JAR and you want to deploy it together with the JAR, you should use the pomFile argument of the deploy-file goal. See sample below.

mvn deploy:deploy-file -DpomFile=<path-to-pom> \
  -Dfile=<path-to-file> \
  -DrepositoryId=<id-to-map-on-server-section-of-settings.xml> \
  -Durl=<url-of-the-repository-to-deploy>

Note that groupId, artifactId, version and packaging arguments are not included here because deploy-file goal will get these information from the given POM.

Deploying Source Jars

To deploy a 3rd party source jar, packaging should be set to java-source, and generatePom should be set to false.