Suppose I have two Java projects in Maven / Eclipse:
I'd like to make it possible for others to build, modify and run the application (and contribute back to the open source project if they like!), but this means that they will also need the library as a dependency.
I'd like to keep things simple, so that builds are easy both for myself and users of the application.
What's the most practical way to make this work?
Provide your own Maven repository on GitHub to distribute the closed source library which you are allowed to redistribute and reference it from your project (pom.xml).
http://cemerick.com/2010/08/24/hosting-maven-repos-on-github gives a nice introduction on how to set up a repository on GitHub. You should be aware of the caveats of such a micro repository also mentioned in that post.
A really simple solution would be to place your private library into your project (e.g. <project>/lib/library-1.0.jar
) and include it as system dependency. You can include it in your pom like.
<dependencies>
<dependency>
<groupId>my.private</groupId>
<artifactId>library</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/library-1.0.jar</systemPath>
</dependency>
</dependencies>
Caution: A system dependency is not transitiv!
From the documentation
This scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repository.
When working with Maven it is recommended to use a Maven Repository Manager such as Nexus and configure your settings file as described here:
https://help.sonatype.com/display/NXRM3/Maven+Repositories#MavenRepositories-ConfiguringApacheMaven
In your situation this has the additional benefit that you could use the Maven Repository Manager to host any private artifacts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With