3

I have a pom which gets some zip, unpacks and deploys the 5 artifacts (jar + pom) that are inside.

It looks something like:

 <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <executions>
                    <execution>
                        <id>default-deploy</id>
                        <phase>none</phase>
                    </execution>
                    <execution>
                        <id>deploy-api-jar</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy-file</goal>
                        </goals>
                        <configuration>
                            <file>target/xxx.jar</file>
                            <pomFile>target/xxx/pom.xml</pomFile>
                            <sources>target/xxx-sources.jar</sources>
                            <repositoryId>${nexus-repository-id}</repositoryId>
                            <url>http://${nexus.deploy.server}/${nexus-repository-path}</url>
                        </configuration>
                    </execution>

So I have 5 executions for 5 different artifacts.

It works for the first artifact but then it fails because it tries to upload this again:

[INFO] Uploading: http://www.zzz.com:8081/nexus/content/repositories/mobile-r/xxx/server/deployall/8.1.17/deployall-8.1.17-dependencies.dot

And it fails with 400 BadRequest because depedencies.dot 8.1.17 is already deployed.

Why does it try and upload the depedencies.dot between each artifact? can I disable it?

Lii
  • 11,553
  • 8
  • 64
  • 88
orepor
  • 905
  • 2
  • 13
  • 23

1 Answers1

4

Edit: answer missed the point

It fails because Maven and thus your nexus only allows one artifact for a given set of coordinates.

So, if you want to deploy them all to the same coordinates, you need to give them different classifiers.

What you want to do is a highly irregular use of a build script. Maven assumes that all artifacts from a single POM have the same coordinates (but different classifiers). If you want that, you can attach the artifacts to the project and upload them using the normal deploy:deploytask in the lifecycle. You can use the build-helper-maven-plugin for that:

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <version>1.12</version>
  <executions>
    <execution>
      <id>attach-artifacts</id>
      <phase>package</phase>
      <goals>
        <goal>attach-artifact</goal>
      </goals>
      <configuration>
        <artifacts>
          <artifact>
            <file>file1</file>
            <type>extension of your file</type>
            <classifier>x</classifier>
          </artifact>
          <artifact>
            <file>file2</file>
            <type>extension of your file</type>
            <classifier>y</classifier>
          </artifact>
          ...
          </artifacts>
        </configuration>
      </execution>
    </executions>
  </plugin>

But since you want to upload 5 disjunct artifacts, a POM is not what you want, use a bash script for the upload instead (calling mvn deploy:deploy-file multiple times).

blackbuild
  • 5,026
  • 1
  • 23
  • 35
  • coordinates you mean groupId:artifactId ? But they don't share the same coordinates, they are 5 different artifacts. I got it to work by calling a bash script which does the same, deploy-file. You don't recommend this solution? – orepor Nov 07 '16 at 16:54
  • Ok, I missed the part using different POMs for the different files. In that case, the bash file is actually the cleanest solution (last paragraph of my answer). You don't have an actual project, so simply upload them. As to why this is happening, the comment of JF Meier to your question points to the correct explaination. – blackbuild Nov 07 '16 at 17:02