Wednesday, August 11, 2010

Guide to installing 3rd party JARs or Guide to use 3rd party JARs with Maven

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 instead to local repository the JAR will be install 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 %M2_HOME%/lib.

Then execute the command:

mvn deploy:deploy-file -DgroupId= \
-DartifactId= \
-Dversion= \
-Dpackaging= \
-Dfile= \
-DrepositoryId= \
-Durl=

Deploying a 3rd party JAR with a generic POM

By default, deploy:deploy-file generates a generic POM(.pom) to be deploy 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 customed POM

If a POM is already existing for the 3rd Party JAR and you want to deploy it together with the JAR we should use the pomFile argument of the deploy-file goal. See sample below.

mvn deploy:deploy-file -DpomFile= \
-Dfile= \
-DrepositoryId= \
-Durl=

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.

Ref - http://maven.apache.org/guides/mini/guide-3rd-party-jars-remote.html

Guide to installing 3rd party JARs

Often times you will have 3rd party JARs that you need to put in your local repository for use in your builds. The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Maven. To make this easier, and less error prone, we have provide a goal in the install plug-in which should make this relatively painless. To install a JAR in the local repository use the following command:

mvn install:install-file -Dfile= -DgroupId= \
-DartifactId= -Dversion= -Dpackaging=

Refrence http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html
[DEBUG] Unable to locate resource in repository
org.apache.maven.wagon.ResourceDoesNotExistException: Unable to locate resource in repository

Try downloading the file manually from the project website.

Then, install it using the command:
mvn install:install-file -DgroupId=jasperreports -DartifactId=jasperreports -Dversion=3.7.1 -Dpackaging=jar -Dfile=/path/to/file

Alternatively, if you host your own repository you can deploy the file there:
mvn deploy:deploy-file -DgroupId=jasperreports -DartifactId=jasperreports -Dversion=3.7.1 -Dpackaging=jar -Dfile=/path/to/file -Durl=[url] -DrepositoryId=[id]

Path to dependency:
1) java_farm_core_v1.2:java_farm_core_v1.2:jar:0.0.1-SNAPSHOT
2) jasperreports:jasperreports:jar:3.7.1

No comments: