0

Environment: Gradle <= 2.5, STS <= 3.7 or Eclipse version <= Luna

It is annoying to work with Gradle and Eclipse (or STS) that you have to keep performing "Gradle Refresh" or "Gradle RefreshAll" numerous time in the development workflow.

Here are the scenarios when you MUST perform Gradle Refresh OR remove the projects and "re-import/aka Build Model".

1) You perform Git pull and receive changes to dependencies. Many times the changes coming in are compile time dependencies or testRuntime dependencies.

In these cases you are confronted with nasty compilation errors. Which are gone ONLY after you perform "Gradle Refresh All/Gradle Refresh Dependency".

2) You add new dependencies yourself to your build.gradle during development and you need your code to

3) JAXB Plugins for schema compilation - Gradle JAXB Plugin- when used you must call xjc before the source folders are created. I got some help using compileJava.dependsOn xjcas per here but still leaves far from desired.

If a developer changes the xsd and Java sources that references the JAXB classes that the xjc would generate. You now must first call xjc or compileJava and then you MUST call Gradle Refresh Sources by right clicking on the schema project.

Another more than year old thread showing same frustration as me.

  1. I would like to know if anyone encountered these problems or I am the only one and how hey are dealing with.
  2. How to capture gradle eclipse events so that necessary action can be can performed ? OR What Gradle task gets invoked by the gradle-eclipse plugin ?
Community
  • 1
  • 1
bhantol
  • 9,368
  • 7
  • 44
  • 81
  • 1
    There is a relatively new integration for Eclipse being implemented at the moment called Buildship. And I think they would be very interested in this feedback and how this could be done with the new tooling. Their forum is at: https://discuss.gradle.org/c/help-discuss/buildship, the project page is at: http://www.eclipse.org/buildship. Hope this helps! – Martin Lippert Aug 27 '15 at 07:00
  • I will checkout buildship – bhantol Aug 27 '15 at 22:17

2 Answers2

1

This probably doesn't handle all your cases, but there is an option you can enable to "Automatically Refresh Dependencies" when .gradle file changes.

enter image description here

Some things to know about the limitations of this feature:

  • refreshes 'Gradle Dependencies' in the 'managed' container only. So 'Dependency management has to be enabled for it to work'.

  • doesn't execute tasks, it only refreshes the dependencies in the container and nothing else.

Kris
  • 3,898
  • 1
  • 23
  • 32
  • I understand you'd like this to be more automatic, but the trouble is that the 'triggers' for automation aren't always there (how can the tools know when to do a 'automatic' refresh, and doing lots of needless refreshes, involving the execution of lengthy/heavy background tasks could be even more annoying. – Kris Aug 27 '15 at 15:45
  • Maven m2e has maven lifecycles. org.eclipse.m2e and plugins takes care of these – bhantol Aug 27 '15 at 22:26
0

Answer to slightly different aspect of your question. You asked about "What Gradle task gets invoked by the gradle-eclipse plugin". You do have this under control. When you import the project using the wizard, you can specify tasks to execute before and after import. These same tasks are also executed upon performing a 'Refresh All'.

enter image description here

Kris
  • 3,898
  • 1
  • 23
  • 32
  • This doesn't solve the problem because here is upfront knowledge of what tasks must be executed for everything to show up well and intact. Not easy way to share the configuration across the team. Honestly any configuration out of Gradle build files is a no no. – bhantol Aug 27 '15 at 22:21