gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-01 10:19:25 25 4
gpt4 key购买 nike

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

  • 有问题的第 3 方库是 org.eclipse.bpmn2 0.7.0
    • 据我们所知,该库并未托管在远程 Maven 存储库中
  • 我们已将第 3 方库上传到托管的 Nexus 第 3 方存储库
  • 我们有一些指向网络的代理 Nexus 存储库(有效)

现在到(可能)问题部分:

  • 我们的项目由 Eclipse 插件组成
    • 因此,我们需要访问 eclipse p2 存储库
  • Manifest.MF 中描述了对第 3 方库的依赖
  • Nexus Open Source 不支持 p2 存储库
    • 因此,我们必须将 Eclipse p2 存储库添加到项目 POM

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

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

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

可能很重要:本地 Maven 存储库和 Nexus 如何协同工作?本地存储库是否多余?它会与 Nexus 库冲突吗?或者 Maven 只从 Nexus 加载依赖项并存储在本地存储库中?我们应该在安装 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 参数):

  • 组 ID:org.eclipse
  • Artifact ID:org.eclipse.bpmn2
  • 版本:0.7.0.201111021300
  • 包装:jar

可能很重要:分类器为空。这里应该输入什么?

当使用 -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

我们做错了什么?

最佳答案

这里发生了一些事情:

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 从远程存储库请求在本地存储库中找不到的 Artifact 。 Nexus 是一个远程存储库,即使它在同一台机器上。因此,为了让请求通过新的 Nexus 设置运行,您需要先清空本地存储库。然后 Maven 会将内容缓存在 Nexus 和本地存储库中。

接下来就是你拥有这个:

<mirrorOf>*</mirrorOf>

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

<mirrorOf>*,!indigo</mirrorOf>

此外,Nexus 的 p2 插件是开源的,它们只是默认不包含在 bundle 中,但您可以手动下载和安装它们。

最后,我们这里有可能对您有帮助的 IRC 聊天室、邮件列表和知识库:http://www.sonatype.org/nexus/participate

关于maven - 如何正确使用 Nexus 和 Maven/Jenkins 作为第 3 方库(不在 Maven 存储库中)和必要的 p2 存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10123273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com