[英]Spring Boot buildInfo is causing Groovy Source Set be not "up-to-date" all the time
在我们正在合作的项目中
springBoot 2.2.11
groovy 2.5.6
我们的 build.gradle 如下所示:
...
plugins {
id 'groovy'
id 'java'
id 'idea'
}
configurations {
testCompile.extendsFrom compile
testRuntime.extendsFrom runtime
...
}
...
sourceSets {
test {
java { srcDirs = ['src/test/java'] }
groovy {srcDirs = ['src/test/groovy'] }
}
...
}
...
springBoot {
buildInfo()
}
...
当我们运行gradlew test --info
我们得到以下 output:
...
> Task :bootBuildInfo
Caching disabled for task ':bootBuildInfo' because:
Build cache is disabled
Task ':bootBuildInfo' is not up-to-date because:
Value of input property 'properties.time' has changed for task ':bootBuildInfo'
...
> Task :compileJava UP-TO-DATE
...
Skipping task ':compileJava' as it is up-to-date.
...
> Task :compileTestGroovy
Caching disabled for task ':compileTestGroovy' because:
Build cache is disabled
Task ':compileTestGroovy' is not up-to-date because:
Input property 'astTransformationClasspath' file C:\projects\test-project\build\resources\main\META-INF\build-info.properties has changed.
The input changes require a full rebuild for incremental task ':compileTestGroovy'.
...
由 spring-boots buildInfo 步骤生成的 build-info.properties 文件包含一个build.time
属性,该属性在每次执行时都会更新。 Java 编译器明显排除了此文件,因为对:compileJava
的最新检查返回 true。 但是, compileGroovy
任务将此文件包含在他的 sourceSet 中,这就是它在最新检查时返回 false 的原因。
我已经尝试了如下的exclude
选项,但没有成功。
sourceSets {
test {
java { srcDirs = ['src/test/java'] }
groovy {
srcDirs = ['src/test/groovy']
excludes = [file("${buildDir}/resources/main/META-INF/build-info.properties")]
}
}
}
有想法该怎么解决这个吗? 理想情况下,我想从最新检查中排除文件build\resources\main\META-INF\build-info.properties
(甚至是 compileGroovy 的输入 sourceSet)。
您需要生成没有时间部分的 spring-boot.properties(是什么让 springBoot 任务过时,又导致 compileJava 过时)
springBoot {
buildInfo {
properties {
// to make compileJava up to date
// https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#integrating-with-actuator.build-info
time = null
}
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.