maven install jar to repository locally

Run the following command to install the "MyJar-x.x.x.jar" into Local maven repository. The underlined  values vary in your case.
mvn install:install-file -Dfile=PathOFJar_MyJar-x.x.x.jar -DgroupId=com.mycompany -DartifactId=myJar -Dversion=x.x.x -Dpackaging=jar

After installing, Add the dependency into Pom.xml :
        <dependency>
            <groupId>com.mycompany</groupId>
            <artifactId>myJar</artifactId>
            <version>x.x.x</version>
        </dependency>

As an alternative, you can directly refer to a jar file in your file system. This eliminates the hassle that every team member and build server to run the mvn:install command every time someone adds some local jar in pom.xml.

Take a look at following blog post for the details.
http://ganeshtiwaridotcomdotnp.blogspot.com/2016/12/maven-use-local-jar-without-installing.html


1 comment :

  1. I ran into a problem specifying the variable on Windows. It seems there's a problem with how maven parses commands containing special characters. So far I've tried double/single quotes to no avail. I figure I'll just have to shuffle the jar around until I get it into Mavens preferred path.

    ReplyDelete

Your Comment and Question will help to make this blog better...