This is a minimal, reproducible example of a bug related to certain usages of the maven-sources-plugin which is tracked by several JIRA issues:
Basically if your build fails with the following message:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-source-plugin:3.3.0:jar-no-fork (attach-sources) on project source-plugin-breaks-releases: 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]
Then you have hit some variant of this bug.
This repository particularly focuses on reproducing the bug when trying to perform a Maven release.
Just clone the code then try the following:
$ mvn release:perform
This particular instance of the bug is caused be the interaction of two things:
- The new duplicate invocation check within the
maven-source-plugin
that was added as of their3.3.0
release - The
maven-release-plugin
's usage of the implicit release profile that includes an extra invocation of themaven-source-plugin
that leads to the duplicate invocation check failing
There are some known workarounds at this time:
- Rollback to using
maven-source-plugin
versions prior to3.3.0
e.g.3.2.1
was the last release without the duplicate invocation check present - Explicitly use a
maven-release-plugin
release that is3.0.0
or higher. As of their 3.x releases they don't enable the implicit release profile by default so you won't get the extramaven-source-plugin
invocation added and hit the bug. You can do this as follows in the<pluginManagement>
section of yourpom.xml
as follows:If you need to configure the plugin in any way then extend that with whatever configuration is appropriate.<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-release-plugin</artifactId> <version>3.0.1</version> </plugin>