Useful debugging information from Groovy and Gradle scripts?

Hi,

I'm attempting to debug a Gradle script I'm working on.

class DependencyOverride implements Plugin<Project> {

    void apply(Project project) {

        def overrides = new Properties()

        new File('override.properties').withInputStream {

            stream -> overrides.load(stream)

        }

        project.configurations.all {

            resolutionStrategy {

                eachDependency { DependencyResolveDetails details ->

                    println(details.target.toString())

                    if(overrides.containsKey(details.requested.name)) {

                        String projectName = overrides.getProperty(details.requested.name)

                        println("Overridden dependency: " + details.requested.name + " -> " + projectName)

                        details.useTarget(project(":" + projectName))

                    }

                }

            }

        }

    }

}

I launch the script in debug mode and it stops at a breakpoint I've set on the line which reads "println(details.target.toString())". All I want to do is inspect the contents of the "details" object.

At this point the debuggers Frames view shows a load of Gradle runtime classes (see below) and the Variables view shows some mega structure of type "build_5o89rt9u7uoavs2o5gr08oa601".

Now, I really don't care what the gradle runtime is doing or what information about my script it has in memory - I'd like to see the frames for my Gradle script (i.e. in a closure inside the apply() method of DependencyOverride), and I'd like to see the variables I've just defined in my script (e.g. project, details and overrides).

Is that possible?


main@1, prio=5, in group 'main', status: 'RUNNING'
   at build_5o89rt9u7uoavs2o5gr08oa601.run(D:\testApp\build.gradle:124)
   at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
   at org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
   at org.gradle.configuration.BuildScriptProcessor.execute(BuildScriptProcessor.java:36)
   at org.gradle.configuration.BuildScriptProcessor.execute(BuildScriptProcessor.java:23)
   at org.gradle.configuration.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
   at org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
   at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:465)
   at org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:76)
   at org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
   at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
   at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
   at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
   at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
   at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
   at org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
   at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
   at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
   at org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
   at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
   at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
   at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
   at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
   at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
   at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
   at org.gradle.launcher.Main.doAction(Main.java:48)
   at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
   at org.gradle.launcher.Main.main(Main.java:39)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethodAccessorImpl.java:-1)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:597)
   at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
   at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
   at org.gradle.launcher.GradleMain.main(GradleMain.java:26)



4 comments

This is with Intellij IDEA 12.1.4 and Gradle 1.6 by the way.

0

Hi Richard,

The ide doesn't offer such a facility at the moment.

Denis

0

Thanks for your reply Dennis. It is something that is planned for a future release?

0

The task is interesting but I'm afraid you can't expect it at least for v.13 - it's more important to provide gradle scripts editing support.

IJ v.14 features set hasn't been discussed yet.

Denis

0

Please sign in to leave a comment.