0

I have uploaded a zip file to a local nexus repository using pom. It appears to have uploaded correctly. I then try to download it in another project using:

<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>

When I try the download, I get:

[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)

If I directly search the repository using: http://repository/nexus/repository/maven-public/com/foo/officestuff/1.0.0-RELEASE/officestuff-1.0.0-RELEASE.zip?describe

It finds the artifact and returns what looks like a correct response. Any idea why would the maven build fail to find it?

Naman
  • 27,789
  • 26
  • 218
  • 353
user3825850
  • 43
  • 1
  • 6
  • could you try and execute `mvn org.apache.maven.plugins:maven-dependency-plugin:3.0.0:unpack` at your project directory just in case to check the older version has any bug or if you are binding it to an incorrect phase possibly. – Naman Jan 05 '17 at 04:11
  • First I have my doubts that the version `1.0.0-RELEASE` is correct. usually a release versions looks like this: `1.0.0`. Furthermore you seemed to define your plugin versions via pluginManagement cause you seemed to be using a very old version of maven-dependency-plugin... – khmarbaise Jan 05 '17 at 07:37

1 Answers1

0

Thanks for the help; I appear to have it working. I found clues to the answer in another stackoverflow question I didn't see originally

Maven - Depend on assembled zip

At upload time, the assembly file name (bin.xml in my case) was appended to the artifact name. To get the download to locate the artifact, I needed to add <classifier>bin</classifier> to the dependency block for the artifact.

Community
  • 1
  • 1
user3825850
  • 43
  • 1
  • 6