How to invoke a static java method from gradle script


Can some one please let me know how do I invoke a local method defined within a class from gradle script? I see that using javaexec we always need to provide the main() method only.

Thanks Srini

The script is just groovy, so you can invoke it directly. The question is where does your class reside? If it’s in an external jar, you’ll need to add it to the classpath via a buildscript closure:

buildscript {
  dependencies {
    classpath ...

What goes in the classpath declaration depends on where the class is coming from. See the user guide section on declaring dependencies for various options.