Maven是3.1.0。
我在我的项目的pom.xml中使用版本-maven-plugin:2.2(如下所示)。除了通常的pom.xml文件配置之外,我只显示下面的主要代码快照:
<project
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>tools-parent</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
Infrastructure related to the "vapp" and
"deployer" utilities.
</description>
<parent>
<groupId>com.company.product</groupId>
<artifactId>deploy-parent</artifactId>
<version>0.0.6-SNAPSHOT</version>
</parent>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-scm-plugin</artifactId>
<version>1.9.4</version>
<configuration>
<connectionType>connection</connectionType>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<!-- Make sure that only non-snapshot versions are used for the dependencies. Only active when property 'snapshotDependencyAllowed' is false. -->
<id>enforce-no-snapshots</id>
<goals>
<goal>enforce</goal>
</goals>
<configuration>
<skip>${snapshotDependencyAllowed}</skip>
<rules>
<requireReleaseDeps>
<message>No Snapshots Allowed!</message>
</requireReleaseDeps>
<requireReleaseVersion>
<message>No Snapshots Allowed!</message>
</requireReleaseVersion>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>现在,当我运行: mvn干净安装时,它成功地构建了。
注意到:在我的项目中,我有一个父部分,其中我依赖于部署--父构件的组id "com.company.product“与我想要的工具相同--父构件(它的pom.xml已粘贴在上面),但是部署--父构件是另一个存储库/项目的工件。
当我运行:mvn版本:set -DnewVersion=0.0.7时,我得到以下错误消息。
[INFO] ------------------------------------------------------------------------
[INFO] Building tools-parent 0.0.7-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- versions-maven-plugin:2.2:set (default-cli) @ tools-parent ---
[INFO] Searching for local aggregator root...
[INFO] Local aggregation root: /user/home/u100123/giga/tools
[INFO] Processing change of com.company.product:tools-parent:0.0.7-SNAPSHOT -> 0.0.7
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] tools-parent .................................... FAILURE [1.093s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.404s
[INFO] Finished at: Fri May 01 20:44:22 GMT-00:00 2015
[INFO] Final Memory: 12M/246M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:versions-maven-plugin:2.2:set (default-cli) on project tools-parent: Execution default-cli of goal org.codehaus.mojo:versions-maven-plugin:2.2:set failed. NullPointerException -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException现在,当我将版本-maven-plugin版本更改回2.1 (我之前使用的版本)时,上面的mvn版本:set -DnewVersion=0.0.7命令正在成功工作,pom.xml文件正在成功地更改为<version>0.0.7</version> for tools-父工件。
在2.2版中,它给出了错误,并且没有将版本更改为0.0.7。
发布于 2015-05-01 21:17:51
好像是什么虫子。
解决方案:
1。我必须在.之外添加<groupId>com.company.product</groupId>属性。对于工具-父级,现在version-maven-plugin:2.2运行得很好,比如我添加了顶部行(如下面所示)。唯一的问题是,父部分的用途是什么(除了继承deploy带来给tools-父项目的主要代码之外)。为什么groupId需要为artifactId工具定义父部分的输出?当它已经在版本的父部分中时-maven-plugin:2.2才能成功地工作。
最重要的事情是:只有当项目/模块的pom.xml有一个<parent>部分时才会发生这个问题,其中父部分的artifactId不是项目本身的父级(典型的- Maven叔叔情景),也就是说,如果在另一个模块的父部分中定义了工具-父构件(让我们说工具-子),那么2.2版本就会成功工作。但是,如果tools-child的父部分没有将artifactId包含为"tools- parent“,并且是其他的示例:部署-父/某些-不同的项目-工件(驻留在源代码管理工具中不同项目中的),那么对于工具-子artifactId,我们也需要在父节之外设置 groupId 值(即使父部分的artifactId的groupId与tools的groupId相同/不同)。
<groupId>com.company.product</groupId>
<artifactId>tools-parent</artifactId>
<version>0.0.7-SNAPSHOT</version>
<packaging>pom</packaging>
<description>
Infrastructure related to the "vapp" and
"deployer" utilities.
</description>
<parent>
<groupId>com.company.product</groupId>
<artifactId>deploy-parent</artifactId>
<version>0.0.6-SNAPSHOT</version>
</parent>-或
2。切换回versions-maven-plugin:2.1
发布于 2015-07-10 01:18:22
为了添加到Arun的答案的第2部分,使用这个插件的2.1版本的方法是:
mvn org.codehaus.mojo:versions-maven-plugin:2.1:set org.codehaus.mojo:versions-maven-plugin:2.1:commit -DnewVersion=0.0.7您必须指定完整的组id和工件id。
发布于 2015-05-01 21:35:15
https://stackoverflow.com/questions/29995139
复制相似问题