How to debug gradle scripts

From time to time I have to “enhance” some gradle scripts (using Java related plugins), and I am not a “gradle specialist”, however, I understand well Java (never programmed in Groovy).

When trying to solve some “gradle/groovy” problem, I quickly (google-)get to Gradle JavaDocs pages.
The missing path which keeps me in trouble is the fact that I cannot relate the DSL expressions to the (Gradle) Java classes (for ex. No signature of method: static org.gradle.api.Project.files() is applicable for argument types: some-configurations.fileset ).

Is there some way to find this kind of info?, (other than read/understand the source of a plugin and/or Gradle)
(generic question, I will post an other message explaining my current problem).

A couple of things I’ve experienced. The Kotlin DSL is way way way easier to navigate because it’s much stricter on type safety and completion in the Intellij IDE.

Debugging builds in Intellij seems to just work, particularly with Kotlin. Breakpoint on Exception, step through code etc.

1 Like

Another option is good old printf:

  println it.metaClass.metaMethods*.name.sort().unique()
  println it.metaClass.methods*.name.sort().unique()
  println it.properties.entrySet()*.toString().sort().toString().replaceAll(", ","\n")
  println it.properties.toString()
  println it.dump()

or with logger.lyfecycle("var: {}", val)