How to add maven dependency from github?

1.7k views Asked by At

I'm trying to figure out how to configure my pom file to add a dependency that is published on Github but which does not appear in the central repository. The jpen library is published here:

https://github.com/qupath/qupath/tree/master/maven/repo/net/sourceforge/jpen/jpen/2-150301

Below is what I've added to my POM file:

<project>

    ...

    <repositories>
        <repository>
            <id>msel.releases</id>
            <url>https://github.com/qupath/qupath/tree/master/maven/repo/net/sourceforge/jpen/jpen/2-150301</url>
            <releases>
                <enabled>true</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
        </repository>
    </repositories>

    <dependencies>

        ...

        <dependency>
            <groupId>net.sourceforge.jpen</groupId>
            <artifactId>jpen</artifactId>
            <version>4.0.0</version>
        </dependency>
    </dependencies>

</project>

When I compile I get:

Failed to execute goal on project MacawSwing: 
Could not resolve dependencies for project com.kitfox.macaw:MacawSwing:jar:1.0-SNAPSHOT: 
Failed to collect dependencies for [com.kitfox.macaw:MacawCore:jar:1.0-SNAPSHOT (compile), 
com.kitfox.docking:MacawDocking:jar:1.0-SNAPSHOT (compile), 
net.sourceforge.jpen:jpen:jar:4.0.0 (compile), 
javax.vecmath:vecmath:jar:1.5.2 (compile)]: 
Failed to read artifact descriptor for com.kitfox.docking:MacawDocking:jar:1.0-SNAPSHOT: 
Failure to find com.kitfox.macaw:Macaw:pom:1.0-SNAPSHOT in https://github.com/qupath/qupath/tree/master/maven/repo/net/sourceforge/jpen/jpen/2-150301 
was cached in the local repository, resolution will not be reattempted until the update interval of msel.releases has elapsed or updates are forced -> [Help 1]

Those other dependencies are either local on my machine or in central and compiled fine before I tried to add the jpen dependency.

How can I fix this?

1

There are 1 answers

0
Jasper Huzen On

Some options:

  1. If you are using a Nexus server you can add that dependency to that.
  2. Add it to Maven Central (please contact the development team of the Git project).
  3. Make use of JitPack. Clone the project on GitHub and change the configuration to let it work with JitPack. Also configure JitPack in your own Maven Pom.

It is also advisable to make use of released or tagged versions instead of a snapshot version.