I'm trying to switch to using Kotlin DSL to get dependencies versions from an object Kotlin file instead of gradle files. When I do a gradle sync it is unable to resolve reference, but I'm able to click on file (Libraries) from build.gradle.kts . I haven't made any other changes to build.gradle or settings.gradle . The issue isn't specific to Jackson and I tried this in multiple projects and read documentation and searched for answers before posting the question.
I get a build.gradle.kts:15:20: Unresolved reference: Libraries
This is the structure of my project
build.gradle
settings.gradle
+buildSrc
build.gradle.kts
+src
+main
+kotlin
Libraries.kt
This is the my build.gradle.kts file
import org.gradle.kotlin.dsl.`kotlin-dsl`
plugins {
`kotlin-dsl`
java
`java-gradle-plugin`
}
repositories {
mavenCentral()
}
dependencies {
implementation(Libraries.Jackson.core)
// implementation(Libraries.anotherJackson)
}
This is the kotlin Libraries.kt file
object Libraries {
val Jackson = JacksonLibraries
const val anotherJackson = "com.fasterxml.jackson.core:jackson-core:2.11.1"
}
object JacksonLibraries {
const val core = "com.fasterxml.jackson.core:jackson-core:${Versions.Jackson.core}"
}
object Versions {
object Jackson {
const val core = "2.11.1"
const val annotations = "2.11.1"
const val databind = "2.11.1"
}
}
If I try it without the Libraries file it works fine.
implementation("com.fasterxml.jackson.core:jackson-core:2.11.1")
But neither of these two work
implementation(Libraries.Jackson.core)
implementation(Libraries.anotherJackson)
Thanks in advance!
from Unresolved reference: Libraries - buildSrc
No comments:
Post a Comment