Maven: Including jar not found in public repository

If you have a parent project with a module that is in this situation (requires a dependency not in a repository) you can setup your parent project to use the exec-maven-plugin plugin to auto-install your dependent file. For example, I had to do this with the authorize.net jar file since it is not publicly available.

Parent POM:

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>1.2.1</version>
            <inherited>false</inherited>
            <executions>
                <execution>
                    <id>install-anet</id>
                    <phase>validate</phase>
                    <goals>
                        <goal>exec</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>
                <executable>mvn</executable>
                <arguments>
                    <argument>install:install-file</argument>
                    <argument>-Dfile=service/lib/anet-java-sdk-1.4.6.jar</argument>
                    <argument>-DgroupId=net.authorize</argument>
                    <argument>-DartifactId=anet-java-sdk</argument>
                    <argument>-Dversion=1.4.6</argument>
                    <argument>-Dpackaging=jar</argument>
                </arguments>
            </configuration>
        </plugin>
    </plugins>
</build>

In the above example, the location of the jar is in the lib folder of the "service" module.

By the time the service module enters the validate phase, the jar will be available in the local repository. Simply reference it in the way you set up the groupid, artifact, etc in the parent pom. For example:

<dependency>
    <groupId>net.authorize</groupId>
    <artifactId>anet-java-sdk</artifactId>
    <version>1.4.6</version>
</dependency>

You can install the project yourself.

Or you can use the system scope like the following:

<dependency>
    <groupId>org.group.project</groupId>
    <artifactId>Project</artifactId>
    <version>1.0.0</version>
    <scope>system</scope>
    <systemPath>${basedir}/lib/project-1.0.0.jar</systemPath>
</dependency>

systemPath requires the absolute path of the project. To make it easier, if the jar file is within the repository/project, you can use ${basedir} property, which is bound to the root of the project.