title: Use Java class in Gradle build script
body: <p>I have a Gradle build script which has to instantiate a Java class in a Task and call a method on the created object. Currently, I have the following:</p>
  
  <pre><code>apply plugin: 'java'
  
  dependencies {
      compile files("libs/some.library.jar")
  }
  
  task A &lt;&lt; {
  
      def obj = new some.library.TestClass()
      obj.doSomething()
  
  }
  </code></pre>
  
  <p>The problem is that the class <code>some.library.TestClass()</code> is not found. I read <a href="https://stackoverflow.com/questions/21905608/using-groovy-classes-within-gradle-build">this article</a> about how to use Groovy classes in Gradle, but I need my Java class to come from an external JAR file. How can I add a jar to the build source? It seems that the <code>dependencies</code> block doesnt do what I expect it to do. Can anyone give me a hint in the right direction?</p>