两个本地Maven项目和${project.build.version}出现问题
我有一个本地项目:两个本地Maven项目和${project.build.version}出现问题,maven,Maven,我有一个本地项目: -- multi-module-first |-- module-core |-- ... |-- pom.xml |-- module-extra |-- ... |-- pom.xml |-- pom.xml 。。。和本地_项目_2: -- multi-module-second |-- another-module-core |-- ... |-- pom.xml |-- another-module-extra |
-- multi-module-first
|-- module-core
|-- ...
|-- pom.xml
|-- module-extra
|-- ...
|-- pom.xml
|-- pom.xml
。。。和本地_项目_2:
-- multi-module-second
|-- another-module-core
|-- ...
|-- pom.xml
|-- another-module-extra
|-- ...
|-- pom.xml
|-- pom.xml
本地_项目_2与本地_项目_1具有依赖关系
当我在本地项目1上运行mvn install
时,会在项目1的.m2/repository/PACKAGE\u PATH\u中创建以下目录/
-- multi-module-first
|-- 1 (because of <project.build.version>1</project.build.version>)
|-- multi-module-first-1.pom
-- module-core
|-- 1
|-- module-core-1.jar
|-- module-core-1.pom
-- module-extra
|-- 1
|-- module-extra-1.jar
|-- module-extra-1.pom
错误的主要部分无法传输工件项目\u 1\u组:多模块优先:pom:${PROJECT.build.version}
在这一步之后,如果我检查项目1的.m2/repository/PACKAGE\u PATH\u,我会看到创建了目录${PROJECT.build.version}
-- multi-module-first
|-- 1
|-- multi-module-first-1.pom
|-- ${project.build.version}
-- module-core
|-- 1
|-- multi-module-1.jar
|-- multi-module-1.pom
-- module-extra
|-- 1
|-- multi-extra-1.jar
|-- multi-extra-1.pom
如果我检查multi-module-first-1.pom
我会看到
...
<groupId>PROJECT_1_GROUP</groupId>
<artifactId>multi-module-first</artifactId>
<version>${project.build.version}</version>
<packaging>pom</packaging>
<modules>
<module>module-core</module>
<module>module-extras</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.version>1</project.build.version>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
...
。。。
项目组
多模块优先
${project.build.version}
聚甲醛
模芯
额外模块
UTF-8
1.
12
12
...
所以在我看来,Maven不知道它应该使用本地项目1的版本
1
,并且认为它应该使用的版本“number”等于${PROJECT.build.version}
使用${PROJECT.build.version},这样所有模块的版本就只有一个地方(在特定的父pom下)需要更改而不需要以下内容:但问题并不存在,因为您在项目初始设置期间仅手动定义了一次版本,之后您仅通过maven release plugin或version maven plugin进行更改…不再手动…将查看您提供的信息!
...
<groupId>PROJECT_1_GROUP</groupId>
<artifactId>multi-module-first</artifactId>
<version>${project.build.version}</version>
<packaging>pom</packaging>
<modules>
<module>module-core</module>
<module>module-extras</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.build.version>1</project.build.version>
<maven.compiler.source>12</maven.compiler.source>
<maven.compiler.target>12</maven.compiler.target>
</properties>
...