How do I correctly use Nexus and Maven/Jenkins for a 3rd Party library (not in Maven Repository) and a necessary p2 repository

danowar picture danowar · Apr 12, 2012 · Viewed 8.9k times · Source

we use Jenkins/Maven for BuildManagement and Continuous Integration. Managing 3rd party libraries should be handled by the Nexus Server we set up.

  • A 3rd party library in question is org.eclipse.bpmn2 0.7.0
    • This library isn't hosted at a remote Maven repository, as far as we know
  • We've uploaded the 3rd party libraries to a hosted Nexus 3rd party repository
  • We have some proxy Nexus repositories pointing around the web (which work)

Now to the (maybe) problem part:

  • Our project consists of Eclipse plugins
    • We therefore need access to a eclipse p2 repository
  • The dependencies to 3rd party libraries are described in the Manifest.MF
  • Nexus Open Source doesn't support p2 repositories
    • We therefore have to add the Eclipse p2 repository to the project POM

First, (probably) relevant settings from our settings.xml from the Maven that Jenkins uses:

<localRepository>/var/lib/jenkins/local_repo</localRepository>

We have a local Maven repository.

Maybe important: How do the local Maven repo and Nexus work together? Is the local repository redundant? Could it conflict with Nexus libraries? Or does Maven only load the dependencies from Nexus and store in the local repository? Should we have emptied it after installing Nexus?

<mirrors>
  <mirror>
  <!--This sends everything else to /public -->
  <id>nexus</id>
  <mirrorOf>*</mirrorOf>
  <url>http://localhost:8082/nexus/content/groups/public</url>
  </mirror>
</mirrors>

<profile>
    <id>nexus</id>
<!--Enable snapshots for the built central repo to direct
    all requests to nexus via the mirror -->
    <repositories>
        <repository>
            <id>central</id>
            <url>http://central</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>central</id>
            <url>http://central</url>
            <releases><enabled>true</enabled></releases>
            <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
    </pluginRepositories>
</profile>

<activeProfiles>
    <activeProfile>nexus</activeProfile>
</activeProfiles>

As you can probably see, we use the default nexus config for now. Now to the relevant project POM contents:

<repositories>
<!--
    <repository>
        <id>UML2</id>
        <layout>p2</layout>
        <url>http://download.eclipse.org/modeling/mdt/updates/releases/</url>
    </repository>
-->
    <repository>
        <id>indigo</id>
        <layout>p2</layout>
        <url>http://download.eclipse.org/releases/indigo</url>
    </repository>
</repositories>

We tried to incorporate the p2 repositories into Nexus, but then saw that the open source version can't handle p2 repositories. So we need to have them in the project POM, as repositories in addition to the Nexus. The MDT repository is commented out because it seems to work without it.

The dependency to org.eclipse.bpmn2 is in the manifest.MF of the corresponding plugin using it:

Require-Bundle: 
 org.eclipse.bpmn2;bundle-version="0.7.0";visibility:=reexport

The library was uploaded to Nexus (using GAV parameters):

  • GroupID: org.eclipse
  • ArtifactID: org.eclipse.bpmn2
  • version: 0.7.0.201111021300
  • packaging: jar

MAYBE IMPORTANT: The classifier was left empty. What should be entered here?

When starting the Jenkins job and Maven with -e -X the output is as follows:

[DEBUG] P2resolver.addMavenProject de.some.tool:pom:2.0
[INFO] Adding repository (cached) http://download.eclipse.org/releases/indigo
[DEBUG] Added p2 repository indigo (http://download.eclipse.org/releases/indigo)
[INFO] Cannot complete the request.  Generating details.
[INFO] Cannot complete the request.  Generating details.
[INFO] {org.osgi.framework.executionenvironment=OSGi/Minimum-1.0,OSGi/Minimum-1.1, osgi.ws=gtk, osgi.arch=x86, osgi.os=linux, org.eclipse.update.install.features=true, org.osgi.framework.system.packages=}
[ERROR] Cannot resolve project dependencies:
[ERROR]   Software being installed: de.modeltype.bpmn2 1.0.0.qualifier
[ERROR]   Missing requirement: de.modeltype.bpmn2 1.0.0.qualifier requires 'bundle org.eclipse.bpmn2 0.7.0' but it could not be found
[ERROR] 
mavenExecutionResult exceptions not empty
message : Internal error: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependency from de.modeltype.bpmn2 1.0.0.qualifier to bundle org.eclipse.bpmn2 0.7.0.", "No solution found because the problem is unsatisfiable."]
cause : "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependency from de.modeltype.bpmn2 1.0.0.qualifier to bundle org.eclipse.bpmn2 0.7.0.", "No solution found because the problem is unsatisfiable."]
Stack trace : 
org.apache.maven.InternalErrorException: Internal error: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependency from de.modeltype.bpmn2 1.0.0.qualifier to bundle org.eclipse.bpmn2 0.7.0.", "No solution found because the problem is unsatisfiable."]
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:168)
    at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
    at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:104)
    at hudson.maven.Maven3Builder.call(Maven3Builder.java:70)
    at hudson.remoting.UserRequest.perform(UserRequest.java:118)
    at hudson.remoting.UserRequest.perform(UserRequest.java:48)
    at hudson.remoting.Request$2.run(Request.java:287)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
    at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
    at java.util.concurrent.FutureTask.run(FutureTask.java:138)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
Caused by: java.lang.RuntimeException: "No solution found because the problem is unsatisfiable.": ["Unable to satisfy dependency from de.modeltype.bpmn2 1.0.0.qualifier to bundle org.eclipse.bpmn2 0.7.0.", "No solution found because the problem is unsatisfiable."]
    at org.eclipse.tycho.p2.impl.resolver.ProjectorResolutionStrategy.resolve(ProjectorResolutionStrategy.java:106)
    at org.eclipse.tycho.p2.impl.resolver.P2ResolverImpl.resolveProject(P2ResolverImpl.java:102)
    at org.eclipse.tycho.p2.impl.resolver.P2ResolverImpl.resolveProject(P2ResolverImpl.java:69)
    at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.doResolvePlatform(P2TargetPlatformResolver.java:342)
    at org.eclipse.tycho.p2.resolver.P2TargetPlatformResolver.resolvePlatform(P2TargetPlatformResolver.java:162)
    at org.eclipse.tycho.core.resolver.DefaultTychoDependencyResolver.resolveProject(DefaultTychoDependencyResolver.java:85)
    at org.eclipse.tycho.core.maven.TychoMavenLifecycleParticipant.afterProjectsRead(TychoMavenLifecycleParticipant.java:91)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:273)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
    ... 19 more
channel stopped
Finished: FAILURE

What are we doing wrong?

Answer

Brian Fox picture Brian Fox · Apr 13, 2012

You have a few things going on here:

Maybe important: How do the local Maven repo and Nexus work together? Is the local repository redundant? Could it conflict with Nexus libraries? Or does Maven only load the dependencies from Nexus and store in the local repository? Should we have emptied it after installing Nexus?

Maven makes requests for artifacts not found in the local repository from the remote repositories. Nexus is a remote repository, even if it's on the same machine. So in order to get requests running through your new Nexus setup, you need to first empty the local repo. Then things will be cached in Nexus and in the local repo by Maven.

The next thing is that you have this:

<mirrorOf>*</mirrorOf>

which tells maven to make requests to Nexus for ALL repositories. This would include the P2 repo you defined lower in your settings. In order to tell Maven to bypass the mirror, you want to do this:

<mirrorOf>*,!indigo</mirrorOf>

Additionally, the p2 plugins for Nexus are available for open source, they just aren't included in the bundle by default, but you can download and install them manually.

And finally, we have IRC rooms and mailing lists and knowledgebases here that might be helpful to you: http://www.sonatype.org/nexus/participate