2

I managed to build a Maven project in a way that makes the release deploy artifacts either double or not at all.

Since the project uses an abstract parent pom of our company it's a bit hard to post the relevant code, but I'll try.

First things first. The parent pom has the following definition:

  <plugin>
    <artifactId>maven-deploy-plugin</artifactId>
    <version>2.8.2</version>
    <configuration>
      <deployAtEnd>true</deployAtEnd>
    </configuration>
  </plugin>

With nothing defined in the actual project, the release will fail after these lines:

[INFO] [INFO] Uploaded to our_repo: http://acme.org/nexus/content/repositories/org.acme.project/1.0.0/org.acme.project-1.0.0-sources.jar (14 kB at 3.8 kB/s)
[INFO] [INFO] Uploading to our_repo: http://acme.org/nexus/content/repositories/org.acme.project/1.0.0/org.acme.project-1.0.0-sources.jar

Our repo doesn't like having two release JARs with the same version, so everything fails. The weird part here is that the deployment is NOT at the end. In fact the project build fails halfway through.

However if I copy the above plug-in in the project, the build will print Deploying repo:org.acme.repo:1.0.0 at end at the same position and then not deploy anothing at the end.

But I'm not even sure that's part of the problem. Still I think both builds should work exactly the same no matter where the plug-in definition is.

I found this question, which made me check the maven-source-plugin in the effective pom. However there are no duplicates there:

    <plugin>
      <artifactId>maven-source-plugin</artifactId>
      <version>3.0.1</version>
      <executions>
        <execution>
          <id>attach-sources</id>
          <goals>
            <goal>jar-no-fork</goal>
          </goals>
          <configuration>...</configuration>
        </execution>
      </executions>
    </plugin>

Nothing is defined in the maven-assembly-plugin either, so no JAR is added for deployment (suggested in this question).

It might have to do with us using Java 10 or Maven 3.5.2, though I'm honestly stumped on what to test and where to progress.

How do I fix this mess? (If you'd like more information about the build, just ask. The pom.xml is way to big to share them here.)

Stefan S.
  • 3,950
  • 5
  • 25
  • 77
  • Duplicate definition of one plugin like maven-source-plugin etc. BTW: How is maven called exactly to do the release ? – khmarbaise Jul 17 '18 at 06:55
  • Is this a multi-module build? If not then `deployAtEnd` may behave strangely, especially since it is also documented as "experimental" – Steve C Jul 17 '18 at 06:59
  • @khmarbaise The release is executed via `release:prepare release:perform -P document,parallel` (I think at least the last profile is our doing for executing the tests in parallel). – Stefan S. Jul 17 '18 at 07:33
  • @SteveC Yes, it's multi-module. Else `deployAtEnd` wouldn't be that useful either way. – Stefan S. Jul 17 '18 at 07:34
  • @SteffiS. Why do you use special profiles during the release? Apart from that I would take a look on the full log file during the build (making the release) I bet there is a duplicate execution of a plugin like maven-source-plugin which can cause the issue...You should check the effective pom with activated release profile like `mvn help:effective-pom -Doutput=result.out -Prelease-profile` and recheck the content. I bet there is a duplicate for maven-source-plugin.... – khmarbaise Jul 17 '18 at 08:28
  • 1
    @SteveC The `deployAtEnd` is always useful cause it prevents uploading failures to a repository in case of tests/build is failing...only a complete successful build will be uploaded at the end...The only thing is if you have a non java/javaee build things like a tycho build or so this could mean you can't use `deployAtEnd`/`installAtEnd` things... – khmarbaise Jul 17 '18 at 08:33
  • There is a BUG in maven.Please upvote if you have been affected: https://issues.apache.org/jira/browse/MDEPLOY-254 – borjab Apr 16 '20 at 11:48

1 Answers1

2

Inspired by that question I tried to disable the release profile, and now it works somehow. I'm not able to conjure any kind of explanation for that behavior.

Snippet for removing the release profile:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-release-plugin</artifactId>
            <configuration>
                <useReleaseProfile>false</useReleaseProfile>
            </configuration>
        </plugin>
Stefan S.
  • 3,950
  • 5
  • 25
  • 77