Using Spring Boot 3.0.5 with Gradle 7.6.1 and Kotlin DSL for Gradle build files, it seems impossible to use includeProjectDependencies() in bootJar > layered > dependencies configuration.

Here is a sample project to showcase the issue: https://github.com/olivier-lemerdy-kry/custom-layer-kotlin-dsl

According to Spring Boot Gradle plugin documentation on Custom Layers configuration,

The intoLayer closure claims content using nested include and exclude calls. The application closure uses Ant-style path matching for include/exclude parameters. The dependencies section uses group:artifact[:version] patterns. It also provides includeProjectDependencies() and excludeProjectDependencies() methods that can be used to include or exclude project dependencies.

However, when you try to use it in this repository build.gradle.kts file, you get the following error

build.gradle.kts:28:17: Unresolved reference: includeProjectDependencies

Looking at the source code of the Spring Boot Gradle plugin, it seems that the includeProjectDependencies() is present in the provided examples for Groovy build.gradle and absent in provided examples for Kotlin DSL build.gradle.kts.

Would it be possible to support this property in Kotlin DSL as well as it is now the new standard for Gradle? Thanks!

Comment From: wilkinsona

Thanks for the report. I suspect we're missing some type information that prevents Kotlin from knowing that it's dealing with a DependenciesIntoLayerSpec. Right now, that information will only be available at runtime so it only works with Groovy.

Comment From: wilkinsona

You can work around the problem by casting:

dependencies {
    intoLayer("application") {
        (this as DependenciesIntoLayerSpec).includeProjectDependencies()
    }
}

You'll need to import org.springframework.boot.gradle.tasks.bundling.LayeredSpec.DependenciesIntoLayerSpec as well.

Comment From: olivier-lemerdy-kry

Thanks for the workaround!

Comment From: wilkinsona

Fixed by 751fc9fe54fc84f587f5e5b1c80abce13f9f59ec.