Debugging Plugins from the Portal

I’ve created a plugin for VI users that integrates Java syntax checking (using Syntastic) into gradle projects. It automatically generates the classpath file from any JavaPlugin’s compileClasspath. The plugin has been published but only works outside of the Plugin DSL.

I’d like to debug the plugin but I don’t know if there is a way to force the plugin mechanism to pull a plugin published locally. (During normal development if I am testing a plugin in multiple projects I just pTML and grab from maven local.)

Hi Kevin

No means to change the plugins block to look at maven local I’m afraid.

I take it that if you have mavenLocal() in your buildscript { repositories { } } block, you dont you see the issue? What doesnt work
when you try via the plugins { } block? Do you see an error? If so
please post any stacktraces here.

Best Regards

Kon

Kevin O’Neal wrote:

Hey Kon,

Thanks for the response.

I did a bit of testing and found out that if I use gradle 2.3 or earlier, then my plugin works fine. Later versions 2.4, 2.5 and 2.6 throw the following error:

C:\Users\kevin.oneal\projects\temp>gradlew clean build

FAILURE: Build failed with an exception.

* Where:
Build file 'C:\Users\kevin.oneal\projects\temp\build.gradle' line: 12

* What went wrong:
An exception occurred applying plugin request [id: 'java']
> Failed to apply plugin [class 'org.gradle.language.base.plugins.LifecycleBasePlugin']
   > Cannot create 'tasks.clean' using creation rule 'tasks.addPlaceholderAction(clean)' as model element 'tasks' is no longer mutable.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 0.97 secs

The stacktrace is:

* Exception is:
org.gradle.api.plugins.InvalidPluginException: An exception occurred applying plugin request [id: 'java']
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:172)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugins(DefaultPluginRequestApplicator.java:136)
        at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:128)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:39)
        at org.gradle.configuration.project.BuildScriptProcessor.execute(BuildScriptProcessor.java:26)
        at org.gradle.configuration.project.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
        at org.gradle.configuration.project.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:487)
        at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:85)
        at org.gradle.execution.TaskPathProjectEvaluator.configureHierarchy(TaskPathProjectEvaluator.java:42)
        at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:35)
        at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:129)
        at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:106)
        at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:86)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:90)
        at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
        at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
        at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
        at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:49)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
        at org.gradle.util.Swapper.swap(Swapper.java:38)
        at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.health.DaemonHealthTracker.execute(DaemonHealthTracker.java:47)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:66)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:71)
        at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.health.HintGCAfterBuild.execute(HintGCAfterBuild.java:41)
        at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
        at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
        at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:246)
        at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
        at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.internal.plugins.PluginApplicationException: Failed to apply plugin [class 'org.gradle.language.base.plugins.LifecycleBasePlugin']
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:160)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:116)
        at org.gradle.api.plugins.BasePlugin.apply(BasePlugin.java:70)
        at org.gradle.api.plugins.BasePlugin.apply(BasePlugin.java:52)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
        at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:116)
        at org.gradle.api.plugins.JavaBasePlugin.apply(JavaBasePlugin.java:71)
        at org.gradle.api.plugins.JavaBasePlugin.apply(JavaBasePlugin.java:54)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
        at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:116)
        at org.gradle.api.plugins.JavaPlugin.apply(JavaPlugin.java:64)
        at org.gradle.api.plugins.JavaPlugin.apply(JavaPlugin.java:47)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
        at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        at org.gradle.api.internal.plugins.DefaultPluginManager.apply(DefaultPluginManager.java:104)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator$6.run(DefaultPluginRequestApplicator.java:138)
        at org.gradle.plugin.use.internal.DefaultPluginRequestApplicator.applyPlugin(DefaultPluginRequestApplicator.java:160)
        ... 46 more
Caused by: java.lang.IllegalStateException: Cannot create 'tasks.clean' using creation rule 'tasks.addPlaceholderAction(clean)' as model element 'tasks' is no longer mutable.
        at org.gradle.model.internal.registry.DefaultModelRegistry.registerNode(DefaultModelRegistry.java:123)
        at org.gradle.model.internal.registry.DefaultModelRegistry.access$500(DefaultModelRegistry.java:49)
        at org.gradle.model.internal.registry.DefaultModelRegistry$ModelElementNode.addLink(DefaultModelRegistry.java:991)
        at org.gradle.api.internal.tasks.DefaultTaskContainer.addPlaceholderModelLink(DefaultTaskContainer.java:247)
        at org.gradle.api.internal.tasks.DefaultTaskContainer.addPlaceholderAction(DefaultTaskContainer.java:239)
        at org.gradle.language.base.plugins.LifecycleBasePlugin.addClean(LifecycleBasePlugin.java:56)
        at org.gradle.language.base.plugins.LifecycleBasePlugin.apply(LifecycleBasePlugin.java:47)
        at org.gradle.language.base.plugins.LifecycleBasePlugin.apply(LifecycleBasePlugin.java:34)
        at org.gradle.api.internal.plugins.ImperativeOnlyPluginApplicator.applyImperative(ImperativeOnlyPluginApplicator.java:35)
        at org.gradle.api.internal.plugins.RuleBasedPluginApplicator.applyImperative(RuleBasedPluginApplicator.java:43)
        at org.gradle.api.internal.plugins.DefaultPluginManager.doApply(DefaultPluginManager.java:144)
        ... 67 more

I feel as though this has something to do with the differences of how the java plugin works in the new mechanism, but am at a loss as how to figure out what my plugin is doing wrong.

Thanks for the stacktrace. Will follow up internally and let you know
-Kon

Kevin, I believe you are running into GRADLE-3321. Since the “lifecycle” tasks (clean, build, etc) are created via rules in Gradle versions 2.4 and later, you often have to indirectly reference them when you attempt to mutate them. As a workaround you can try doing this:

rootProject.tasks.matching { it.name == 'build' }.all { dependsOn TASK_NAME }
1 Like

Thanks @kon and @mark_vieira! This fixed the problem!!