Combining open-source dependency with Maven

Suppose I have two Java projects in Maven / Eclipse:

  • An open source application hosted on GitHub
  • A small private library containing utility functions that is not open source (but I have rights to modify, build and distribute in compiled form, for example, as a .jar file).

I would like others to be able to create, modify, and run the application (and return to the open source project if they like it!), But that means they will also need the library as a dependency.

I would like everything to be simple, so assembly is easy both for me and for users of the application.

What is the most practical way to do this job?

+5
source share
3 answers

Provide your own Maven repository on GitHub to distribute a private source library that you are allowed to redistribute and reference from your project (pom.xml).

http://cemerick.com/2010/08/24/hosting-maven-repos-on-github gives a good idea on how to set up a repository on GitHub. You should be aware of the warnings of such a microrepository, also mentioned in this post.

+3
source

When working with Maven, it is recommended to use the Maven Repository Manager, such as Nexus, and configure the settings file, as described here:

https://help.sonatype.com/display/NXRM3/Maven+Repositories#MavenRepositories-ConfiguringApacheMaven

, Maven Repository Manager .

+3

In fact, a simple solution would be to place your personal library in your project (for example, <project>/lib/library-1.0.jar) and include it as a 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 : system dependency is not transitive!

From the documentation

This area is similar to the one provided, except that you must provide a JAR that contains this explicitly. The artifact is always available and cannot be viewed in the repository.

+3
source

All Articles