How to add maven dependency from github? - maven

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?

Some options:
If you are using a Nexus server you can add that dependency to that.
Add it to Maven Central (please contact the development team of the Git project).
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.

Related

Adding a Github release to my maven pom.xml file

I need to add the following GitHub project as a dependency in my pom.xml:
https://github.com/loomchild/maligna
This project defines two maven modules: maligna and maligna-ui and I need both.
Unfortunately, it seems only the first module (maligna) is being deployed to a maven artifactory.
I tried using jitPack, as follows:
<pluginRepositories>
<pluginRepository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</pluginRepository>
</pluginRepositories>
...
<depencies>
...
<dependency>
<groupId>com.github.loomchild.maligna</groupId>
<artifactId>maligna-ui</artifactId>
<version>3.0.1</version>
</dependency>
...
</depencies>
but I get the following error
[ERROR] Failed to execute goal on project iutools-core: Could not resolve dependencies for project org.iutools:iutools-core:jar:1.0.2: Failure to find com.github.loomchild.maligna:maligna-ui:jar:3.0.1 in https://repository.apache.org/content/repositories/snapshots was cached in the local repository, resolution will not be reattempted until the update interval of snapshots has elapsed or updates are forced -> [Help 1]
Is there something I misundertand about how to use jitPack?

Maven not downloading dependency from custom repository

I'm trying to share some code between two projects by loading it as a dependency via maven. For some reason, I can't get Maven to pick up the dependency.
Here's how I generated the shared JAR:
mvn install:install-file -Dfile=/Users/usr1/shared-code-1.0.0.jar -DpomFile=/Users/usr1/shared-code/pom.xml -DlocalRepositoryPath=.
This jar is held in a git repo github.com/myOrg/myRepo/repository where repository is the branch. The configuration described in the pom file for the shared code looks like this:
<groupId>com.myOrg</groupId>
<artifactId>shared-code</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
Here's how I defined the dependency and repository in my other code bases:
<dependency>
<groupId>com.myOrg</groupId>
<artifactId>shared-code</artifactId>
<version>1.0.0</version>
</dependency>
...
...
<repository>
<id>shared-code/id>
<name>Shared code for my stuff</name>
<url>http://raw.github.com/myOrg/myRepo/repository</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>\
The exact error I'm getting when I try and do a mvn clean package is:
[ERROR] Failed to execute goal on project otherCodeBase: Could not resolve dependencies for project otherCode:myProject:jar:latest: Failure to find com.myOrg:shared-code:jar:1.0.0 in http://[company's artifactory repo] was cached in the local repository, resolution will not be reattempted until the update interval of artifactory has elapsed or updates are forced -> [Help 1]
At first glance, it looks like Maven isn't even scanning the repository I defined in my other code's pom file, but when I execute mvn help:effective-pom it does appear. I should also add that I did make this repository public for the sake of getting it to work once. What gives?

Spring Asciidoctor Extensions not in correct repo?

Good afternoon guys,
I've been trying to get spring-asciidoctor-extensions to work with my documentation but for some reason maven can't find the dependency.
The error i got after my build attempt:
Failed to execute goal org.asciidoctor:asciidoctor-maven-plugin:1.5.5:process-asciidoc (generate-docs) on project organization: Execution generate-docs of goal org.asciidoctor:asciidoctor-maven-plugin:1.5.5:process-asciidoc failed: Plugin org.asciidoctor:asciidoctor-maven-plugin:1.5.5 or one of its dependencies could not be resolved: Failure to find io.spring.asciidoctor:spring-asciidoctor-extensions:jar:0.1.1.RELEASE in https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced -> [Help 1]
I checked thier GitHub and looked around to find out that theres nothing in the maven repo (obvious from error) and in this question found that the repo is in https://repo.spring.io/release. Is there a way to reference a dependency to a repo directly? If not what can i do?
You can add the repo.spring.io repository to your pom.xml.
<repositories>
<repository>
<id>spring-repo</id>
<url>https://repo.spring.io/release</url>
</repository>
</repositories>
With that declaration in place you will be able to resolve this dependency:
<dependency>
<groupId>io.spring.asciidoctor</groupId>
<artifactId>spring-asciidoctor-extensions</artifactId>
<version>0.1.1.RELEASE</version>
</dependency>
More details in the docs.
Note: it is not possible to explicitly associate this dependency with that repository. Maven walks through the repositories in order of their declaration until a given dependency is resolved (or not) however if all of your other dependencies are resolved from Maven Central then the only dependency left to be resolved from repo.spring.io will be spring-asciidoctor-extensions.
I ran into this issue as well. My misconception at first was that I expected the dependencies to be resolved from the repositories section. However turns out that it's rather the pluginRepositories section. Like so:
<pluginRepositories>
<pluginRepository>
<id>spring-repo</id>
<url>https://repo.spring.io/release</url>
</pluginRepository>
</pluginRepositories>

Official Maven repo for com.springsource.org.jboss.el

I have a project with a dependency org.jboss.el:com.springsource.org.jboss.el:jar:2.0.0.GA for which I am trying to find the official Maven repository.
It is unclear to me where this depedency should come from. Should I download this and create a Nexus repo myself. Is there a official repo for this artifact?
[ERROR] Failed to execute goal on project myproject: Could not resolve dependencies for project myjar:jar:5.0.0-SNAPSHOT: Failure to find org.jboss.el:com.springsource.org.jboss.el:jar:2.0.0.GA in https://mynexusserver/nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced -> [Help 1]
The artifact org.jboss.el:com.springsource.org.jboss.el:jar:2.0.0.GA is available from Spring repositories:
You can add them by adding this snippet inside your settings or POM:
<repository>
<id>com.springsource.repository.bundles.release</id>
<name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/release</url>
</repository>
<repository>
<id>com.springsource.repository.bundles.external</id>
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
<url>http://repository.springsource.com/maven/bundles/external</url>
</repository>
Note that the error message you are getting suggest to run Maven with the -U option also, to force the updates of dependencies.

How can i use SVN as Maven Repository

I am working on project which has multiple dependencies. Most of the dependencies are available at our centralized maven repository. My project includes some JARs which only specific to my application and unavailable at our Maven repo. Due to some policy/restriction i cant deploy that jars to our maven repository.
When i install these jars in my local repository(i.e.UserHome/.m2/repository) and compile the code its working fine.
Now i want these dependencies in SVN so that we can build the application package using Continuum.(We cant refer local dependency from Continuum server.)
Just to achieve these i copied the locally installed dependency from .m2/repository and committed it in SVN. Then i declared repository in pom.xml like..
<repositories>
<repository>
<id>repo.pu</id>
<name>repo.pu</name>
<url>https://URL/migration2/APP1/src/main/lib/</url>
<layout>default</layout>
</repository>
</repositories>
Now to use dependency from above repo i added code like...
<dependencies>
<dependency>
<groupId>repo.pu</groupId>
<artifactId>Ptestval</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
When i type mvn verify i am getting the below error..
[ERROR] Failed to execute goal on project APP1: Could not resolve dependencies f
or project fileservices.migration2:APP1:jar:1.0: Failed to collect dependencies
for [repo.pu:Ptestval:jar:1.0 (compile)]: Failed to read artifact descriptor for
repo.pu:Ptestval:jar:1.0: Could not transfer artifact repo.pu:Ptestval:pom:1.0
from/to repo.pu (https://URL/migration2/APP1/src/main/lib/): Access denied to:
https://URL/migration2/APP1/src/main/lib/repo/pu/Ptestv
al/1.0/Ptestval-1.0.pom -> [Help 1]
Could you please someone help me to resolve these issue?
EDIT: I created a repository like ..
<repositories>
<repository>
<id>repo.pu</id>
<name>repo.pu</name>
<url>https://SVNUserName:SVNPassword#SVN_URL/BaseProj/ProjA/src/main/lib</url>
<layout>default</layout>
</repository>
</repositories>
This technique works perfectly at my Personal laptop. Maven downloads the listed dependency from repo.
But when tries to use the same in my project on company network it is not working .. It gives the same error which i was getting before using this approach.
Can anyone help me please? What would be problem? Is it a network issue?
Set up a repository manager like Nexus and don't abuse Subversion for something it was not designed for. This is unfortunately done in Google Code.
You must configure your project to use wagon-scm.
See http://maven.apache.org/wagon/wagon-providers/wagon-scm/usage.html

Resources