`subprojects` block won't let you apply signing
chrisjenx opened this issue · 2 comments
chrisjenx commented
TBH, this is probably not the plugin, it's probably something else, but this breaks:
subprojects {
val p = this
p.plugins.withType<MavenPublishBasePlugin>().configureEach {
p.extensions.configure<MavenPublishBaseExtension>("mavenPublishing") {
publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL, automaticRelease = true)
signAllPublications()
}
But you can do this in the subprojects fine....
mavenPublishing {
signAllPublications()
}
Stack trace:
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin class 'org.gradle.plugins.signing.SigningPlugin'.
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:176)
at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:91)
at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:98)
at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:77)
at com.vanniktech.maven.publish.MavenPublishBaseExtension.signAllPublications(MavenPublishBaseExtension.kt:143)
at Build_gradle$3$1$1.execute(build.gradle.kts:32)
at Build_gradle$3$1$1.execute(build.gradle.kts:29)
at org.gradle.internal.extensibility.ExtensionsStorage$ExtensionHolder.configure(ExtensionsStorage.java:177)
at org.gradle.internal.extensibility.ExtensionsStorage.configureExtension(ExtensionsStorage.java:64)
at org.gradle.internal.extensibility.DefaultConvention.configure(DefaultConvention.java:207)
at Build_gradle$3$1.execute(build.gradle.kts:29)
at Build_gradle$3$1.execute(build.gradle.kts:28)
at org.gradle.internal.code.DefaultUserCodeApplicationContext$CurrentApplication$1.execute(DefaultUserCodeApplicationContext.java:124)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction$1.run(DefaultCollectionCallbackActionDecorator.java:110)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.api.internal.DefaultCollectionCallbackActionDecorator$BuildOperationEmittingAction.execute(DefaultCollectionCallbackActionDecorator.java:107)
at org.gradle.api.internal.DefaultMutationGuard$1.execute(DefaultMutationGuard.java:45)
at org.gradle.api.internal.collections.CollectionFilter$1.execute(CollectionFilter.java:62)
at org.gradle.internal.ImmutableActionSet$SetWithManyActions.execute(ImmutableActionSet.java:329)
at org.gradle.api.internal.DefaultDomainObjectCollection.doAdd(DefaultDomainObjectCollection.java:262)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:251)
at org.gradle.api.internal.plugins.DefaultPluginContainer.pluginAdded(DefaultPluginContainer.java:50)
at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:196)
at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:54)
at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:288)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:170)
at org.gradle.internal.code.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:44)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:169)
at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:91)
at org.gradle.api.internal.plugins.DefaultPluginManager.addImperativePlugin(DefaultPluginManager.java:98)
at org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:77)
at com.vanniktech.maven.publish.MavenPublishPlugin.apply(MavenPublishPlugin.kt:8)
at com.vanniktech.maven.publish.MavenPublishPlugin.apply(MavenPublishPlugin.kt:6)
at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:54)
at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
at org.gradle.api.internal.plugins.ModelDefaultsApplyingPluginTarget.applyImperative(ModelDefaultsApplyingPluginTarget.java:46)
at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:190)
at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:54)
at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:288)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:170)
at org.gradle.internal.code.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:44)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:169)
at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:139)
at org.gradle.plugin.use.resolve.internal.ClassPathPluginResolution.applyTo(ClassPathPluginResolution.java:50)
at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator$ApplyAction.apply(DefaultPluginRequestApplicator.java:156)
... 193 more
Caused by: org.gradle.api.internal.AbstractMutationGuard$IllegalMutationException: DefaultPluginContainer#add(T) on [com.android.ide.gradle.model.builder.AndroidStudioToolingPlugin@2e91347d, org.gradle.api.plugins.HelpTasksPlugin_Decorated@379035ae, org.gradle.buildinit.plugins.BuildInitPlugin_Decorated@2b8bf3de, org.gradle.buildinit.plugins.WrapperPlugin_Decorated@3222cf19, com.android.build.gradle.internal.plugins.VersionCheckPlugin@50311b4, org.gradle.language.base.plugins.LifecycleBasePlugin_Decorated@34058186, org.gradle.api.plugins.BasePlugin_Decorated@5330d842, org.gradle.api.plugins.JvmEcosystemPlugin_Decorated@d9cc856, org.gradle.api.plugins.ReportingBasePlugin_Decorated@469ec57b, org.gradle.api.plugins.JvmToolchainsPlugin_Decorated@6f85cbd4, org.gradle.api.plugins.JavaBasePlugin_Decorated@e749e7e, com.android.build.gradle.api.AndroidBasePlugin@5496b74e, com.android.build.gradle.internal.plugins.LibraryPlugin@3608b36, com.android.build.gradle.LibraryPlugin@3a433598, org.jetbrains.kotlin.gradle.scripting.internal.ScriptingKotlinGradleSubplugin@2da9e57c, org.jetbrains.kotlin.gradle.scripting.internal.ScriptingGradleSubplugin@513259fd, org.jetbrains.kotlin.gradle.plugin.KotlinMultiplatformPluginWrapper@15724675, org.jetbrains.kotlinx.serialization.gradle.SerializationGradleSubplugin@72bb002d, app.cash.sqldelight.gradle.SqlDelightPlugin_Decorated@4c545b71, org.gradle.api.publish.plugins.PublishingPlugin_Decorated@689c7f37, org.gradle.api.publish.maven.plugins.MavenPublishPlugin_Decorated@1498c832, com.vanniktech.maven.publish.MavenPublishBasePlugin@378f42b6] cannot be executed in the current context.
at org.gradle.api.internal.AbstractMutationGuard.createIllegalStateException(AbstractMutationGuard.java:39)
at org.gradle.api.internal.AbstractMutationGuard.assertMutationAllowed(AbstractMutationGuard.java:27)
at org.gradle.api.internal.DefaultDomainObjectCollection.assertMutable(DefaultDomainObjectCollection.java:440)
at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:249)
at org.gradle.api.internal.plugins.DefaultPluginContainer.pluginAdded(DefaultPluginContainer.java:50)
at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:196)
at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:54)
at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:288)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:166)
at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:170)
at org.gradle.internal.code.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:44)
at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:169)
... 257 more
gabrielittner commented
Could you try using p.plugins.withId("...")
instead of withType
? The withType<MavenPublishBasePlugin>().configureEach
iterates over a filtered collection of plugins and calling signAllPublications
will add a new plugin (the signing plugin). It seems like Gradle doesn't like it when a plugin is added from inside the configureEach
chrisjenx commented
Interesting, yes that fixed it, TIL, not seen that before. Generally try to use configureEach AFAIK it is lazy vs the latter. But that works, thanks!