swagger-core icon indicating copy to clipboard operation
swagger-core copied to clipboard

Upgrade to v2.2.27: Cannot change dependencies of dependency configuration '<CONFIG>' after it has been included in dependency resolution

Open paiden opened this issue 1 year ago • 6 comments

Hi,

I'm trying to update io.swagger.core.v3:swagger-gradle-plugin from 2.2.26 to 2.2.27.

As soon as I try this the build start to fail with the following error message

[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.preventIllegalMutation(DefaultConfiguration.java:1493)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.validateMutation(DefaultConfiguration.java:1459)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.lambda$validateMutationType$0(DefaultConfiguration.java:350)
[2024-12-18T07:29:08.690Z] 	at org.gradle.internal.ImmutableActionSet$SingletonSet.execute(ImmutableActionSet.java:225)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.DefaultDomainObjectSet.assertMutableCollectionContents(DefaultDomainObjectSet.java:57)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.DefaultDomainObjectCollection.add(DefaultDomainObjectCollection.java:250)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.DelegatingDomainObjectSet.add(DelegatingDomainObjectSet.java:114)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.DefaultDependencySet.add(DefaultDependencySet.java:68)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.DefaultDependencySet.add(DefaultDependencySet.java:35)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.doAddRegularDependency(DefaultDependencyHandler.java:201)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.doAdd(DefaultDependencyHandler.java:195)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.access$100(DefaultDependencyHandler.java:72)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler$DirectDependencyAdder.add(DefaultDependencyHandler.java:437)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler$DirectDependencyAdder.add(DefaultDependencyHandler.java:432)
[2024-12-18T07:29:08.690Z] 	at org.gradle.api.internal.artifacts.dsl.dependencies.DynamicAddDependencyMethods.tryInvokeMethod(DynamicAddDependencyMethods.java:56)
[2024-12-18T07:29:08.690Z] 	at org.gradle.internal.metaobject.BeanDynamicObject$MetaClassAdapter.invokeMethod(BeanDynamicObject.java:561)
[2024-12-18T07:29:08.690Z] 	at org.gradle.internal.metaobject.BeanDynamicObject.tryInvokeMethod(BeanDynamicObject.java:218)
[2024-12-18T07:29:08.690Z] 	at org.gradle.internal.metaobject.CompositeDynamicObject.tryInvokeMethod(CompositeDynamicObject.java:99)
[2024-12-18T07:29:08.690Z] 	at org.gradle.internal.extensibility.MixInClosurePropertiesAsMethodsDynamicObject.tryInvokeMethod(MixInClosurePropertiesAsMethodsDynamicObject.java:38)
[2024-12-18T07:29:08.690Z] 	at org.gradle.internal.metaobject.ConfigureDelegate.invokeMethod(ConfigureDelegate.java:65)
[2024-12-18T07:29:08.690Z] 	at build_69n9ixd66v86rijstdeqwnwkb$_run_closure2.doCall$original(/home/jenkins/agent/workspace/ore.v3-swagger-gradle-plugin-2.x/<PROJECT>/build.gradle:19)
[2024-12-18T07:29:08.690Z] 	at build_69n9ixd66v86rijstdeqwnwkb$_run_closure2.doCall(/home/jenkins/agent/workspace/ore.v3-swagger-gradle-plugin-2.x/<PROJECT>/build.gradle)
[2024-12-18T07:29:08.690Z] 	at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
...

gradle version: 8.6

My Gradle skills are quite limited so I do not know how to provide more details or analyze this further.

paiden avatar Dec 18 '24 11:12 paiden

Can you provide some more details, including your gradle config and ideally a test project reproducing the issue?

frantuma avatar Dec 19 '24 11:12 frantuma

This is part of a quite large and complex gradle project. I cannot share any of the sources for that project here.

I will try to come up with project that reproduces the issue, that I can share. But this will take some time and I do not have too high hopes of succeeding in doing so.

paiden avatar Dec 20 '24 09:12 paiden

@frantuma I've faced the same issue, my project is public: https://github.com/valfirst/browserup-proxy/actions/runs/12467897498/job/34827477405

valfirst avatar Feb 02 '25 21:02 valfirst

I think the issue is that the runtime classpath is resolved too early. That is before the configuration phase is over. The exception then is raised afterwards when a configuration is changed.

I got the same issue in a bug project. It should be reproducable by having the following in the build.gradle, for example:

configurations {
	configureEach {
		// Exclude JUnit 4 globally to ensure not adding it as a transitive dependency
		exclude group: 'junit', module: 'junit'
	}
}

The resolution seems to be triggered at https://github.com/swagger-api/swagger-core/commit/583c21b11a9628aa87f030fb2b5b722d6bfedbb8#diff-c414ec7aea3be1621ea74aeea4bc392bda6b74eecba70d2df7ae06e64f649b61R27.

t-beckmann avatar Mar 03 '25 08:03 t-beckmann

Still same issue for v2.2.29

reinhapa avatar Mar 24 '25 11:03 reinhapa

One more datapoint.

Gatling introduced Gradle 9 build cache support in version 3.14.6.1 with Issue 4651.

As soon as we upgrade gatling to that version, we see the same build error for that gradle plugin, when building with Gradle 8.X.

That version contains exactly one commit 30cbb4ae789f54

Maybe there is some common code change in that commit, that could given a hint on the cause for this build error?

paiden avatar Oct 21 '25 17:10 paiden