Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gradle Spring Boot plugin with Kotlin DSL does not support includeProjectDependencies in bootJar > layered > dependencies configuration #35033

Closed
olivier-lemerdy-kry opened this issue Apr 17, 2023 · 4 comments
Labels
type: bug A general bug
Milestone

Comments

@olivier-lemerdy-kry
Copy link

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!

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Apr 17, 2023
@wilkinsona
Copy link
Member

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.

@wilkinsona wilkinsona added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Apr 17, 2023
@wilkinsona wilkinsona added this to the 2.7.x milestone Apr 17, 2023
@wilkinsona
Copy link
Member

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.

@olivier-lemerdy-kry
Copy link
Author

Thanks for the workaround!

@wilkinsona
Copy link
Member

Fixed by 751fc9f.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

No branches or pull requests

3 participants