Maven升级到maven-source-plugin 3.3.0后,构建失败。

huangapple go评论133阅读模式
英文:

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后遇到了相同的问题。

在将goaljar更改为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中添加以下内容解决了这个问题:

&lt;dependency&gt;
   &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
   &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
   &lt;version&gt;3.2.1&lt;/version&gt;
&lt;/dependency&gt;

&lt;plugin&gt;
   &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
   &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
   &lt;version&gt;3.2.1&lt;/version&gt;				
&lt;/plugin&gt;
英文:

I had the same problem yesterday and I solved adding this in my pom.xml:

&lt;dependency&gt;
   &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
   &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
   &lt;version&gt;3.2.1&lt;/version&gt;
&lt;/dependency&gt;

&lt;plugin&gt;
   &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt;
   &lt;artifactId&gt;maven-source-plugin&lt;/artifactId&gt;
   &lt;version&gt;3.2.1&lt;/version&gt;				
&lt;/plugin&gt;

huangapple
  • 本文由 发表于 2023年5月22日 19:53:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/76305897.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定