Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven build fails after upgrading to maven-source-plugin from 3.2.1 to 3.3.0

I recently upgraded the maven-source-plugin version in my project from 3.2.1 to 3.3.0 and now I am encountering the following error during the build process:

Failed to execute goal org.apache.maven.plugins:maven-source-plugin:3.3.0:jar (attach-sources) on project xxx: Presumably you have configured maven-source-plugn to execute twice times in your build. You have to configure a classifier for at least on of them. -> [Help 1]

It seems that this error is related to the fact that the maven-source-plugin has changed its behavior in version 3.3.0 to prevent the attach-sources goal from being executed multiple times during the build. However, I can't find any doc or release note related to this feature that may cause this incompatibility problem.

I want to know where I can find the official documentation and what the purpose of this new feature is? Thanks~

like image 684
HHHHNNNNNNIIIII Avatar asked Sep 13 '25 00:09

HHHHNNNNNNIIIII


2 Answers

Since 3.3.0 the duplicate check will also fails build when multiple lifecycle phase which are bound to the jar-no-fork goal of the sources plugin are given on the command line. For example

# mvn package install
# mvn install deploy

The solution is to simply avoid the unnecessary lifecycle phase:

# mvn install
# mvn deploy

However, upgrading to maven-sources-plugin 3.3.0 will break quite a number of build I presume.

like image 97
user3670285 Avatar answered Sep 15 '25 13:09

user3670285


Had the same issue after upgrading from 3.2.1 to 3.3.0.

The error was resolved after changing the goal from jar to jar-no-fork:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-source-plugin</artifactId>
    <version>3.3.0</version>
    <executions>
        <execution>
            <id>attach-sources</id>
            <goals>
                <goal>jar-no-fork</goal>
            </goals>
        </execution>
    </executions>
</plugin>
like image 42
armandino Avatar answered Sep 15 '25 14:09

armandino