2017-01-05 171 views
0

我已经使用pom将zip文件上传到本地nexus存储库。它似乎已正确上传。然后我尝试使用下载它在另一个项目:Maven:上传和下载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构建不能找到它?

+0

你可以尝试在你的项目目录下执行'mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.0:unpack',以防万一检查旧版本是否有bug或者是否绑定它可能是一个错误的阶段。 – nullpointer

+0

首先,我怀疑'1.0.0-RELEASE'版本是否正确。通常发布版本看起来像这样:'1.0.0'。此外,你似乎通过pluginManagement定义你的插件版本,因为你似乎正在使用一个非常老版本的maven-dependency-plugin ... – khmarbaise

回答

0

感谢您的帮助;我似乎有它的工作。我发现线索到另一个计算器问题的答案,我没有看到原本

Maven - Depend on assembled zip

在上传时,大会文件名(bin.xml在我的情况)被追加到该工件名称。为了让下载找到工件,我需要将<classifier>bin</classifier> 添加到工件的依赖块。