首页 文章

如何正确使用Nexus和Maven / Jenkins作为第三方库(不在Maven存储库中)和必要的p2存储库

提问于
浏览
3

我们使用Jenkins / Maven进行BuildManagement和持续集成 . 管理第三方库应该由我们设置的Nexus服务器处理 .

  • 有问题的第三方库是org.eclipse.bpmn2 0.7.0

  • 据我们所知,此库未托管在远程Maven存储库中

  • 我们已将第三方库上传到托管的Nexus第三方存储库

  • 我们有一些代理Nexus存储库指向Web(工作)

现在到(也许)问题部分:

  • 我们的项目由Eclipse插件组成

  • 因此我们需要访问eclipse p2存储库

  • Manifest.MF中描述了对第三方库的依赖性

  • Nexus Open Source不支持p2存储库

  • 因此,我们必须将Eclipse p2存储库添加到项目POM中

首先,(可能)来自Jenkins使用的Maven的settings.xml中的相关设置:

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

我们有一个本地Maven存储库 .

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>

您可能已经看到,我们现在使用默认的nexus配置 . 现在到相关项目POM内容:

<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>

我们尝试将p2存储库合并到Nexus中,但随后发现开源版本无法处理p2存储库 . 所以我们需要在项目POM中将它们作为存储库以及Nexus . MDT存储库已被注释掉,因为它似乎没有它 .

对org.eclipse.bpmn2的依赖是在相应插件的manifest.MF中使用它:

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

该库已上传至Nexus(使用GAV参数):

  • GroupID:org.eclipse

  • ArtifactID:org.eclipse.bpmn2

  • 版本:0.7.0.201111021300

  • 包装: jar

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

使用-e -X启动Jenkins作业和Maven时,输出如下:

[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

我们做错了什么?

2 回答

  • 0

    你有几件事情在这里:

    也许很重要:本地Maven回购和Nexus如何协同工作?本地存储库是多余的吗?它可能与Nexus库冲突吗?或者Maven是否只从Nexus加载依赖项并存储在本地存储库中?我们应该在安装Nexus后将其清空吗?

    Maven从远程存储库请求本地存储库中找不到的工件 . Nexus是一个远程存储库,即使它位于同一台机器上 . 因此,为了通过新的Nexus设置获取请求,您需要先清空本地存储库 . 然后,事情将被缓存在Nexus和Maven的本地回购中 .

    接下来就是你有这个:

    <mirrorOf>*</mirrorOf>
    

    它告诉maven向Nexus请求所有存储库 . 这将包括您在设置中定义的P2 repo . 为了告诉Maven绕过镜像,你想这样做:

    <mirrorOf>*,!indigo</mirrorOf>
    

    此外,Nexus的p2插件可用于开源,默认情况下它们不包含在捆绑包中,但您可以手动下载和安装它们 .

    最后,我们在这里有IRC房间,邮件列表和知识库,可能对您有所帮助:http://www.sonatype.org/nexus/participate

  • 3

    默认情况下,Tycho不会在Maven存储库中搜索以解析依赖关系 . (背景:搜索完整的Maven存储库是不可能的,因为Maven存储库的索引不包含Tycho进行依赖性解析的足够信息,因此Tycho将被迫下载并分析所有Maven工件 . )

    但是,可以在Tycho的搜索空间中添加一些Maven文物(所谓的“target platform”):

    • target-platform-configuration 插件上设置 pomDependencies = consider (有关示例POM,请参阅here

    • 通过POM中的GAV向org.eclipse.bpmn2包添加依赖项 .

    如果您在清单中有 Require-Bundle: org.eclipse.bpmn2 ,则Tycho将能够解析该依赖关系,因为该捆绑包位于目标平台中 .

    请注意,您需要在所有传递上需要org.eclipse.bpmn2包的模块中具有上述配置和依赖关系,因此您可能希望将其放入父POM中 .

相关问题