Update my gradle dependencies in eclipse
EclipseGradleEclipse Problem Overview
I have a simple gradle project in my eclipse. I update the build.gradle to include a few apache http jars...
dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile 'org.apache.httpcomponents:httpclient:4.2.3'
compile "org.apache.httpcomponents:httpmime:4.2.3"
testCompile group: 'junit', name: 'junit', version: '4.+'
}
However in my code, where I reference some Apache HTTP stuff I get:
The import org.apache.http cannot be resolved
Any tips on what I need to do to make Eclipse see the new dependencies in my build.gradle?
I tried doing a clean but that does not work. My gradle plugin is:
Gradle IDE 3.3.0.201307040643-RELEASE org.springsource.ide.eclipse.gradle.feature.feature.group GoPivotal, Inc.
Eclipse Solutions
Solution 1 - Eclipse
You have to select "Refresh Dependencies" in the "Gradle" context menu that appears when you right-click the project in the Package Explorer.
Solution 2 - Eclipse
Follow those steps to update Gradle project in Eclipse:
- First, please check you have include eclipse gradle plugin.
apply plugin : 'eclipse'
- Then go to your project directory in Terminal. Type
gradle clean
and thengradle eclipse
. - Then go to project in eclipse and refresh the project (Go to Project Explorer, select root of the project and hit F5 to refresh, or right click and select refresh in context menu).
Solution 3 - Eclipse
Looking at the Eclipse plugin docs I found some useful tasks that rebuilt my classpath and updated the required dependencies.
- First try
gradle cleanEclipse
to clean the Eclipse configuration completely. If this doesn;t work you may try more specific tasks: gradle cleanEclipseProject
to remove the .project filegradle cleanEclipseClasspath
to empty the project's classpath- Finally
gradle eclipse
to rebuild the Eclipse configuration
Solution 4 - Eclipse
You have to make sure that "Dependency Management" is enabled. To do so, right click on the project name, go to the "Gradle" sub-menu and click on "Enable Dependency Management". Once you do that, Gradle should load all the dependencies for you.
Solution 5 - Eclipse
I tried all above options but was still getting error, in my case issue was I have not setup gradle installation directory in eclipse, following worked:
> eclipse -> Window -> Preferences -> Gradle -> "Select Local > Installation Directory" > > Click on Browse button and provide path.
Even though question is answered, thought to share in case somebody else is facing similar issue.
Cheers !
Solution 6 - Eclipse
In my case, I solved weird issues in Spring Tools Suite (essentially Eclipse) after I tried to upgrade Spring Boot and the changes didn't seem to be taking effect.
Right click on your project -> Gradle -> Refresh Gradle Project