top of page
Search
Tech Explore

Installing Third party JARs to a Maven Project - 1



Most of the time when we built a maven project we use JAR files that are hosted in Maven Central Repository.

Maven Central Repository can be access via the following URL :


In this post let us explore, how to install third party JARs to the project which are not hosted in the Maven Central Repository.


Please refer to the blog post https://serantechexplore.wixsite.com/website/post/downloading-dependencies-from-maven-central on downloading dependencies from Maven Central.


There are a lot of options available to install a third party JAR to the maven project. Third party JAR can be a proprietary JAR which is not hosted publicly OR it can be a custom JAR we have written.


  • Installing the JAR locally to the .m2 repository.

  • Adding it to the project as a system-scoped file.

  • Adding the JAR as an IntelliJ project dependency.

  • Using a repository management tool like Nexus Or Archiva.

  • Publishing the dependency to Maven Central.


Installing the JAR locally to the .m2 repository


To use third party JARs which don't exist in any public repository like Maven Central we need to put them to the local repository to be used by the builds.


The JARs must be placed in the local repository in the correct place in order for it to be correctly picked up by Apache Maven. To make this easier, and less error prone, we have provide a goal in the maven-install-plugin which should make this relatively painless.


To install a JAR in the local repository use the following command:

The groupId, artifactId, and version details can be found from the downloaded third party JAR itself. Generally we can find this information from the pom.properties file or the pom.xml file residing in the <Extracted_JAR>/META-INF/maven/<package_name>/<class_name>/ directory.


For example, let say you have downloaded the claim manager JAR file

claim-manager-4.0.0.jar mentioned in this post


Extract the JAR file and navigate to

claim-manager-4.0.0/META-INF/maven/org.wso2.samples.is/claim-manager/ directory.

There we can find the pom.properties file and pom.xml file.


We can find the groupId, artifactId, and version details from the pom.properties file.






To install the claim-manager jar file to the local repository we can execute the command as below.

Alternatively, if we have a pom.xml file available in the third party jar we can use it as well to install the jar to the local repository as below.

Now let's say i have a jar file with sources (claim-manager-4.0.0-sources.jar) which i need to associate with the executable jar file (claim-manager-4.0.0.jar) while installing.

We can use the following command with an additional -Dsources option which let us install the sources along with the executable jar.

Now the Jar file is installed in your local repository and can be referenced by the builds.


Let us continue with the remaining options in the upcoming blogs.


Thank you for reading!!!


26 views0 comments

コメント


Post: Blog2_Post
bottom of page