Maven: Including jar not found in public repository

Viewed 46238

If I was to use a 3rd party library that was not in the maven public repository, what is the best way to include it as dependency for my project so that when someone else checks out my code it will still be able to build?

i.e.

My Application "A" depends on jar "B" which does not exist in the public repository. I, however, wish to add "B" as a dependency to "A" such that when a person on the other side of the world could check out the code and still be able to build "A"

6 Answers

This solution worked for me; 1. Created a local-maven-repo in my project's root directory and copied all my jars in the 2. Executed the following command to generate the necessary pom files and metadata etc for each and every jar that I needed to use;

mvn deploy:deploy-file -DgroupId=<somegroupid> -DartifactId=<someartifact> -Dversion=1.0.0 -Durl=file:./local-maven-repo/ -DrepositoryId=local-maven-repo -DupdateReleaseInfo=true -Dfile=<path to jar file>

This generated a new jar file with a pom file inside the local-maven-repo and I was able to include into my project as a dependency like this;

    <dependency>
        <groupId>somegroupid</groupId>
        <artifactId>someartifact</artifactId>
        <version>1.0.0</version>
    </dependency>

Then mvn package ensured that my project dependencies are resolved and packaged with my war file.

Related