在以下情况下,对于多项目,版本控制和发布管理的最佳实践是什么?
我只想为父项目和所有子项目设置一次版本,因为项目的每个部分都必须具有相同的版本。
我还想要的是,用continuum / maven释放项目。
通常,一种简单的方法应该是在父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>
儿童
<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>
如果要立即使用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>
儿童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>
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>
如果您尝试使用dependencyManagement时,模块之间的依赖关系将永远不必定义任何版本,因为它们是在父pom中定义的。
通过这种方法发布多模块项目从来没有任何问题。
编辑
需要明确的是:dependencyManagement
与父子之间的继承无关。它解决了子模块之间的依赖版本问题。它在发行期间有效。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句