Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error reporting for issues with ExtraJavaModule Plugin integration #121

Open
tg-freigmbh opened this issue Aug 1, 2024 · 1 comment

Comments

@tg-freigmbh
Copy link

Hi.
So I tried to migrate from a Project Plugin to a settings Plugin.

But I got:


java.lang.NoClassDefFoundError: org/gradlex/javamodule/moduleinfo/ExtraJavaModuleInfoPluginExtension
	at org.gradlex.javamodule.dependencies.internal.bridges.ExtraJavaModuleInfoBridge.autoRegisterPatchedModuleMappings(ExtraJavaModuleInfoBridge.java:30)
	at org.gradlex.javamodule.dependencies.JavaModuleDependenciesPlugin.lambda$setupExtraJavaModulePluginBridge$4(JavaModuleDependenciesPlugin.java:125)
	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.collections.CollectionFilter$1.execute(CollectionFilter.java:62)
	at org.gradle.api.internal.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:161)
	at org.gradle.api.internal.plugins.DefaultPluginContainer$2.execute(DefaultPluginContainer.java:163)
	at org.gradle.api.internal.plugins.DefaultPluginContainer$2.execute(DefaultPluginContainer.java:154)
	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.DefaultDomainObjectCollection.all(DefaultDomainObjectCollection.java:161)
	at org.gradle.api.internal.plugins.DefaultPluginContainer.withId(DefaultPluginContainer.java:167)
	at org.gradlex.javamodule.dependencies.JavaModuleDependenciesPlugin.setupExtraJavaModulePluginBridge(JavaModuleDependenciesPlugin.java:124)
	at org.gradlex.javamodule.dependencies.JavaModuleDependenciesPlugin.applyProject(JavaModuleDependenciesPlugin.java:89)
	at org.gradlex.javamodule.dependencies.JavaModuleDependenciesPlugin.apply(JavaModuleDependenciesPlugin.java:78)
	at org.gradlex.javamodule.dependencies.JavaModuleDependenciesPlugin.apply(JavaModuleDependenciesPlugin.java:66)

No quite sure, do I have to immediatly remove the ProjectPlugin when i Use the settings Plugin, will the extraModuleInfoPlugin integrate when I switch to the settings Plugin?

@jjohannes
Copy link
Member

Thank you for reporting this. I think this is a problem with the Gradle classloading and the integration with the ExtraJavaModuleInfoPlugin that could also happen in other situations and other versions.

You probably now apply this plugin in settings.gradle and Gradle therefore loads it in the "global scope". Then you apply the extra-java-module-info later and Gradle loads it in a more specialized (sub)project scope.

I usually make sure that all plugins are loaded in one scope to avoid such issues. It is a very confusing topic that hopefully gets improved in some future Gradle version: gradle/gradle#25616

In you case, if you apply the plugin with version directly in settings, adding this should fix the issue:

// settings.gradle
plugins {
  id("org.gradlex.java-module-dependencies") version "1.7"
  id("org.gradlex.extra-java-module-info") version "1.8" apply false
}

Another option is to have all the dependencies to the plugin Jars in one place (like this for example) and never use versions in the plugins { } blocks.


On our side, we can think about giving a better error message. And/or, for the next major release, we may consider combining all org.gradlex.*java-module* plugins into one repository and release them together in one Jar. Then they are always loaded and always fit together. You would still be able to apply them separately.

@jjohannes jjohannes changed the title New Settings Plugin causes NoClassDefFoundError in combination with the ExtraJavaModule Plugin Improve error reporting for issues with ExtraJavaModule Plugin integration Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants