Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
783 views
in Technique[技术] by (71.8m points)

gradle - How do I refresh project dependencies using Buildship in Eclipse?

Eclipse Mars was recently released and I felt like trying it out. It listed tighter integration with Gradle as one of its features via Buildship.

With Luna I was using Gradle Integration for Eclipse (4.4) and I found this a lot easier to work with for what I was trying to do; I could add a Gradle "nature" to an existing project without needing to remove the project and re-import it as I did with Buildship, and it automatically put all dependencies that I declared in build.gradle within the project's classpath.

With Buildship, I didn't see any option to configure an existing project as a Gradle project and I couldn't find a way to make it include the dependencies I specified in the build script within the project's classpath.

I tried installing the original plugin (GIfE 4.4) for Eclipse Mars and after restarting Eclipse it automatically did all that for me again. What I'm wondering is if there's a way to do this all through Buildship alone because right now, although it all works, it's quite a funny setup. My project's dropdown menu looks like this:

Apart from looking a bit odd it is actually quite a nice setup, since it combines the automatic dependency management of GIfE with the ability to run Gradle tasks directly from Eclipse that Buildship provides.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Updating the dependencies that eclipse sees should then be as simple as:

right click on project -> gradle -> refresh all

Update in buildship 1.0.16

Currently you need to jump through the delete-and-import hoop the first time you use an existing gradle project with buildship. You can now use the Add Gradle Nature option:

 right click on project -> configure -> Add Gradle Nature

“Refresh Gradle Project” is now also shown when right-clicking on any .gradle file as well as in the context menu of the Gradle editor. source

See update below However sometimes you may find that when your project was imported, it didn't get the new Project and External Dependencies classpath entry which you would normally be able to see in your Project Properties -> Java Build Path -> Libraries If this is indeed missing, add the following to your project's .classpath file and all the gradle goodness should start working:

<classpathentry exported="true" kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>

Update in buildship 1.0.16

Gradle classpath container is restored if missing

When converting an existing Eclipse Java project to Gradle, the Gradle classpath container was missing. It is now always added when a project is a Java project.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...