DenLilleMand
DenLilleMand

Reputation: 4560

Gradlew doesn't add dependencies to my external libraries(class path) in IDEA 16.2

tl;dr; adding adding dependencies to build.gradle downloads it fine but doesn't add it to the classpath/external libraries in idea.

Hi guys

Im new to developing webapps in java, and im trying to depend on a few jars on mvnrepository.com, the only time the dependencies are downloaded into the external libraries and added to the classpath is when i import the project as a gradle project, as in, each time i have a project up and running and i add a new dependency i would have to import the whole project into intellij again.

my build.gradle file looks like this:

group 'project_name'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'idea'

sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
// https://mvnrepository.com/artifact/com.google.inject/guice
 compile group: 'com.google.inject', name: 'guice', version: '3.0'
// https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-core
 compile group: 'org.apache.tomcat.embed', name: 'tomcat-embed-core', version: '9.0.0.M9'
// https://mvnrepository.com/artifact/com.sun.jersey/jersey-core
 compile group: 'com.sun.jersey', name: 'jersey-core', version: '1.19.1'
// https://mvnrepository.com/artifact/com.sun.jersey/jersey-json
 compile group: 'com.sun.jersey', name: 'jersey-json', version: '1.19.1'

// https://mvnrepository.com/artifact/org.glassfish.jersey.core/jersey-client
 compile group: 'org.glassfish.jersey.core', name: 'jersey-client', version: '2.23.2'

// https://mvnrepository.com/artifact/com.sun.jersey/jersey-servlet
 compile group: 'com.sun.jersey', name: 'jersey-servlet', version: '1.19.1'

// https://mvnrepository.com/artifact/com.sun.jersey/jersey-server
 compile group: 'com.sun.jersey', name: 'jersey-server', version: '1.19.1'




 testCompile group: 'junit', name: 'junit', version: '4.11'
}



task wrapper(type: Wrapper) {
    gradleVersion = '2.5'
}

When i add a new dependency to the list, and run ./gradlew build, with or without the --refresh-dependencies option it does download the new dependencies but it doesn't add the downloaded files to the external libraries/classpath so i can't import them into the java code. I saw a question similar to this one, where they accepted answers like running:

./gradlew idea

In my case this doesn't help at all, it just adds some autogenerated files in the directory with no clear difference to behavior.

Then they accepted importing the project as a gradle project aswell, which i have done - which works, but adding new dependencies doesn't work.

FYI I am using the gradle 2.5 wrapper and IDEA community 16.2

Upvotes: 0

Views: 2511

Answers (1)

DenLilleMand
DenLilleMand

Reputation: 4560

Okay. I solved/figured it out, Apparently it didn't help to just run build, inside of intellij i had to go to View --> Tool Windows --> Gradle, it then opens the gradle window, where i could click the refresh button, which downloads the dependencies.

Thanks to anyone who looked it over :)

Upvotes: 4

Related Questions