kordamp / enforcer-gradle-plugin

Kordamp Enforcer Gradle Plugin
Apache License 2.0
23 stars 3 forks source link

Enforcer implementation must change due to Gradle 7 #17

Open aalmiray opened 4 years ago

aalmiray commented 4 years ago

Current enforcer (0.8.0) will output a warning when rules related to artifact resolution are configured in a build. This warning occurs because settings resolves configurations belonging to a project, and that's a big no-no in Gradle 7.

The fix is to resolve configurations with a task that's registered on the project. This would make dependency resolution aware rules be good citizens however that also means rules won't be executed automatically after all projects are configured but not yet executed. And here lies the problem if the current design stays put:

To complicate matters, registering a buildFinished() listener is also a no go in Gradle 7 due to configuration cache (currently incubating since 6.6.). It may be the case that some rules will have to be removed or their effectiveness may become limited. It's unclear as of now if a combination of automatic execution as it's right now (early rules) and enforce tasks (dependency resolution aware) would be a good fit. Or perhaps all rules should be executed via tasks. Whatever the case it's likely that enforcer rules may not be compliant with configuration cache, in which case if that feature becomes stringent then enforcer may not be possible at some point.

aalmiray commented 3 years ago

Watch out for https://github.com/gradle/gradle/issues/15522

robvadai commented 3 years ago

It fails with Gradle 7, plugin version 0.9.0:

> Failed to apply plugin 'org.kordamp.gradle.enforcer'.
   > class org.gradle.api.internal.project.DefaultProject_Decorated cannot be cast to class org.gradle.api.initialization.Settings (org.gradle.api.internal.project.DefaultProject_Decorated and org.gradle.api.initialization.Settings are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @57baeedf)
bondolo commented 3 years ago

If another release of the plugin occurs before you are able to fix this issue perhaps add a version check and fail to run if Gradle 7+ is being used. (As usual I flailed for a while thinking the problem was my fault before learning that it wasn't expected to work).

aalmiray commented 3 years ago

@bondolo I'm waiting til Gradle 7.3 comes out to have another go at migration. Why that particular release? Because Gradle has a history of unstable releases after a major release. Things usually settle after a couple of minor releases are posted.

rr-nick-tan commented 2 years ago

same issue with gradle 7.3.1

2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] An exception occurred applying plugin request [id: 'org.kordamp.gradle.enforcer', version: '0.9.0']
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Failed to apply plugin 'org.kordamp.gradle.enforcer'.
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]    > class org.gradle.api.internal.project.DefaultProject_Decorated cannot be cast to class org.gradle.api.initialization.Settings (org.gradle.api.internal.project.DefaultProject_Decorated and org.gradle.api.initialization.Settings are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @66a3ffec)
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Try:
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Run with --scan to get full insights.
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] 
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'org.kordamp.gradle.enforcer', version: '0.9.0']
2021-12-19T10:55:01.341-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.exceptionOccurred(DefaultPluginRequestApplicator.java:206)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:188)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyLegacyPlugin(DefaultPluginRequestApplicator.java:137)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.access$300(DefaultPluginRequestApplicator.java:60)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator$1$1.lambda$addLegacy$0(DefaultPluginRequestApplicator.java:101)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.lambda$applyPlugins$0(DefaultPluginRequestApplicator.java:122)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:122)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:117)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.BuildOperationScriptPlugin$1.run(BuildOperationScriptPlugin.java:65)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
2021-12-19T10:55:01.342-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.BuildOperationScriptPlugin.lambda$apply$0(BuildOperationScriptPlugin.java:62)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:44)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.BuildOperationScriptPlugin.apply(BuildOperationScriptPlugin.java:62)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$0(DefaultProjectStateRegistry.java:366)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.fromMutableState(DefaultProjectStateRegistry.java:393)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.applyToMutableState(DefaultProjectStateRegistry.java:365)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:42)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:35)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.lambda$run$0(LifecycleProjectEvaluator.java:100)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$applyToMutableState$0(DefaultProjectStateRegistry.java:366)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.lambda$withProjectLock$3(DefaultProjectStateRegistry.java:426)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:211)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.withProjectLock(DefaultProjectStateRegistry.java:426)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.fromMutableState(DefaultProjectStateRegistry.java:407)
2021-12-19T10:55:01.343-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.applyToMutableState(DefaultProjectStateRegistry.java:365)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.project.LifecycleProjectEvaluator$EvaluateProject.run(LifecycleProjectEvaluator.java:91)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:63)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:751)
2021-12-19T10:55:01.344-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProject.evaluate(DefaultProject.java:151)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.project.DefaultProjectStateRegistry$ProjectStateImpl.ensureConfigured(DefaultProjectStateRegistry.java:339)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.TaskPathProjectEvaluator.configure(TaskPathProjectEvaluator.java:41)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:55)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.DefaultProjectsPreparer.prepareProjects(DefaultProjectsPreparer.java:48)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.BuildTreePreparingProjectsPreparer.prepareProjects(BuildTreePreparingProjectsPreparer.java:64)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.BuildOperationFiringProjectsPreparer$ConfigureBuild.run(BuildOperationFiringProjectsPreparer.java:52)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
2021-12-19T10:55:01.345-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.BuildOperationFiringProjectsPreparer.prepareProjects(BuildOperationFiringProjectsPreparer.java:40)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.VintageBuildModelController.lambda$prepareProjects$1(VintageBuildModelController.java:93)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.lambda$doTransition$1(StateTransitionController.java:222)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.doTransition(StateTransitionController.java:243)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.doTransition(StateTransitionController.java:221)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.transitionIfNotPreviously(StateTransitionController.java:190)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.VintageBuildModelController.prepareProjects(VintageBuildModelController.java:93)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.VintageBuildModelController.doBuildStages(VintageBuildModelController.java:77)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.initialization.VintageBuildModelController.prepareToScheduleTasks(VintageBuildModelController.java:64)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.DefaultBuildLifecycleController.lambda$prepareToScheduleTasks$0(DefaultBuildLifecycleController.java:105)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.lambda$doTransition$1(StateTransitionController.java:222)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.doTransition(StateTransitionController.java:243)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.doTransition(StateTransitionController.java:221)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.maybeTransition(StateTransitionController.java:174)
2021-12-19T10:55:01.346-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.DefaultBuildLifecycleController.prepareToScheduleTasks(DefaultBuildLifecycleController.java:103)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.DefaultBuildTreeWorkPreparer.scheduleRequestedTasks(DefaultBuildTreeWorkPreparer.java:33)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.lambda$doScheduleAndRunTasks$2(DefaultBuildTreeLifecycleController.java:86)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.composite.internal.DefaultIncludedBuildTaskGraph.withNewTaskGraph(DefaultIncludedBuildTaskGraph.java:94)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.doScheduleAndRunTasks(DefaultBuildTreeLifecycleController.java:85)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.lambda$runBuild$4(DefaultBuildTreeLifecycleController.java:103)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.lambda$transition$0(StateTransitionController.java:145)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.doTransition(StateTransitionController.java:243)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.build.StateTransitionController.transition(StateTransitionController.java:145)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.runBuild(DefaultBuildTreeLifecycleController.java:100)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.DefaultBuildTreeLifecycleController.scheduleAndRunTasks(DefaultBuildTreeLifecycleController.java:66)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:31)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
2021-12-19T10:55:01.347-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.ProblemReportingBuildActionRunner.run(ProblemReportingBuildActionRunner.java:49)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:69)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.FileSystemWatchingBuildActionRunner.run(FileSystemWatchingBuildActionRunner.java:114)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:41)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.RootBuildLifecycleBuildActionExecutor.lambda$execute$0(RootBuildLifecycleBuildActionExecutor.java:40)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:155)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.RootBuildLifecycleBuildActionExecutor.execute(RootBuildLifecycleBuildActionExecutor.java:40)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.DefaultBuildTreeContext.execute(DefaultBuildTreeContext.java:40)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.BuildTreeLifecycleBuildActionExecutor.lambda$execute$0(BuildTreeLifecycleBuildActionExecutor.java:65)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.buildtree.BuildTreeState.run(BuildTreeState.java:53)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.BuildTreeLifecycleBuildActionExecutor.execute(BuildTreeLifecycleBuildActionExecutor.java:65)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor$3.call(RunAsBuildOperationBuildActionExecutor.java:61)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor$3.call(RunAsBuildOperationBuildActionExecutor.java:57)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
2021-12-19T10:55:01.348-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.RunAsBuildOperationBuildActionExecutor.execute(RunAsBuildOperationBuildActionExecutor.java:57)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.lambda$execute$0(RunAsWorkerThreadBuildActionExecutor.java:38)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:211)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.exec.RunAsWorkerThreadBuildActionExecutor.execute(RunAsWorkerThreadBuildActionExecutor.java:38)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.ContinuousBuildActionExecutor.execute(ContinuousBuildActionExecutor.java:103)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SubscribableBuildActionExecutor.execute(SubscribableBuildActionExecutor.java:64)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.session.DefaultBuildSessionContext.execute(DefaultBuildSessionContext.java:46)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter$ActionImpl.apply(BuildSessionLifecycleBuildActionExecuter.java:100)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter$ActionImpl.apply(BuildSessionLifecycleBuildActionExecuter.java:88)
2021-12-19T10:55:01.349-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.session.BuildSessionState.run(BuildSessionState.java:69)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter.execute(BuildSessionLifecycleBuildActionExecuter.java:62)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.BuildSessionLifecycleBuildActionExecuter.execute(BuildSessionLifecycleBuildActionExecuter.java:41)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:36)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:25)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:63)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:31)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:58)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:42)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:47)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:31)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:65)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:39)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:29)
2021-12-19T10:55:01.350-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:35)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:78)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.create(ForwardClientInput.java:75)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.util.internal.Swapper.swap(Swapper.java:38)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:75)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:63)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:84)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:37)
2021-12-19T10:55:01.351-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:52)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin 'org.kordamp.gradle.enforcer'.
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:173)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:146)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.lambda$applyLegacyPlugin$2(DefaultPluginRequestApplicator.java:139)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:184)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 152 more
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Caused by: java.lang.ClassCastException: class org.gradle.api.internal.project.DefaultProject_Decorated cannot be cast to class org.gradle.api.initialization.Settings (org.gradle.api.internal.project.DefaultProject_Decorated and org.gradle.api.initialization.Settings are in unnamed module of loader org.gradle.internal.classloader.VisitableURLClassLoader @66a3ffec)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.kordamp.gradle.plugin.enforcer.BuildEnforcerPlugin.apply(BuildEnforcerPlugin.groovy)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.ImperativeOnlyPluginTarget.applyImperative(ImperativeOnlyPluginTarget.java:43)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.RuleBasedPluginTarget.applyImperative(RuleBasedPluginTarget.java:51)
2021-12-19T10:55:01.352-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.DefaultPluginManager.addPlugin(DefaultPluginManager.java:187)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.DefaultPluginManager.access$100(DefaultPluginManager.java:52)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.DefaultPluginManager$AddPluginBuildOperation.run(DefaultPluginManager.java:282)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.DefaultPluginManager.lambda$doApply$0(DefaultPluginManager.java:167)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.configuration.internal.DefaultUserCodeApplicationContext.apply(DefaultUserCodeApplicationContext.java:44)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:166)
2021-12-19T10:55:01.353-0800 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]   ... 155 more
rr-nick-tan commented 2 years ago

get the same issue on gradle 7.4.0 it's a blocker of adoption this enforcer plugin in our projects.

* What went wrong:
An exception occurred applying plugin request [id: 'org.kordamp.gradle.enforcer', version: '0.10.0']
> Failed to apply plugin 'org.kordamp.gradle.enforcer'.
   > org.gradle.api.internal.project.DefaultProject_Decorated cannot be cast to org.gradle.api.initialization.Settings
aalmiray commented 2 years ago

Are you applying the plugin at the right place? Note that there are 2 plugins https://kordamp.org/enforcer-gradle-plugin/#_applying_the_plugin

rr-nick-tan commented 2 years ago

@aalmiray , ah, right, I use it at project level, it works after use the 'org.kordamp.gradle.project-enforcer'. thx

bmuschko commented 1 year ago

Is this still an issue? I tried with Gradle 8.1.1 and enforcer plugin 0.13.0 and didn't see build failure or warning message.

aalmiray commented 1 year ago

@bmuschko That's strange. That would mean a warning that used to appear in Gradle 7 was removed while the deprecated behavior was kept in place. I think that's highly unlikely but also I have not read through the releases notes for 8 to check if the old behavior was deemed acceptable in the end.

bmuschko commented 1 year ago

@aalmiray My build script:

plugins {
    id 'org.kordamp.gradle.project-enforcer' version '0.13.0'
    id 'java'
}

repositories {
    mavenCentral()
}

dependencies {
    implementation 'commons-lang:commons-lang:2.4'
}

enforce {
    rule(enforcer.rules.BannedDependencies) { r ->
        // search only on compile and runtime classpaths
        r.configurations.addAll(['compileClasspath', 'runtimeClasspath'])
        // ignore all classes under the following package
        r.exclude('org.apache.maven')
        r.exclude('org.apache.maven:badArtifact')
        r.exclude('*:badArtifact')
        // only 1.0 of badArtifact is allowed
        r.include('org.apache.maven:badArtifact:1.0')
    }
}

Does this only happen with the --configuration-cache flag added?

aalmiray commented 1 year ago

Ah I see. project-enforcer should work fine as configurations will be resolved from the owning scope (the project) as the plugin is applied to the project. The problem arises when using the enforcer plugin which should be applied to Settings. In the latter case the invoking scope (Settings) differs from the owning scope (project) and the warning is raised.

bmuschko commented 1 year ago

Gotcha. Do you have plans to fix this issue?

aalmiray commented 1 year ago

I have not come up with a plan that would let the build enforcer to continue to work as it does today. Only a few of my builds use Gradle 7 and none use 8 thus I’m not in a rush to fix it. That might change by the end of 2023.

binkley commented 5 months ago

I'm not sure is my problem is related to this issue, or if I should file a separate issue. I'm using Gradle 8.x with version catalogs. I've setup the plugin cleanly to specify gradle/libs.versions.toml to 0.13.0, and build.gradle to pull in the plugin with a plugin "alias". Though the setup is different, Maven use of plugin works great as expected.

However, when I add an "enforce" block to build.gradle I syntax troubles. This fails spectacularly when uncommented:

// Do read the documentation on Enforcer to pick what makes sense to you:
// https://kordamp.org/enforcer-gradle-plugin/#_rule_dsl
/*
enforce {
     configure()
     rule()
}
*/

I feel I'm doing something wrong, however I'm following the documentation, and have tried several variations.

binkley commented 4 months ago

@aalmiray: Following up to see what status is on this issue.

@jwlibby and I work on a book for examples in the JVM world with Gradle and Maven on good practices in the build pipeline (local development, CI [ie, GitHub actions]). We have Enforcer for Maven working, and would like to show examples and documentation on using Enforcer in Gradle. (https://github.com/binkley/modern-java-practices -- example project; the writing is in the wiki pages.)

aalmiray commented 4 months ago

Status quo remains. This plugin works with Gradle 8.x despite the warnings issued when build-enforcer is applied to settings.gradle.

AFAICT the enforcer plugin when applied to a project (build.gradle) should work without warnings.

This being said, the use of build-enforcer may no longer be possible once Gradle 9 comes out, leaving only the use of enforcer.

binkley commented 4 months ago

@aalmiray Thank you for such good information! I'll unblock our story card on Enforcer for Gradle, and see how far we get, and keep an eye on what happens when Gradle 9 soon comes.

binkley commented 3 months ago

@aalmiray I have this working now, thank you! My goal:

Two observations:

  1. Docs not helpful for new people to get started. I found the integration tests for the plugin to see how to set things up. I found that:
    • I needed to put Enforcer into settings.gradle rather than build.gradle (which makes sense when I think it through)
    • I do not believe I have access to Gradle's version catalogs when in "settings" (I may be wrong), so fell back on older methods
    • A simple example project for folks to study would be helpful here
  2. Enforcer uses an older version of commons-lang3, and since I'm playing with classpath in settings.gradle, this impacts project dependencies. The older version broke DependencyCheck. I worked around this with an explicit "commons-lang3" version in classpath before referencing the Enforcer plugin.

Here is the settings.gradle I used:

buildscript {
    repositories {
        gradlePluginPortal()
        mavenCentral()
    }

    dependencies {
        classpath "org.apache.commons:commons-lang3:3.15.0"
        classpath "org.kordamp.gradle:enforcer-gradle-plugin:$enforcerPluginVersion"
    }
}

apply plugin: "org.kordamp.gradle.enforcer"

enforce {
    rule(enforcer.rules.RequireGradleVersion) { r ->
        r.version = "$gradleWrapperVersion" // Pulled in from "gradle.properties"
    }
}
aalmiray commented 3 months ago

Applying the plugin in settings.gradle requires using the build-enforcer plugin which will likely break with Gradle 9. However, this plugin gives you the Maven equivalent of being active all the time (when maven-enforcer-plugin is bound to the validate phase for example).

Applying the plugin in build.gradle requires using the enforcer plugin which should work with Gradle 9.

I don't have concrete experience with versions catalog but I venture I guess they are not available during evaluation of the settings.gradle script. Versions catalog are still hacky IMHO.

I suppose I could upgrade dependencies and release a newer version.

binkley commented 3 months ago

@aalmiray Cool. I'll see if I can do the same with build.gradle. I don't know what the restrictions are between "settings" and "build" that needs a diff plugin. My test cases were trivial, and worked, so there must be Rules or other things impacted between those two files.

When I get it working, I'll post my sample build.gradle changes here.

aalmiray commented 3 months ago

Plugins applied in settings.gradle target the Settings model while plugins applied to build.gradle target the Project model.

binkley commented 3 months ago

I like that explanation. It makes sense. Perhaps docs for Rules might suggest when they are better applied to Settings or to Project. For example, check Gradle or JVM versions makes more sense to me in Settings, but check for banned dependencies makes more sense in Project.

aalmiray commented 3 months ago

In its current state, yes I'd agree a distinction may be needed. But given that the build-enforcer plugin will be removed once Gradle 9.x stabilizes itself there's not much incentive to change the docs at the moment.

binkley commented 3 months ago

I'd be happy to contribute example snippets once the plugin project is ready. I want more projects able to adopt this with minimal friction.

aalmiray commented 3 months ago

Thank you. I'll post a release in the coming days.