maven install jar to repository locally

To install a custom JAR, such as your-library-x.x.x.jar into your local Maven repository, run the command below. The underlined values vary for your project.
mvn install:install-file -Dfile=/absolute/path/to/your-library.jar -DgroupId=com.yourcompany -DartifactId=your-library -Dversion=1.0.0 -Dpackaging=jar

After installation, add the dependency to your pom.xml:
        <dependency>
            <groupId>com.yourcompany</groupId>
            <artifactId>your-library</artifactId>
            <version>1.0.0</version>
        </dependency>

As an alternative, you can reference the JAR directly from your file system. This avoids forcing every developer and CI server to run the install command each time a local JAR is added.

Take a look at the following blog post for a detailed guide:
Using a local JAR without installing it manually


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...