Spring Boot buildInfo is causing Groovy Source Set be not "up-to-date" all the time

Viewed 153

in our project we are working with

springBoot 2.2.11
groovy 2.5.6

Our build.gradle looks like the following:

...
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()
}
...

When we run gradlew test --info we get the following 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'.
...

The build-info.properties file which is generated by spring-boots buildInfo step contains a build.time property which is updated on every execution. The Java Compiler excludes this file apperently as the up-to-date check for :compileJava is returning true. However, the compileGroovy tasks includes this file into his sourceSet which is why it returns false on the up-to-date check.

I already tried the exclude option as follows with no success.

sourceSets {
  test {
    java { srcDirs = ['src/test/java'] }
    groovy {
      srcDirs = ['src/test/groovy']
      excludes = [file("${buildDir}/resources/main/META-INF/build-info.properties")]
    }
  }
}

Any ideas on how to fix this? Idealy I would like to exclude the file build\resources\main\META-INF\build-info.properties from the up-to-date-check (or even the input sourceSet of compileGroovy).

1 Answers

You need to make spring-boot.properties generated with no time part(what makes springBoot task out of dated what in turn leads compileJava outdated)

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
        }
    }
}
Related