首页 文章

如何强制Sonatype Nexus更新?

提问于
浏览
17

我想在我的pom.xml中使用onejar-maven-plugin:

<plugin>
    <groupId>org.dstovall</groupId>
    <artifactId>onejar-maven-plugin</artifactId>
    <version>1.4.4</version>
    <executions>
        <execution>
            <configuration>
                <mainClass>com.exmaple.myproj.MpPort_MpSoapPort_Client</mainClass>
                <onejarVersion>0.97</onejarVersion>
                <attachToBuild>true</attachToBuild>
                <classifier>onejar</classifier>
            </configuration>
            <goals>
                <goal>one-jar</goal>
            </goals>
        </execution>
    </executions>
</plugin>

<pluginRepositories>
    <pluginRepository>
        <id>onejar-maven-plugin.googlecode.com</id>
        <url>http://onejar-maven-plugin.googlecode.com/svn/mavenrepo</url>
    </pluginRepository>
</pluginRepositories>

但由于某种原因,尝试通过Eclipse Maven插件(Maven安装)构建它会导致BUILD ERROR:

Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository onejar-maven-plugin.googlecode.com (http://onejar-maven-plugin.googlecode.com/svn/mavenrepo)
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2)
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.dstovall:onejar-maven-plugin

Reason: POM 'org.dstovall:onejar-maven-plugin' not found in repository: Unable to download the artifact from any repository

  org.dstovall:onejar-maven-plugin:pom:1.4.4

from the specified remote repositories:
  Nexus (https://mynexus.example.com/nexus/content/repositories/central)

 for project org.dstovall:onejar-maven-plugin

所以我手动下载onejar-maven-plugin.jar并通过命令行安装它,我似乎得到一个类似的错误:

C:\Users\daniel\myproj>mvn install:install-file -Dfile=onejar-maven-plugin-1.4.4.jar -DgroupId=com.jolira -DartifactId=onejar-maven-plugin -Dversion=1.4.4 -Dpackaging=jar
[INFO] Scanning for projects...
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository onejar-maven-plugin.googlecode.com (http://onejar-maven-plugin.googlecode.com/svn/mavenrepo)
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2)
Downloading: https://mynexus.example.com/nexus/content/repositories/central/org/dstovall/onejar-maven-plugin/1.4.4/onejar-maven-plugin-1.4.4.pom
[INFO] Unable to find resource 'org.dstovall:onejar-maven-plugin:pom:1.4.4' in repository central (http://repo1.maven.org/maven2)
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error building POM (may not be this project's POM).


Project ID: org.dstovall:onejar-maven-plugin

Reason: POM 'org.dstovall:onejar-maven-plugin' not found in repository: Unable to download the artifact from any repository

  org.dstovall:onejar-maven-plugin:pom:1.4.4

from the specified remote repositories:
  Nexus (https://mynexus.example.com/nexus/content/repositories/central)

 for project org.dstovall:onejar-maven-plugin

我的理解是因为我们有一个Nexus镜像,它不包含那个特殊的神器,所以事情会变得混乱 .

所以我尝试按照How to force Sonatype Nexus Regenerate / Reindex its Metadata上的说明操作,但在我们的Sonatype Nexus上按照 the “Browse Index” tab has no such context menu! 进行操作 .

enter image description here

我读here那是"Nexus only caches artifacts that clients have requested. So you need to set up your project poms to request the proper versions" . 但 that's exactly what I have been doing - 结果没有任何变化 .

如何摆脱这种“鸡蛋和鸡蛋”的情况并获得这个onejar-maven-plugin ver . 1.4.4进入我的Nexus镜像?

(或者,如何将其放入我的本地.m2缓存?)

1 回答

  • 23

    即使本地存储包含有关-U不可用的工件的元数据,您也可以强制Maven再次更新和请求依赖关系

    mvn clean install -U
    

    应该管用 .

    此外,您应该将 settings.xml 更改为指向公共组而不是直接指向中央存储库 . 更多可以找到in the Nexus book .

    您应该注意,Central Repository没有您尝试使用的 onejar 插件 . 看看search results,看看 groupIdcom.joilira 而不是 org.dstovall

    如果你真的想使用 org.dstovall 中的 onejar 插件,你应该将url http://onejar-maven-plugin.googlecode.com/svn/mavenrepo/作为代理存储库添加到Nexus,将其添加到公共组,然后使用 settings.xml 中的公共组

相关问题