Slackbot
01/18/2023, 8:33 AMEli Graber
01/18/2023, 9:06 AMAnze Sodja
01/18/2023, 9:27 AMMartin
01/18/2023, 9:33 AMMartin
01/18/2023, 9:34 AMmyPlugin { detektVersion.set(foo) }
) (or better see below)
2. "reacting" on a plugin that is already applied (withPlugin {}
)Vampire
01/18/2023, 9:35 AMmyPlugin { useDetekt("1.2.3") }
Vampire
01/18/2023, 9:36 AMpluginManager.withPlugin
instead in that case.Vampire
01/18/2023, 9:37 AMEli Graber
01/18/2023, 1:20 PMimplementation
it leaks to the user's classpath and if they depend on detekt plugin as well it could override the version they use.
The same issue applies to all the other compileOnly
dependencies in that file. I'm just using detekt as an exampleVampire
01/18/2023, 1:25 PMVampire
01/18/2023, 1:28 PMcompileOnly
and instead of applying the detekt plugin it can simply react to the fact your consumer applied the detekt plugin using pluginManager.withPlugin("io.gitlab.arturbosch.detekt") { ... }
.
He could even apply your convention plugin (or all your convention plugins) without applying the detekt plugin and your convention plugin would then simply do nothing, as the withPlugin
closure will never be invoked.Eli Graber
01/18/2023, 2:20 PMEli Graber
01/18/2023, 2:24 PMMartin
01/18/2023, 2:28 PMSome of my projects have hundreds of subprojects so that's a pain.I see
After updating to Gradle 8.0-rc-2 the plugins that I apply in the precompiled script plugins are no longer foundMight also be a classloader thingie. Are you using
buildscript {}
by any chance, in which case you could try this?
// rootProject/build.gradle.kts
plugins {
id("io.gitlab.arturbosch.detekt").version(foo).apply(false)
}
Eli Graber
01/18/2023, 2:29 PMMartin
01/18/2023, 2:31 PM./gradlew -p build-logic build
or so...Eli Graber
01/18/2023, 2:32 PMMartin
01/18/2023, 2:33 PMsystemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=false
?Eli Graber
01/18/2023, 2:34 PMMartin
01/18/2023, 2:35 PMkotlin-dsl
). You won't have generated accessors but you'll be able to apply the detekt plugin dynamically I believeVampire
01/18/2023, 2:36 PMgeneratePrecompiledScriptPluginAccessors
task?
Could well be that this is a bug that the compileOnly
dependencies are not added to the dummy projects classpath that is used to generate the accesors.Vampire
01/18/2023, 2:37 PMplugins { ... }
block in your convention plugin but use the legacy apply(...)
. Then you also do not get accessors and need to use the more verbose syntax but can keep them as precompiled script plugins.Eli Graber
01/18/2023, 2:37 PMsystemProp.org.gradle.kotlin.dsl.precompiled.accessors.strict=false
actually worked! I guess it's just deprecated now, but still works?
It is happening during generatePrecompiledScriptPluginAccessors
Vampire
01/18/2023, 2:37 PMVampire
01/18/2023, 2:38 PMEli Graber
01/18/2023, 2:54 PM