Filip Wiesner
02/12/2021, 9:09 AMKotlinDependencyHandler in buildSrc so we can call implementation(...) there (using function with receiver e.g fun KotlinDependencyHandler.installDependencies(){}) instead of in build.gradle.kts?Javier
02/12/2021, 9:13 AMJavier
02/12/2021, 9:14 AMplugins {
kotlin("jvm")
}Filip Wiesner
02/12/2021, 9:20 AMbuildSrc build.gradle.kts file? All other buid.gradle.kts files that depend on it stop working (unresolved reference ... on every dsl function) if I try that.Javier
02/12/2021, 9:21 AMtapchicoma
02/12/2021, 9:31 AMbuildSrc/build.gradle.kts :
dependencies {
"implementation"("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.30")
}irus
02/12/2021, 9:32 AMdependencies {
"implementation"("org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.4.30")
}irus
02/12/2021, 9:38 AMFilip Wiesner
02/12/2021, 9:47 AMKotlinDependencyHandler and the function did not work with it as a receiver (had to pass it as a parameter). Thanks @irus
With the plugin dependency (not 'plugin-api') I was getting some ClassDefNotFoundException.irus
02/12/2021, 9:49 AMVampire
02/12/2021, 9:50 AMVampire
02/12/2021, 9:50 AMThat worked! But I had to manually import theÂDo you use the and the function did not work with it as a receiver (had to pass it as a parameter).KotlinDependencyHandler
kotlin-dsl plugin?
Might be that it sets the sam-with-receiver compiler option so that it works the other way aroundFilip Wiesner
02/12/2021, 9:52 AMplugins {
`kotlin-dsl`
}
repositories {
jcenter()
}
dependencies {
"implementation"("org.jetbrains.kotlin:kotlin-gradle-plugin-api:1.4.30")
}irus
02/12/2021, 9:53 AMThey are, in pre-compiled script plugins
plugins {
`kotlin-dsl`
}
repositories {
mavenCentral()
}
val kotlinVersion = "1.4.30"
dependencies {
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-serialization:$kotlinVersion")
}
But not in case of kotlin plugin in buildSrc, they not available in main sourceSetVampire
02/12/2021, 9:55 AMVampire
02/12/2021, 9:55 AMirus
02/12/2021, 9:56 AMVampire
02/12/2021, 9:57 AMVampire
02/12/2021, 9:57 AMVampire
02/12/2021, 9:57 AMJavier
02/12/2021, 9:58 AMJavier
02/12/2021, 9:59 AMJavier
02/12/2021, 10:00 AMinternal fun DependencyHandler.implementation(dependencyNotation: Any): Dependency? =
add("implementation", dependencyNotation)Javier
02/12/2021, 10:00 AMinternal fun DependencyHandler.api(dependencyNotation: Any): Dependency? =
add("api", dependencyNotation)Javier
02/12/2021, 10:00 AMirus
02/12/2021, 10:08 AMVampire
02/12/2021, 10:08 AMVampire
02/12/2021, 10:08 AMVampire
02/12/2021, 10:09 AMwhatever.gradle.ktsirus
02/12/2021, 10:11 AMVampire
02/12/2021, 10:11 AMplugins block from the script plugin
• apply it to a dummy project
• look what supported things like tasks, extensions and so on were added to the dummy project
• generate accessors for those added things
Now in the rest of the script plugin you can use these accessors.
If a plugin for example adds tasks dynamically depending on some extension configuration, those tasks will also not be available as they will not be added in the dummy project.Vampire
02/12/2021, 10:12 AMVampire
02/12/2021, 10:13 AMJavier
02/12/2021, 10:26 AMkotlin block from multiplatform plugin if you are only using the kotlin jvm plugin. This is the same. If you havent a plugin that has the dependencies block, why it should be there?
And this problem is no only in buildSrc, you can see that in a normal module where you only can access to the methods provided by the plugins you are using, not all method of all plugins in the world.irus
02/12/2021, 10:36 AMkotlin-dsl to buildSrc classpathVampire
02/12/2021, 10:43 AM