How can add the proprietary library in maven project with dependency?

I have a proprietary library. I am using this library in my java desktop project but now, I have a maven project. I want to add this library in my maven project with dependency. How can I do this?

Upvotes: 0

Views: 1067

Answers (2)

wsl
wsl

Reputation: 10305

Firstly you should search if this library is available as maven dependency. Try maven search.

For example if you want to include a library commons-io-2.4.jar, you serach for it in the link above, if it is in public repository (it is), then you get maven dependency:

<dependency>
  <groupId>commons-io</groupId>
  <artifactId>commons-io</artifactId>
  <version>2.4</version>
</dependency>

You should paste this dependency to your pom to dependencies tag.

If above library is not available in public repository, you have to place your jar manually in your local repository by refering to: http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

Example:

mvn install:install-file -DgroupId=commons-io -DartifactId=commons-io -Dpackaging=jar -Dversion=2.4 -Dfile=home_folder_path/commons-io-2.4.jar -DgeneratePom=true

Upvotes: 1

Puneetsri
Puneetsri

Reputation: 254

If it is not already on maven repository, simply add it to your pom.xml, and add it to your local repository.

<dependencies>
    <dependency>
        <groupId>com.proppath</groupId>
        <artifactId>mylib.jar</artifactId>
        <version>myjarversion</version>
    </dependency>

And also put this prop library into .m2\repository\com\proppath\myjarversion

Give any groupId you like but make sure that you have corresponding path on repository to find it.

Normally, in large projets these kind of propriatery libraries are stored in Nexus of your enterprise.

Upvotes: 0

Related Questions