英文:
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-plugin to execute twice times in your build. You have to configure a classifier for at least one 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~
英文:
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~
答案1
得分: 2
自3.3.0
版本开始,当命令行中给定了与jar-no-fork
目标绑定的maven-sources-plugin
的多个生命周期阶段时,重复检查也会导致构建失败。例如:
# mvn package install
# mvn install deploy
解决方法是简单地避免不必要的生命周期阶段:
# mvn install
# mvn deploy
然而,我认为升级到maven-sources-plugin
3.3.0版本可能会导致相当多的构建问题。
英文:
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.
答案2
得分: 1
在从3.2.1
升级到3.3.0
后遇到了相同的问题。
在将goal
从jar
更改为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>
英文:
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>
答案3
得分: -2
如果你在pom配置中遇到困难并需要解决方法,你可以通过在mvn命令中使用**'-Dmaven.source.skip'**参数来跳过maven-source-plugin(这将阻止部署'artifact-sources.jar')。
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-source-plugin
可用参数:
skipSource (默认: false)
用户属性: maven.source.skip
用于禁用源码过程的标志。
这主要用于从命令行偶尔调整构建。
对于版本为'maven-source-plugin' 2.4及以下的版本,应该使用'-Dsource.skip'。
对于版本3.0.0及更高版本,请改用'-Dmaven.source.skip'。
英文:
If you're encountering difficulties with your pom configuration and need a workaround, you can skip the maven-source-plugin (this will prevent 'artifact-sources.jar' deployment) by utilizing the '-Dmaven.source.skip' parameter in your mvn command.
mvn help:describe -Dplugin=org.apache.maven.plugins:maven-source-plugin
>Available parameters:
<br>skipSource (Default: false)</br>
<br>User property: maven.source.skip</br>
A flag used to disable the source procedure. <br>This is primarily intended
for usage from the command line to occasionally adjust the build.
For versions of the 'maven-source-plugin' up to 2.4, you should use '-Dsource.skip'.<br>For version 3.0.0 and later, employ '-Dmaven.source.skip' instead.</br>
答案4
得分: -3
我昨天遇到了同样的问题,我通过在我的pom.xml中添加以下内容解决了这个问题:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
</plugin>
英文:
I had the same problem yesterday and I solved adding this in my pom.xml:
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
</dependency>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.2.1</version>
</plugin>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论