【问题标题】:Maven: upload and download zip file to nexus repositoryMaven:上传和下载 zip 文件到 nexus 存储库
【发布时间】:2017-05-19 11:43:46
【问题描述】:

我已使用 pom 将 zip 文件上传到本地 nexus 存储库。它似乎已正确上传。然后我尝试使用以下方式将其下载到另一个项目中:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.foo</groupId>

  <artifactId>projectusingofficestuff</artifactId>
  <version>1.0.0-SNAPSHOT</version>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-dependency</id>
            <phase>compile</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>com.foo</groupId>
                  <artifactId>officestuff</artifactId>
                  <type>zip</type>
                  <version>1.0.0-RELEASE</version>
                  <overWrite>true</overWrite>
                  <outputDirectory>target/unpacked</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

当我尝试下载时,我得到:

[DEBUG]   (s) remoteRepos = [       id: nexus
      url: http://repository/nexus/repository/maven-public
   layout: default
snapshots: [enabled => false, update => daily]
 releases: [enabled => true, update => daily]
]
[DEBUG]   (f) silent = false
[DEBUG] -- end configuration --
[INFO] Configured Artifact: com.foo:officestuff:1.0.0-RELEASE:zip
[DEBUG] Using connector WagonRepositoryConnector with priority 0 for http://repository/nexus/repository/maven-public as mike
Downloading: http://repository/nexus/repository/maven-public/com/foo/officestuff/1.0.0-RELEASE/officestuff-1.0.0-RELEASE.zip
[DEBUG] Writing resolution tracking file /home/mike/.m2/repository/com/foo/officestuff/1.0.0-RELEASE/officestuff-1.0.0-RELEASE.zip.lastUpdated
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.763s
[INFO] Finished at: Wed Jan 04 16:13:20 EST 2017
[INFO] Final Memory: 20M/962M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-dependency-plugin:2.1:unpack (copy-dependency) on project projectusingofficestuff: Unable to find artifact. Could not find artifact com.foo:officestuff:zip:1.0.0-RELEASE in nexus (http://repository/nexus/repository/maven-public)

如果我直接使用以下方法搜索存储库: http://repository/nexus/repository/maven-public/com/foo/officestuff/1.0.0-RELEASE/officestuff-1.0.0-RELEASE.zip?describe

它找到工件并返回看似正确的响应。知道为什么 Maven 构建会找不到它吗?

【问题讨论】:

  • 您能否尝试在您的项目目录中执行mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.0:unpack,以防万一检查旧版本是否有任何错误,或者您可能将其绑定到不正确的阶段。
  • 首先我怀疑1.0.0-RELEASE 的版本是否正确。通常发布版本如下所示:1.0.0。此外,您似乎通过 pluginManagement 定义插件版本,因为您似乎使用的是非常旧版本的 maven-dependency-plugin...

标签: maven nexus


【解决方案1】:

感谢您的帮助;我似乎有它的工作。我在另一个我最初没有看到的 stackoverflow 问题中找到了答案的线索

Maven - Depend on assembled zip

在上传时,程序集文件名(在我的例子中是 bin.xml)被附加到工件名称中。要下载找到工件,我需要添加&lt;classifier&gt;bin&lt;/classifier&gt; 到工件的依赖块。

【讨论】:

    猜你喜欢
    • 2017-06-16
    • 1970-01-01
    • 1970-01-01
    • 2018-01-12
    • 2021-02-27
    • 2019-01-14
    • 1970-01-01
    • 2021-10-22
    • 2014-04-13
    相关资源
    最近更新 更多