How do you add JAR Libraries to your build?

Sincerely Gradle Community, I have a Problem concerning Dependency Management. In my Project ‘A’ I have two Java Classes, one of them is a GUI library with the name “” and the other one is a simple object called “”

I uploaded the JAR Gradle produces to an Artifactory and wanted to use the two Java Classes for my Project B

In my Project B I have the file “” where I wanted to use this library and the java Object via the Artifactory.

Project B’s Build Script looks like this:

apply plugin: ‘java’ apply plugin: ‘eclipse’

repositories {

mavenRepo urls: “” }

dependencies {

compile ‘A:A:1.0.0’

runtime “A:A:1.0.0@jar”

runtime group: ‘A’, name: ‘A’, version: ‘1.0.0’, ext: ‘jar’ }

But each time I try to build I get the error:

:compileJava /Users/Mike/Workspace/B/src/main/java/projectB/ cannot find symbol symbol : class Enemy location: class projectB.Main

static Enemy enemy;

^ /Users/Mike/Workspace/B/src/main/java/projectB/ cannot find symbol symbol : variable StdDraw location: class projectB.Main

StandardDraw.setCanvasSize( WIDTH, HEIGHT);

^ …

I am still practicing with Gradle and tried the code you use in your Documentation, but I think I 'm still mixing something up.

The directory of the JAR looks like this:



  • projectA

    • Enemy.class
    • StandardDraw.class

The Manifest of the JAR includes just this one line:

“Manifest-Version: 1.0”

Maybe I have to add something there?

I would appreciate any help!

Diagnostic stuff you can do:

  1. Run gradle dependencies for the project you have compilation errors. See if the required jars are resolved. 2. Make sure that the jar contains the class your project needs 3. You can print the classpath used by compilation, println sourceSets.main.compileClasspath in your build.gradle.

Hope that helps!

One thing that strikes me is this part:

dependencies {
   compile 'A:A:1.0.0'
   runtime "A:A:1.0.0@jar"
   runtime group: 'A', name: 'A', version: '1.0.0', ext: 'jar'

It should just be:

dependencies {
  compile 'A:A:1.0.0'

Is there any reason why you have declared the dependency three times?

Sorry, I already tried the three liner:

dependencies {

compile ‘A:A:1.0.0’ }

but it didn’t work so I just threw in all the stuff I found in your documentation, that’s the only reason why I declared it three times, but it was not intentionally. I already changed it like you recommended.

I tried your ListJars Task and modified it a bit:

task listJars << {

configurations.compile.each { File file -> println }

println sourceSets.main.compileClasspath } So strangely the output is:

Mike$ gradle list :listJars A-1.0.0.jar configuration ‘:compile’


Could something be wrong with the MetaInf of the Jar?

( I’m still using Milestone 3 (installed it with Homebrew))

Do you want to include project dependencies in the meta file? See the ‘Customization of MANIFEST.MF’ section in the user guide:

Thank you guys, there was something wrong with the Jar file! It’s working just fine now. Thank you very much for your help, much appreciated!