可以根据 JDK 版本(例如 1.7 或 1.8)打开 Maven 配置文件。但是我找不到基于 JDK 更新版本激活配置文件的方法。
具体来说,如果使用 JDK 1.8.0_u121 或更高版本,我希望能够激活配置文件。例如,这不起作用:
<profiles>
<profile>
<activation>
<jdk>[1.8.0_u121,]</jdk>
<activation>
</profile>
<additionalparam>--allow-script-in-comments</additionalparam>
</profiles>
实现相同效果的配置文件的任何替代方案(在使用 1.8.0_u121 或更高版本时允许设置属性将很高兴被接受)。
最佳答案
Maven's Introduction to Build Profiles documentation说:
The following configuration will trigger the profile when the JDK's version starts with "1.4" (eg. "1.4.0_08", "1.4.2_07", "1.4"):
<profiles> <profile> <activation> <jdk>1.4</jdk> </activation> </profile> </profiles>
然后提到从 Maven 2.1 开始,您可以使用 Enforcer Version Range Syntax .
根据这些文档,我相信您的激活不是由于额外的
u
而触发的。 .也许尝试:<profiles>
<profile>
<activation>
<jdk>[1.8.0_121,)</jdk>
<activation>
</profile>
...
</profiles>
关于maven - 根据 JDK 更新版本选择 Maven 配置文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43849647/