当 maven 构建的父版本不是最新版本时,版本插件 display-parent-updates 的目标是很好地报告它,但我想以某种方式报告这一点:
- 将构建标记为警告或不稳定状态(在詹金斯中具有彩色视觉效果)
- 在 jacoco 报告中添加这个(不知道这是否可能,会很棒)-> 在声纳中可见
- 也许使用强制插件(不知道这是否有帮助)
有什么建议么?
当 maven 构建的父版本不是最新版本时,版本插件 display-parent-updates 的目标是很好地报告它,但我想以某种方式报告这一点:
有什么建议么?
I achieved this in 2 steps :
1. Use of the following plugin
`<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<executions>
<execution>
<id>display-dkv-boot-starter-parent-updates</id>
<phase>initialize</phase>
<goals>
<goal>display-parent-updates</goal>
</goals>
<configuration>
<allowSnapshots>true</allowSnapshots>
</configuration>
</execution>
</executions>
</plugin>`
使用带有自定义规则的强制插件
公共类 MyCustomRule 实现 EnforcerRule2 {
private boolean fail = false;
@Override
public void execute(EnforcerRuleHelper helper) throws EnforcerRuleException {
Log log = helper.getLog();
List<String> lines = Collections.emptyList();
try {
Path path = Paths.get((String) helper.evaluate("${versions.outputFile}"));
lines = Files.readAllLines(path);
fail = lines.stream()
.anyMatch(l -> l.contains("The parent project has a newer version"));
} catch (Exception ex) {
log.warn(ex);
fail = false;
}
if (this.fail) {
throw new EnforcerRuleException(lines.toString());
}
}
@Override
public boolean isCacheable() {
return false;
}
@Override
public boolean isResultValid(EnforcerRule enforcerRule) {
return fail;
}
@Override
public String getCacheId() {
return null;
}
@Override
public EnforcerLevel getLevel() {
return EnforcerLevel.WARN;
}
}