Trying to update a project that uses the Gradle Kotlin DSL to Spring Boot 3.0 causes several Spring Boot plugins to fail. Specifically, when I try to set the build info time to null (for reproducible builds), I get an error.

Here is the snippet of the build.gradle.kts:

springBoot {
  buildInfo {
    properties {
      time = null // necessary for reproducible builds, see https://github.com/spring-projects/spring-boot/issues/14494
    }
  }
}

I get the following error when I try to build:

  Line 299:       time = null                                                                                                      
                  ^ Val cannot be reassigned

Our current version of Kotlin is 1.7.22. We are using Gradle 7.6.

I've tried using the setter method but it appears to not be in scope for Kotlin DSL. I've tried using some of the other properties setter methods that my IDE exposes. None of them seem to work.

Comment From: scottfrederick

This is likely due to a change in how the Spring Boot Gradle plugin uses properties, which is covered in the 3.0 Migration Guide here: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide#configuring-gradle-tasks.

The updated documentation shows examples of setting properties in a Kotlin build file (be sure to click on the Kotlin button above the examples).

I've tried using the setter method but it appears to not be in scope for Kotlin DSL.

Can you give an example of the error you get when you try something like time.set(null)?

Comment From: danielshiplett

Thanks for the response. It was this example:

springBoot {
    buildInfo {
        excludes.set(setOf("time"))
    }
}

That resolved the issue.

Trying to use the setter resulted in an error about there being so method with a matching signature. I suspect it might have been because IntelliJ couldn't update the Gradle build model until all the issues were resolved.

The 'excludes' method plus using the setters when configuring the BootBuildImage task were enough to get my kts fixed enough that the rest of the dependencies would pull down and my IDE could catch up and help me with the rest.