Reputation: 313
I am learning to create a java ee web application. In intellij idea I created a project using the project wizard: Java Enterprise -> Web Application. Then I created a build file.gradle in the project root, and call the gradle init
, gradle build
in the terminal. Here is the build file.gradle
apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'idea'
repositories {
jcenter()
mavenCentral()
}
sourceCompatibility = 1.5
dependencies {
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
testCompile 'junit:junit:4.12'
}
When I add a dependency and do gradle build, they are not loaded into the project. For example, the Gson library is not available in the code. How to tell Gradle to download the libraries so I could use them? What i'm doing wrong?
Upvotes: 1
Views: 1166
Reputation: 678
When your run gradle build does it shows the dependency downloading, if so then the dependency has downloaded but not avaialable in intellij Quick fix is to close the project
Upvotes: 1
Reputation: 17055
Your project is not backed by gradle. The easiest way for me to fix this is to :
(x) Event log
(the digit in parentheses being the number of events raised);Event log
;Import Gradle project
;Upvotes: 2
Reputation: 33436
IntelliJ's Gradle integration does not automatically reflect changes you make in your build script. You will have manually initiate the synchronization between build script and IntelliJ project.
Upvotes: 2