Slackbot
06/23/2022, 6:23 PMVampire
06/23/2022, 7:20 PMHendra Anggrian
06/23/2022, 7:28 PMsubprojects or allprojects, I need reference to particular extension or task in root build.gradle. For example:
subprojects {
afterEvaluate {
extensions.getByType<KotlinProjectExtension>().jvmToolchain {
(this as JavaToolchainSpec).languageVersion.set(JavaLanguageVersion.of(sdk.versions.jdk.get()))
}
}
}Vampire
06/23/2022, 7:36 PMsubprojects or allprojects block is bad too. It immediately introduces project coupling and works against more sophisticated features like parallel execution or configuration cache. So using them is highly discouraged anyway. The proper way to share configuration code is to use convention plugins.Vampire
06/23/2022, 7:37 PMafterEvaluate is also bad in almost all cases where it is used, it is usually only symptom treatment and just delays problem to a later and harder debug point in time and always introduces race conditions as the thing meant to wait for could also happen in an afterEvaluate block happening after your afterEvaluate block.Vampire
06/23/2022, 7:38 PMpluginManager.withPlugin...Vampire
06/23/2022, 7:42 PMHendra Anggrian
06/23/2022, 8:02 PMafterEvaluate is a bad and will move on from this practice.
Another reason to use legacy plugin application is if a plugin has optional dependency, I still need to configure the capabilities in root build.gradle :
buildscript {
dependencies {
classpath("my.plugin") {
capabilities { ... }
}
}
}Hendra Anggrian
06/23/2022, 8:04 PMorg.gradle.api.InvalidUserDataException . As of version 7.4.2, withoutVersion is only limited to LibraryAliasBuilder.Vampire
06/23/2022, 8:05 PMHendra Anggrian
06/23/2022, 8:07 PMPluginAliasBuilder does not have a function withoutVersion, only LibraryAliasBuilder does.Vampire
06/23/2022, 8:09 PMVampire
06/23/2022, 8:12 PMplugins { ... } DSL it imho is a bug in that plugin that should be fixed.
It should maybe instead have different sub-plugins for the use-cases that you apply additionally.
As a work-around you could probably declare this dependency in buildSrc build script in runtimeOnly scope.Vampire
06/23/2022, 8:14 PMlibs.plugins.myPlugin.get().pluginId to only get the id without versionHendra Anggrian
06/23/2022, 8:31 PMChris Lee
06/23/2022, 9:00 PMHendra Anggrian
06/23/2022, 9:40 PM