Nexus不会从默认公共组服务快照

时间:2011-03-08 16:33:10

标签: maven nexus snapshot

出于某种原因,我无法让Nexus通过默认公共组服务我的SNAPSHOT工件。我已经阅读了Nexus手册的相关内容并搜索了Google,但我所做的一切似乎都无法解决。

我已经在第4.2节中实现了这些内容。 (Configuring Maven to Use a Single Nexus Group)手册,所以我的settings.xml看起来像:

<settings>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://my-server/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

  <profiles>
    <profile>
      <id>nexus</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <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>
  </profiles>

</settings>

一切正常,直到我开始在干净的机器上构建东西(即我没有构建任何SNAPSHOT项目的东西)并且它不会下载所需的SNAPSHOT依赖项。 Maven给了我以下内容:

[INFO] Scanning for projects...
[INFO]       
[INFO] ------------------------------------------------------------------------
[INFO] Building MyCo Actions Base Classes 1.0.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/maven-metadata.xml
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/testing-1.0.0-SNAPSHOT.pom
[WARNING] The POM for com.myco:testing:jar:1.0.0-SNAPSHOT is missing, no dependency information available
Downloading: http://my-sever/nexus/content/groups/public/com/myco/testing/1.0.0-SNAPSHOT/testing-1.0.0-SNAPSHOT.jar
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.023s
[INFO] Finished at: Tue Mar 08 15:55:23 GMT 2011
[INFO] Final Memory: 99M/480M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal on project actions-base: Could not resolve dependencies for project com.myco:actions-base:jar:1.0.0-SNAPSHOT: Could not find artifact com.myco:testing:jar:1.0.0-SNAPSHOT in nexus (http://my-sever/nexus/content/groups/public) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/DependencyResolutionException

问题是testing-1.0.0-SNAPSHOT.jar不存在,但是测试-1.0.0-20110301.182820-1.jar确实存在。如何让Nexus正确解析SNAPSHOT并为我服务JAR ......?

4 个答案:

答案 0 :(得分:9)

我最终得到了所有工作,我从公共组删除本地版本和快照存储库并制作镜像,只镜像公共组而不是一切。所以我的settings.xml最终包含:

  <profiles>
    <profile>
      <id>nexus</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <repositories>
        <repository>
          <id>maven-releases</id>
          <url>http://myhost.com/nexus/content/repositories/releases</url>
          <layout>default</layout>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>maven-snapshots</id>
          <url>http://myhost.com/nexus/content/repositories/snapshots</url>
          <layout>default</layout>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>        
        <repository>
          <id>madeUp</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>madeUp</id>
          <url>http://central</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>

  <mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>madeUp</mirrorOf>
      <url>http://myhost.com/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

答案 1 :(得分:6)

配置nexus作为镜像时,同样的问题。将所有存储库(发布和快照)添加到公共存储库组后,您可以通过浏览相应的URL找到所有快照:

Configure nexus Browser public group

但是maven无论如何都会失败从镜像中获取快照,如本主题所述。它接缝maven不会从镜像中检索快照,直到你明确告诉它这样做。作为一个解决方案,我添加了与存储库 -Tag相同的URL,它只是按预期工作:

<settings>

<mirrors>
    <mirror>
        <id>nexus-mirror</id>
        <name>Nexus Mirror</name>
        <url>http://my-server/nexus/content/groups/public/</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
</mirrors>

<profiles>
    <profile>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>nexus-public</id>
                <name>Nexus Public Repository</name>
                <url>http://my-server/nexus/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </repository>
        </repositories>
    </profile>
</profiles>

</settings>

即使将 updatePolicy -Tag设置为整个镜像也不会有任何问题。由于maven足够聪明,只能更新每个版本中的快照,而不是版本。

答案 2 :(得分:1)

我也尝试了这个但它失败了。问题here有第二个描述。可能是Nexus公共回购正在干扰事情。

我最终在settings.xml中添加了第二个存储库,更直接地指向我们的本地快照存储库。

<repository>
   <id>ummsSnaps</id>
      <url>https://team/nexus/content/repositories/snapshots</url>
      <snapshots>
         <enabled>true</enabled>
      </snapshots>
</repository>

它有效。

答案 3 :(得分:0)

检查您的快照存储库是否已添加到公共组。看起来你已经正确配置了settings.xml,因此它必须只是/ public不包含你的快照仓库。