In my Android/Gradle project in the buildSrc folder I like to provide a property which returns the data type org.jetbrains.kotlin.gradle.dsl.JvmTarget in the buildSrc folder. The build configuration for this folder currently looks like this:
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
Which plugin/dependency do I have to add to get access to org.jetbrains.kotlin.gradle.dsl data types?
To access
org.jetbrains.kotlin.gradle.dsl.JvmTargetand other types related to the Kotlin plugin in normal Kotlin files (including Kotlin files in thebuildSrcproject), you should add the Kotlin Gradle plugin JAR to the classpath:Note that doing this in the
buildSrcbuild.gradle.ktsfile adds the Kotlin plugin to the classpath of allbuild.gradle.ktsfiles in the project, which means you will need to remove references to the version to other applications of the Kotlin plugin elsewhere in the build to avoid a Gradle error.This also means that the version you specify in such a way in a
buildSrcproject will define the Kotlin plugin version throughout your project.