如果属性是在根 POM 文件的依赖项部分中声明的,我需要使用 maven 版本仅更新属性部分中的版本的帮助。如果依赖项仅在子模块中声明,则不会替换该属性。我在 POM 的配置部分添加了我想要替换的属性:(fake-libary-version,report-generation-service-version)。
我不希望替换任何其他版本,例如在 3rd 方 lib 示例下声明的任何属性:(versions-maven-plugin-version)。
report-generation-service-version:24.0.0-SNAPSHOT 替换为 Nexus 中的发布版本:24.0.0
fake-libary-version: 3.0.0-SNAPSHOT 应该替换为 Nexus: 3.0.0 中的发布版本,但事实并非如此。
我错过了什么?任何帮助将不胜感激!
在我正在执行的终端:
mvn 版本:更新属性 -DallowSnapshots=false
这是我的根 POM 的内容:
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<bxp.security.version>3.18</bxp.security.version>
**<!-- SNAPSHOT I WANT TO BE REPLACED -->**
<fake-libary-version>3.0.0-SNAPSHOT</fake-libary-version>
<report-generation-service-version>24.0.0-SNAPSHOT</report-generation-service-version>
**<!-- I do not want anything replaced here - 3rd party lib -->**
<versions-maven-plugin-version>2.8.1</versions-maven-plugin-version>
<jackson-databind-version>2.9.4</jackson-databind-version>
<javax.ws.rs-api-version>2.1.1</javax.ws.rs-api-version>
<lombok-version>1.18.2</lombok-version>
<junit-version>4.12</junit-version>
<mockito-core-version>2.21.0</mockito-core-version>
<json-path-version>2.4.0</json-path-version>
<hamcrest-all-version>1.3</hamcrest-all-version>
<json-version>20160212</json-version>
<spring-boot-version>2.0.8.RELEASE</spring-boot-version>
<spring-version>5.0.12.RELEASE</spring-version>
<swagger-jersey2-jaxrs-version>1.5.21</swagger-jersey2-jaxrs-version>
<reflections-version>0.9.10</reflections-version>
<aspect-version>1.9.2</aspect-version>
<maven-compiler-plugin-version>3.3</maven-compiler-plugin-version>
</properties>
<parent>
<groupId>test</groupId>
<artifactId>parent</artifactId>
<version>1.1.9</version>
</parent>
<groupId>wmr.com.test.cicd-sandbox-java-svc</groupId>
<artifactId>cicd-sandbox-java-services</artifactId>
<version>18.0.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>dummy-main-app</module>
</modules>
<dependencies>
<dependency>
<groupId>wmr.com.test.report-generation-service</groupId>
<artifactId>report-generation-service-version-app</artifactId>
<version>${report-generation-service-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin-version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>${versions-maven-plugin-version}</version>
<configuration>
<excludes>
<exclude>org.apache.commons:commons-collections4</exclude>
</excludes>
<includes>
<include>wmr.test.report-generation-service:*</include>
<include>wmr.test.cicd-sandbox-java-lib:*</include>
</includes>
<properties>
<property>
<name>fake-libary-version</name>
<name>report-generation-service-version</name>
</property>
</properties>
</configuration>
</plugin>
</plugins>
</build>
<scm>
<url>https://gitlab.test.net/wmr/wmr-00/cicd-sandbox-java-svc</url>
<connection>scm:https://gitlab.test.net/wmr/wmr-00/cicd-sandbox-java-svc.git</connection>
<developerConnection>scm:git:https://gitlab.test.net/wmr/wmr-00/cicd-sandbox-java-svc.git
</developerConnection>
<tag>cicd-sandbox-java-services-9.0.0</tag>
</scm>
</project>
这是我的 dummy-main-app POM 的内容:
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/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<artifactId>cicd-sandbox-java-services</artifactId>
<groupId>wmr.com.test.cicd-sandbox-java-svc</groupId>
<version>18.0.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>dummy-main-app</artifactId>
<version>18.0.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>wmr.com.test.cicd-sandbox-java-lib</groupId>
<artifactId>fake-libary</artifactId>
<version>${fake-libary-version}</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok-version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin-version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot-version}</version>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>