0

我有一个 Nexus 实例,其 Maven 2 存储库托管在未连接 Internet 的公司开发域上。我需要使用 Sun 的maven-jaxb-schemagen插件,但是,它只能以 Maven 1 格式提供(以及许多其他 Maven 1 依赖项,因此这不是一次性的极端情况)。

我在 Nexus ( maven1 ) 中创建了一个新的 Maven 1 托管存储库,然后也创建了一个 Maven1-to-Maven2 虚拟存储库 ( maven1as2 )。因为一些所需的工件是快照,所以maven1(以及扩展名maven1as2)的策略是Snapshot

我通过文件系统将所有 Maven 1 工件导入到此存储库的覆盖本地存储位置。

然后我将maven1as2添加到我的公共存储库组中。我发现的一些参考资料说 Nexus 不允许您浏览或搜索 Maven1 存储库。我的结果好坏参半。如果我在 Nexus 中选择Public Repositoriesmaven1as2,我可以转到Browse Storage并向下钻取到com/sun/tools/jxc/maven2/maven-jaxb-schemagen-plugin/1.3-SNAPSHOT/并查看maven-jaxb-schemagen -plugin-1.3-SNAPSHOT.pom文件及其校验和。但是,我无法查看应该存在且位于文件系统上的JAR工件。

当我尝试使用 Maven 构建时,我得到以下信息:

$ mvn clean compile
[INFO] Scanning for projects...
[INFO] Reactor build order:
[INFO]   MyProject
[INFO]   MyModule1
[INFO]   MyModule2
         ...
[INFO] ---------------------------------------------------------------------------
[INFO] Building MyProject
[INFO]    task-segment: [clean, compile]
[INFO] ---------------------------------------------------------------------------
[INFO] [clean:clean {execution: default-clean}]
[INFO] [cobertura:clean {execution: default}]
[INFO] No goals needed for project - skipping
[INFO] ---------------------------------------------------------------------------
[INFO] Building MyModule1
[INFO]    task-segment: [clean, compile]
[INFO] ---------------------------------------------------------------------------
Downloading: http://my.nexus.server:8081/nexus/content/groups/public/com/sun/tools/jxc/maven2/maven-jaxb-schemagen-plugin/1.3-SNAPSHOT/maven-jaxb-schemagen-plugin-1.3-SNAPSHOT.pom
6K downloaded (maven-jaxb-schemagen-plugin-1.3-SNAPSHOT.pom)
[INFO] ---------------------------------------------------------------------------
[ERROR] BUILD FAILURE
[INFO] ---------------------------------------------------------------------------
[INFO] A required plugin was not found: Plugin could not be found - check that the goal name is correct: Unable to download the artifact from any repository

Try downloading the file manually from the project website.

Then, install it using the command:
    mvn install:install-file -DgroupId=com.sun.tools.jxc.maven2 -DartifactId=maven-jaxb-schemagen-plugin -Dversion=1.3-SNAPSHOT -Dpackaging=maven-plugin -Dfile=path/to/file

Alternatively, if you host your own repository you can deploy the file there:
    mvn deploy:deploy-file -DgroupId=com.sun.tools.jxc.maven2 -DartifactId=maven-jaxb-schemagen-plugin -Dversion=1.3-SNAPSHOT -Dpackaging=maven-plugin -Dfile=path/to/file -Durl=[url] -DrepositoryId=[id]


  com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.3-SNAPSHOT

from the specified remote repositories:
  nexus (http://my.nexus.server:8081/nexus/content/groups/public)


  com.sun.tools.jxc.maven2:maven-jaxb-schemagen-plugin:1.3-SNAPSHOT

from the specified remote repositories:
  nexus (http://my.nexus.server:8081/nexus/content/groups/public)

[INFO] ---------------------------------------------------------------------------
[INFO] For more information, run Maven with the -e switch
[INFO] ---------------------------------------------------------------------------
[INFO] Total time: 2 seconds
[INFO] Finished at: Tue Jul 06 15:05:08 EDT 2010
[INFO] Final Memory: 7M/17M
[INFO] ---------------------------------------------------------------------------
4

2 回答 2

0

有时在使用 m2eclipse 时会发生这种情况。您选择了一个依赖项,默认范围是 pom 而不是 jar。你没有显示你的pom文件。验证所有依赖项都是 jar 范围的。

于 2010-07-19T16:27:13.653 回答
0

我了解到,大多数时候重建存储库的元数据有助于解决这些问题。我觉得这很烦人。

  • 选择存储库
  • 在“浏览存储”选项卡中打开根节点的上下文菜单(它有时隐藏在 Firefox 默认上下文菜单后面 - 在这种情况下按 Esc 会有所帮助,并会显示 Nexus 上下文菜单)
  • 选择重建元数据

在某些情况下,过期缓存和重新索引也可能有所帮助。
大多数情况下,这些步骤在第一次尝试时并没有解决问题,但最后他们每次都解决了。

我在 Glassfish 2.1 中将 Nexus 作为 WAR 运行

于 2010-07-20T06:21:11.423 回答