我有一个多模块 Maven 项目,例如
A B C D E 目前这个项目运行良好,只有一个工作来构建所有模块并上传到工件,例如 4.0.0-。他们正在使用版本:set -DnewVersion=4.0.0-${BUILD_NUMBER} Jenkins 工作。现在我的下一个任务是将这个项目拆分为模块,以便他们的开发团队可以独立构建每个模块,但我的问题是某些模块依赖于其他模块,例如
模块 B 依赖于模块 A 和模块 C。如果我先构建模块 A,然后它生成数字 4.0.0-00001 并将其上传到工件,然后我构建模块 C,然后它生成构建 4.0.0 -00005。现在问题来了,我如何构建依赖于模块 A 和 C 的模块 B。我认为我需要在依赖部分明确定义模块 A 和 C 的版本。
<dependency>
<groupId>com.xyz.engine</groupId>
<artifactId>A</artifactId>
<version>4.0.0-00005</version>
</dependency>
从我的模块 POM 我调用我的父 POM 并且在 jenkins 工作中我给出版本:set -DnewVersion=4.0.0-${BUILD_NUMBER} 用于版本控制,如果我明确定义 A 模块的版本,那么它也传递相同父 POM 的值并搜索它是不可用的。下面是我的模块 POM 文件
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.truvenhealth.analyticsengine</groupId>
<artifactId>AnalyticsEngine</artifactId>
<version>4.0.0-00002</version>
</parent>
<artifactId>LicenseVerifier</artifactId>
<name>LicenseVerifier</name>
<packaging>jar</packaging>
<dependencies>
<!-- Modules dependencies -->
<dependency>
<groupId>com.xyz.engine</groupId>
<artifactId>Common</artifactId>
<version>4.0.0-00007</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
</dependency>
<!-- External dependencies -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjtools</artifactId>
<version>1.6.2</version>
</dependency>
<dependency>
<groupId>com.verhas</groupId>
<artifactId>license3j</artifactId>
<version>1.0.4</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<!-- Plugin configurations inherited from the parent POM -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
它为我分配给公共模块的父 POM 采用相同的值。我将父 POM 保存在单独的存储库中它不应该采用相同的值它应该只采用我为父 POM 定义的值并且它应该下载它来自他们并向模块 POM 提供所有值,并且应该为具有不同版本的模块 LicenseVerifier 创建构建。