【发布时间】:2017-04-26 11:20:19
【问题描述】:
最近我们尝试使用 jenkins 部署文件,为构建提供 ${revision} 属性(Maven 3.3.9)。
它在 json 上为开发构建创建 0.0.1-SNAPSHOT 和为发布创建 0.0.1-RC 工作正常,但我们在开发人员机器上使用 maven 时遇到问题。
我们有多模块 maven 项目,其版本在父项中定义,一些模块使用其他模块作为依赖项。两者都从 jenkins 构建并在本地使用 maven,以与 IDE 集成并在将其推送到存储库之前运行测试。
当我们尝试构建单个模块时,maven 无法识别${revision},尽管当我们提到所有模块时它工作正常,例如mvn clean install -pl appserver,我们看到了
Failed to execute goal on project appserver: Could not resolve dependencies for project com.org:appserver:war:0.0.1-local: Failed to collect dependencies at com.org:my-kinesis-events:jar:0.0.1-local: Failed to read artifact descriptor for com.org:my-kinesis-events:jar:0.0.1-local: Could not transfer artifact com.org:my-parent:pom:${revision} from/to central: Failed to transfer .../repository/maven-central/com/org/my-parent/${revision}/my-parent-${revision}.pom. Error code 500, Server Error -> [Help 1]
我们尝试使用:
-Drevision=0.0.1-local<profile> <id>default-version</id> <activation> <property> <name>!revision</name> </property> <activeByDefault>true</activeByDefault> </activation> <properties> <revision>0.0.1-local</revision> <project.version>0.0.1-local</project.version> </properties> </profile>
但唯一有效的是构建模块及其依赖的所有模块的父级构建:
mvn clean install -pl appserver,my-kinesis-events,module1,module2,...
尽管上述工作需要团队在 IDE 中定义自定义运行配置,但每次他们需要一些东西时。
是否有人也遇到过这个问题并找到了解决方案?
父 pom sn-p:
<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 @987654321@">
<modelVersion>4.0.0</modelVersion>
<groupId>com.org</groupId>
<artifactId>my-parent</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>
<name>My Parent module</name>
<modules>
<module>../my-tools</module>
<module>my-kinesis-events</module>
....
</modules>
.....
</project>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>my.org</groupId>
<artifactId>my-kinesis-events<</artifactId>
<version>${project.version}</version>
<dependency>
<dependencies>
</dependencyManagement>
模块 pom sn-p:
<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 @987654322@">
<modelVersion>4.0.0</modelVersion>
<artifactId>appServer</artifactId>
<parent>
<groupId>com.org</groupId>
<artifactId>my-dsp</artifactId>
<version>${revision}</version>
<relativePath>..</relativePath>
</parent>
<packaging>war</packaging>
<name>AppServerAPI</name>
<description>Application Server</description>
<dependencies>
<dependency>
<groupId>com.org</groupId>
<artifactId>my-openrtb</artifactId>
</dependency>
.....
</dependencies>
....
</project>
【问题讨论】:
-
谢谢。这产生了另外三个问题。首先,我可以在哪里找到 maven 3.4.0(maven.apache.org/docs/history.html 声明 3.3.9 是最新的)。二、MNG-690计划什么时候解决?第三,在解决之前是否存在任何解决方法?
-
Maven 3.4.0 is not released yet...除此之外 Maven 是一个开源项目,所以没有计划什么时候会解决...不幸的是目前没有解决方法...
标签: java maven jenkins multi-module