未按预期评估java Maven属性(osmavenplugin)
我有一个带有模块的父项目。其中一个模块在其pom文件中声明了以下内容:
...
<build>
<extensions>
<extension>
<groupId>kr.motd.maven</groupId>
<artifactId>os-maven-plugin</artifactId>
<version>1.2.3.Final</version>
</extension>
</extensions>
</build>
...
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-tcnative</artifactId>
<version>${netty.tcnative.version}</version>
<classifier>${os.detected.classifier}</classifier>
</dependency>
</dependencies>
...
当从父项目运行mvn package
时,此项目将成功生成。然后,我想在其他一些gradle项目中将此子模块项目用作依赖项,因此我将父项目安装到maven local repo中,并在构建中声明该依赖项。格雷德尔档案
在构建gradle项目时,我遇到以下错误:
Could not resolve all dependencies for configuration ':runtime'.
> Could not find netty-tcnative-${os.detected.classifier}.jar (io.netty:netty-tcnative:1.1.33.Fork2).
Searched in the following locations: https://repo.grails.org/grails/core/io/netty/netty-tcnative/1.1.33.Fork2/netty-tcnative-1.1.33.Fork2-${os.detected.classifier}.jar
为什么${os.detected.classifier}
没有被评估?应该注意的是${netty.tcnative.version}
被评估为父pom中定义的属性,因为它出现在正在寻找的jar路径中
多谢各位
编辑:我认为问题可能是因为gradle引用了依赖项,而maven没有被调用来运行os maven插件,后者会计算表达式。只是猜测而已
# 1 楼答案
当我的POM包含一个父POM,该父POM还将
os-maven-plugin
定义为扩展时,我发现正确解析os.detected.classifier
存在问题您可以尝试将其配置为插件 https://github.com/trustin/os-maven-plugin#issues-with-eclipse-m2e-or-other-ides