[英]gradle doesn't resolve placeholder from parent properties in dependency version that is inside library that I specified in build.gradle
I have one interesting question about resolving dependencies versions by gradle.我有一个关于通过 gradle 解决依赖版本的有趣问题。 Here is my situation.这是我的情况。 I deployed my libraries to nexus.我将我的库部署到了 nexus。 In this process I used the flatten-maven-plugin and resolveCiFriendliesOnly flattenMode.在这个过程中,我使用了 flatten-maven-plugin 和 resolveCiFriendliesOnly flattenMode。 As result I have parent pom file and child pom files in nexus.结果我在nexus中有父pom文件和子pom文件。
parent pom file from source:来自源的父 pom 文件:
<groupId>ru.example</groupId>
<artifactId>example-parent</artifactId>
<version>${revision}${changelist}</version>
<packaging>pom</packaging>
<properties>
<revision>0.0.1</revision>
<changelist>-SNAPSHOT</changelist>
<version.base>${revision}${changelist}</version.base>
<example-child.version>${version.base}</example-child.version>
<example-child-dependency.version>${version.base}</example-child-dependency.version>
</properties>
child pom file from source来自源的子 pom 文件
<parent>
<groupId>ru.example</groupId>
<artifactId>example-parent</artifactId>
<version>${revision}${changelist}</version>
<relativePath>..</relativePath>
</parent>
<artifactId>example-child</artifactId>
<version>${example-child.version}</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>ru.example</groupId>
<artifactId>example-child-dependency</artifactId>
<version>${example-child-dependency.version}</version>
</dependency>
</dependencies>
parent pom file from nexus来自nexus的父pom文件
<groupId>ru.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<properties>
<version.base>0.0.1-SNAPSHOT</version.base>
<revision>0.0.1</revision>
<changelist>-SNAPSHOT</changelist>
<example-child.version>${version.base}</example-child.version>
<example-child-dependency.version>${version.base}</example-child-dependency.version>
<properties>
child pom file from nexus来自nexus的子pom文件
<parent>
<groupId>ru.example</groupId>
<artifactId>example-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>..</relativePath>
</parent>
<groupId>ru.example</groupId>
<artifactId>example-child</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>ru.example</groupId>
<artifactId>example-child-dependency</artifactId>
<version>${example-child-dependency.version}</version>
</dependency>
</dependencies>
After that I try to build java application with gradle.之后,我尝试使用 gradle 构建 java 应用程序。 In build.gradle file of this application I have such line:在此应用程序的 build.gradle 文件中,我有这样的行:
dependencies {
implementation("ru.example:example-child:0.0.1-SNAPSHOT")
}
And build fails with error:并且构建失败并出现错误:
> Task :java_application:compileJava
Resolving global dependency management for project 'java_application'
Errors occurred while build effective model from /u01/jenkins_slave/.gradle/caches/modules-
2/files-2.1/ru.example/example-child/0.0.1-
SNAPSHOT/809129e53f76bfb7b6a141e9aeb8ffb1a692e76c/example-child-0.0.1-SNAPSHOT.pom:
'dependencies.dependency.version' for ru.example:example-child-dependency:jar must be a
valid version but is '${example-child-dependency.version}'. in ru.example:example-
child:0.0.1-SNAPSHOT
Why gradle doesn't resolve placeholder of child project dependency?为什么 gradle 不能解析子项目依赖的占位符?
gradle
appearently does not evaluate ${example-child-dependency.version}
and you might have to build with mvn
in order to produce consumable/static *.pom
for gradle
. gradle
似乎没有评估${example-child-dependency.version}
并且您可能必须使用mvn
构建才能为 gradle 生成消耗品/静态*.pom
gradle
。 I mean, most likely mvn
would evaluate *.pom
, while gradle
doesn't.我的意思是,很可能mvn
会评估*.pom
,而gradle
不会。
And that might rather be:那可能是:
<artifactId>example-child-dependency</artifactId>
<version>${version.base}</version>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.