Search This Blog

Thursday, February 20, 2014

Adding Unmanaged Dependencies to a Maven Project

Adding Unmanaged Dependencies to a Maven Project

To add a local jar to maven build you need to deploy it to your project's local repository (that's NOT your local maven's repository placed in home/user/.m2 folder).

Adding the jar file as a system dependency won't work as the jar would have to be copied by hand to every device where you want to install your application.

Changing local system dependency to maven's local project repository:

            <dependency>
            <groupId>com.wagnerandade</groupId>
            <artifactId>coollection</artifactId>
            <version>0.2.2</version>
            <scope>system</scope>
            <systemPath>${project.basedir}/lib/coollection-0.2.2.jar</systemPath>
        </dependency>

Use the command to register a local project repository:

mvn deploy:deploy-file -Durl=file:///android/myapplication/repo/ -Dfile=coollection-0.2.2.jar -DgroupId=com.wagnerandade -DartifactId=coollection -Dpackaging=jar -Dversion=0.2.2



and change the pom to:

          <repositories>
        <repository>
            <id>project.local</id>
            <name>project</name>
            <url>file:${project.basedir}/repo</url>
        </repository>
    </repositories>

[...]

        <dependency>
            <groupId>com.wagnerandade</groupId>
            <artifactId>coollection</artifactId>
            <version>0.2.2</version>
     </dependency>


PDF tutorial



No comments:

Post a Comment

If you like this post, please leave a comment :)