Matthieu Ghilain
10/16/2024, 10:48 AMproject.dependencies {
implementation("org.springframework.boot:spring-boot-gradle-plugin:3.3.4")
}
I must write
project.dependencies.apply {
this.add("compileOnly", "jakarta.servlet:jakarta.servlet-api")
}Matthieu Ghilain
10/16/2024, 10:54 AMKotlinClosure0 but it seems not to be available.Matthieu Ghilain
10/16/2024, 10:56 AMThomas Broyer
10/16/2024, 11:01 AMkotlin-dsl plugin)? In the latter case, you have to import the Kotlin DSL extensions.Matthieu Ghilain
10/16/2024, 11:02 AMMatthieu Ghilain
10/16/2024, 11:04 AMimplementation("org.gradle.kotlin:gradle-kotlin-dsl-plugins:5.1.2")Matthieu Ghilain
10/16/2024, 11:05 AMgradleKotlinDsl()Matthieu Ghilain
10/16/2024, 11:28 AMMatthieu Ghilain
10/16/2024, 11:28 AMAdam
10/16/2024, 12:40 PMgradleKotlinDSl() make sure to add the import
import org.gradle.kotlin.dsl.*Vampire
10/16/2024, 1:21 PMDespite adding the kotlin dsl plugin as a dependency to my project, I still can't access the extensions defined on DependencyHandler
gradleKotlinDsl() is not a dependency on the kotlin-dsl plugin.
It is a dependency to on the Kotlin DSL.
The kotlin-dsl plugin also adds this dependency to your project and additionally does some other things like configuring the assignment Kotlin compiler plugin which allows you to set `Property`s using = or the sam-with-receiver Kotlin compiler plugin.
I still can't access the extensions defined on DependencyHandler
implementation(...) is not a fixed extension on DependencyHandler.
In a Kotlin DSL build script where you applied some plugin in the plugins { ... } block that adds a configuration called implementation
you have a generated accessor extension function that lets you do implementation("...") on the dependency handler.
In a normal Kotlin file, you don't have such accessors.
So you have to have a variable of type Configuration or Provider<Configuration>, and then you can use that syntax if you imported org.gradle.kotlin.dsl.invoke.