Ren*_*get 8 java dependencies release continuum maven
在以下情况下,对于多项目,版本控制和发布管理的最佳实践是什么?
我只想为父项目和所有子项目设置一次版本,因为项目的每个部分必须具有相同的版本.
我想要的是,用continuum/maven发布项目.
Normaly一个简单的方法应该是在父pom中设置版本并在每个孩子中说"父母的最后一个版本",但这不适用于maven <3.1(见这里)[http://jira.codehaus.org/browse/ MNG-624]现在我在每个子项目中设置父项目的版本,并且对于每个版本,我必须更改所有子项和父项的版本.
例:
亲
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
Run Code Online (Sandbox Code Playgroud)
儿童
<parent>
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<groupId>com.test</groupId>
<artifactId>com.test.project</artifactId>
<version>${parent.version}</version>
Run Code Online (Sandbox Code Playgroud)
如果我想现在使用Continuum发布我的项目,我使用以下顺序来释放它:
但这不起作用,因为在更改父版本之后,孩子们在父母中不再有SNAPSHOT版本,我认为必须有更好的方法来发布连续体的多项目.
如果您在标签中添加子模块,<dependencyManagement/>我确信您不会遇到这个问题。
家长
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>child1</module>
<module>child2</module>
</modules>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>com.test.child1</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.test</groupId>
<artifactId>com.test.child2</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
Run Code Online (Sandbox Code Playgroud)
儿童1
<parent>
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<!-- groupId and version can be skipped since it will be inherited from parent -->
<artifactId>com.test.child1</artifactId>
Run Code Online (Sandbox Code Playgroud)
Child2(取决于 Child1)
<parent>
<groupId>com.test</groupId>
<artifactId>com.test.buildDefinition</artifactId>
<version>1.0-SNAPSHOT</version>
</parent>
<!-- groupId and version can be skipped since it will be inherited from parent -->
<artifactId>com.test.child2</artifactId>
<dependencies>
<dependency>
<groupId>com.test</groupId>
<artifactId>com.test.child1</artifactId>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
如果您尝试在使用 dependencyManagement 时,模块之间的依赖关系将永远不必定义任何版本,因为它们是在父 pom.xml 中定义的。
通过这种方法发布多模块项目我从未遇到过任何问题。
编辑
需要明确的是:dependencyManagement与父子之间的继承没有任何关系。它解决了子模块之间依赖版本的任何问题。它在发布期间有效。