Hi, currently documentation says how to configure devtools using maven and gradle (groovy), but missing how to configure it using gradle with Kotlin DSL :)

For people who are just starting with gradle and Kotlin DSL, as myself πŸ˜‰, I can say it is not straightforward to migrate from Groovy DSL. After some time struggling with it, I think that I finally managed to configure devtools using Kotlin DSL and I thought it could be useful for others:

instead of:

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom developmentOnly
    }
}

in Kotlin DSL one should use:

val developmentOnly = configurations.create("developmentOnly")
configurations.runtimeClasspath.get().extendsFrom(developmentOnly)

maybe you could add it to the documentation so others could find it faster πŸ˜ƒ

Comment From: mbhave

This is probably wider than just devtools. We have other gradle examples in the doc that are in groovy. I think if we decide to do this, we should have general strategy for how to document gradle snippets in groovy and Kotlin (similar to the Spring Boot Gradle Plugin). Let's see what the rest of the team thinks.

Comment From: wilkinsona

I'm not sure that we should try and cover both Groovy and Kotlin Gradle configuration in the main reference documentation, particularly when it's something that's standard Gradle rather than being specific to our plugin. Gradle's own documentation already shows how to do this.

Comment From: venzersiz

@mkurcius Hi. Because of you, I solved my problem.

First, I don't know gradle well. I was using Spring Boot 2.1.5.RELEASE with Spring Initializr on IntelliJ IDEA. But when I used Spring Boot 2.1.6.RELEASE in same environment, IntelliJ IDEA could not resolve 'developmentOnly'.

I changed this

configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom(configurations.developmentOnly.get())
    }
    compileOnly {
        extendsFrom(configurations.annotationProcessor.get())
    }
}

to

val developmentOnly = configurations.create("developmentOnly")
configurations {
    developmentOnly
    runtimeClasspath {
        extendsFrom(developmentOnly)
    }
    compileOnly {
        extendsFrom(configurations.annotationProcessor.get())
    }
}

Thank you!

Comment From: mkurcius

@venzersiz I'm glad I could help :)

Comment From: nicholasq

This has been bugging me for a couple of hours. @mkurcius @venzersiz Thanks! Your solutions worked for me too.

Comment From: evorts

Thanks a lot @mkurcius & @venzersiz. I also had the same problem, have no idea what to do until i found this solution.

Comment From: arunvelsriram

The issue is fixed now https://github.com/spring-io/start.spring.io/issues/146

Comment From: steklopod

in Kotlin DSL one should use:

val developmentOnly = configurations.create("developmentOnly") configurations.runtimeClasspath.get().extendsFrom(developmentOnly)

maybe you could add it to the documentation so others could find it faster πŸ˜ƒ

  • Good idea πŸ’‘ to document this
  • Better idea is to make it work out of the box πŸ“¦

Comment From: liyofx

developmentOnly("org.springframework.boot:spring-boot-devtools")
dependencies {
      developmentOnly("org.springframework.boot:spring-boot-devtools")
}

Comment From: geoHeil

I want to get: testCompile.extendsFrom compileOnly compatible for the Kotlin DSL (https://stackoverflow.com/questions/62452133/gradle-kotlin-dsl-extendsfrom).

So far, it is not working when trying:

configurations {
        testCompile {
            val executableJarsCompileOnly = configurations.create("compileOnly")
            extendsFrom(executableJarsCompileOnly)
        }
    }

it fails with:

NamedDomainObjectContainer#create(String) on configuration container cannot be executed in the current context.

do you have any pointers what is going wrong?

Comment From: geoHeil

configurations {
        testCompile {
            extendsFrom(configurations.compileOnly.get())
        }
    }

ha - finally. This is looking better

Comment From: wilkinsona

The developmentOnly configuration is now created automatically.