Buildship 3.1 is now available

We are happy to announce that Buildship 3.1 has just been released. The highlight of this release is the “Run tasks upon synchronization” story, which is the highest voted issue in the project’s bug tracker. The full list of changes is available here.

Run tasks on synchronization

Since Gradle 5.4, projects can declare an arbitrary set of tasks in the eclipse.synchronizationTasks configuration. Once configured, Gradle will automatically execute those tasks every time the user synchronizes workspace with the build.

plugins {
    id 'eclipse'
}

task foo {
    doLast {
        println 'foo'
    }
}

eclipse {
    synchronizationTasks foo
}

Run tasks on Eclipse build

Similarly to the feature above, tasks can be configured to execute every time the Eclipse auto-build is triggered:

plugins {
    id 'eclipse'
}

task foo {
    doLast {
        println 'foo'
    }
}

eclipse {
    autoBuildTasks foo
}

Installation

Buildship 3.1 can be installed from the Eclipse Marketplace or by using the usual update sites.

Update: we published a blog post that elaborates on the task execution: https://blog.gradle.org/buildship-sync-task-exec

Hi @donat,

I got the synchronizationTasks feature to work in my project. That’s going to be a big win for our dev team.

WRT the autoBuildTasks feature, can you explain a bit about what the phrase “every time the Eclipse auto-build” means? I used to know a bit more about the Eclipse builder architecture than I remember now, but IIRC the builder runs only relatively infrequently and, for example, not when I’m just editing Java source files. And I know it runs when you do a “Project > Clean”. But other than that, I’m hazy on when it runs.

Like other projects, our Gradle build generates Java source files. The inputs into that source generation process are themselves Java source files. Ideally, whenever one edits and saves one of those input files in Eclipse, the Gradle task that does the generation process would run. However, even when I added the appropriate autoBuildTasks directive, that doesn’t happen. So either I’m misunderstanding the extent of the feature’s capability, or I’m doing something wrong.

Any suggestions?

Thanks.

Nat

Actually, it should happen quite frequently. Buildship launches autoBuildTasks every time a resource changes within the project and Project > Build Automatically Eclipse menu item is enabled. Did you turn off the option?

For whatever reason my use of autoBuildTasks appears to be resulting in exactly nothing ever happening.

I do have Project > Build Automatically enabled. As an experiment, I turned it off and then did Project > Build on the project that uses autoBuildTasks. Still the Gradle build task didn’t run.

Is there some logging or other mechanisms I can enable to see what might be going on?

You can debug the plugin to see why the execution doesn’t reach this line: https://github.com/eclipse/buildship/blob/master/org.eclipse.buildship.core/src/main/java/org/eclipse/buildship/core/internal/configuration/DefaultGradleProjectBuilder.java#L46

It is a very good news for me.
Thanks

How many changes are taken for this?

The full list of changes which you gave in your thread closed nine days ago. So how can I make it sure?

I’m not 100% sure what you mean here. Can you please be more specific?