Can't add dependencies to the project


(diredko) #1

Hello everyone) I’am just newbie to Gradle, and I’ve faced a problem when adding dependencies to my java project. I need to add WEKA and Guava libraries to my project. Both are available in the Maven Central Repository. Here is my gradle script code (the content of build.gradle)

apply plugin: 'java'
apply plugin: 'eclipse'
    repositories {
    mavenCentral()
}
  dependencies {
    runtime group: 'com.google.guava', name: 'guava', version: '17.0'
    runtime group: 'nz.ac.waikato.cms.weka', name: 'weka-stable', version: '3.6.6'
}

When I’am running

gradle build

from CMD, I’am getting a lot of error messages, inferring that neither of those libraries were added to project. Surely the build fails. I don’t know what to do. Thanks in advance)


(Peter Niederwieser) #2

You need to make them ‘compile’ dependencies.


(diredko) #3

Thank You for reply)) But in the gradle book it says that

runtime

task depends on the

compile

one. Can You please tell me what is special about

runtime

, that makes my build script fail.


(Peter Niederwieser) #4

The fact that ‘runtime’ extends from ‘compile’ means that every compile dependency is also a runtime dependency. The inverse isn’t true, hence if you only make these ‘runtime’ dependencies yet reference them from your Java code, compilation will fail.


(diredko) #5

Thank you very much))