title: How to call custom Java method from Gradle
body: <p>Please, what is the most convenient way how to call a Java method within Gradle build script? This method contain functionality I want to use during build; a piece of functionality too complex to be a in-script Groovy method but not enough to command full custom Gradle plugin.</p>
  
  <p>My question is not about running a Java application from Gradle. That would involve forking JVM, and there is no simple way how to publish output back to Gradle and I need that output.</p>
  
  <p>Initially I had my code in src/main/java but it has to be compiled early on to be callable from within Gradle build script.</p>
  
  <p>Then I tried to move the build helper class to a submodule project, a one class submodule, hoping that the submodule would be builded before the main build script is called; in there I put:</p>
  
  <pre><code> buildscript {
      dependencies {
         classpath 'this.project:build-helper:1.0-SNAPSHOT'
      }
   }
  </code></pre>
  
  <p>But the <code>build-helper</code> subproject is clearly not build first, despite having in in <code>settings.gradle</code> as first and build fails as the dependency is not recognised. It seems buildscript is evaluated before submodules are built, before anything else. D'oh!</p>