How do I refresh project dependencies using Buildship in Eclipse?

前端 未结 5 1328
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-24 05:51

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 usi

相关标签:
5条回答
  • 2020-12-24 06:33

    I agree Buildship is a bit of a disaster. The documentation is extremely sparse with limited examples and minimal user guide. You would think documenting the transition from Gradle Integration for Eclipse (4.4) would be a no-brainer but I guess not. I also don't have a single clue how to use Buildship other than that I ran some tasks manually and it put fully qualified paths in my .classpath file. That's ridiculous considering many projects are shared through change control systems.

    0 讨论(0)
  • 2020-12-24 06:39

    Incase for anyone, if you are not getting the

    right click on project -> gradle

    link after doing the steps mentioned in @PaulAdamson answer. Try this.

    1. In your build.gradle add apply plugin 'eclipse';

    2. Close the project in eclispe.

    3. Run the gradle build from command line and then reopen the project in eclipse.

      Now the gradle link should be available on right click.

    0 讨论(0)
  • 2020-12-24 06:42

    Currently there is no "Convert to Gradle project" implemented in Buildship. However, if you remove the project and reimport it using the Gradle import wizard you should see the same exact project with the proper nature and the classpath container.

    On top of that, if you have a Gradle project in your workspace and update the dependencies in the build script, you can refresh the classpath container by right-clicking on the project and select Gradle > Refresh projects.

    A similar problem you were facing was discussed in the Gradle forums: discuss.gradle.org/t/adding-dependencies-to-projects/10415.

    We also have a bug dedicated for this feature request: bugs.eclipse.org/bugs/show_bug.cgi?id=465355. Please vote for it and share your thoughts there too.

    Regarding to the documentation: It's true that we haven't provided an official documentation for the central Eclipse help system, but there are some resources explaining the current functionality:

    • The user documentation on GitHub
    • A Vogella tutorial
    0 讨论(0)
  • 2020-12-24 06:42

    If you have already converted Java project to Gradle project but [RIGHT-CLICK]+Import (Then importing 'Existing Gradle Project') then your project should be of Gradle Nature.

    If the project is of Gradle Nature then in .classpath file you will not see all the .jar dependencies as you see in normal java project, Instead you will see a single entry of:

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

    To refresh dependencies you should do following:

    [RIGHT-CLICK] + Gradle + Refresh Gradle Project

    This will fix all complication issues.

    0 讨论(0)
  • 2020-12-24 06:58

    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.

    0 讨论(0)
提交回复
热议问题