How I can write this code in kotlin dsl?
dependencies{
api'org.slf4j:slf4j-api:1.7.25'
}
I can't find for what I need to change groovy "api" (in dependencies block) in kotlin dsl. For example I want to use org.slf4j, I want to declare it like API, but I checked migration docs and found analogies only for implementation, compile, etc. I use intellij idea.
I tried this:
plugins {
id("java")
}
group = "com.myapp"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
}
dependencies {
api("org.slf4j:slf4j-api:1.7.36")
}
But is says: "Unresolved reference: api"
I checked this: https://docs.gradle.org/current/userguide/migrating_from_groovy_to_kotlin_dsl.html https://docs.gradle.org/current/userguide/kotlin_dsl.html
The syntax should be api("org.slf4j:slf4j-api:1.7.25")
.
You need to use the java-library
plugin instead of just java
to have access to the “api” configuration, regardless of whether your script is in Groovy or Kotlin.