Eclipse Buildship: Eclipse Plug-ins for Gradle 3.0.0

New And Noteworthy

Improved project synchronization

Buildship can now import projects even if their configuration is broken. In that case, the root project is imported as-is. Also, instead of using a custom error dialog, synchronization issues are shown via error markers. In case a location information is present in the error, Buildship assigns the error marker to the proper resource.

New APIs

Buildship 3.0 now offers a stable API for downstream dependencies manage Gradle projects programmatically. The API has the following components:

1) Project Synchronization API

This API lets Eclipse plugins programmatically import and synchronize Gradle projects with the workspace. To import a new project, clients need to declare a build configuration and use it to obtain a reference to the Gradle build and execute the project synchronization:

BuildConfiguration configuration = BuildConfiguration

    .forRootProjectDirectory(new File("path/to/project"))

    .overrideWorkspaceConfiguration(true)

    .gradleDistribution(GradleDistribution.forVersion("4.10.2"))

    .autoSync(true)

    .build();

GradleWorkspace workspace = GradleCore.getWorkspace();

GradleBuild newBuild = workspace.createBuild(configuration);

newBuild.synchronize(monitor);

For existing projects, the Gradle build reference can be returned via the getBuild() method:

IProject project = ...

GradleBuild existingBuild = workspace.getBuild(project).get();

existingBuild.synchronize(monitor);

2) Task Execution API

This API exposes all Tooling API functionality. Clients can enumerate and execute tasks, inspect the configuration of the current build and more. The provided connection instances are preconfigured to re-use Buildship resources (views, inputs, outputs, cancellation, etc.) for the Gradle invocations. Here's an example of how to execute a task:

IProject project = ...;

GradleWorkspace workspace = GradleCore.getWorkspace();

GradleBuild build = workspace.getBuild(project).get();

build.withConnection(connection -> connection.newBuild().forTasks("build").run(), monitor)

 

3) Project configurators

This is an extension point, via which external plugins can hook into Buildship synchronization logic and can provide additional configuration to each workspace projects. The required interface is quite simple:

public interface ProjectConfigurator {

    void init(InitializationContext context, IProgressMonitor monitor);

    void configure(ProjectContext context, IProgressMonitor monitor);

    void unconfigure(ProjectContext context, IProgressMonitor monitor);

}

The context objects provide access the current Gradle build, the project being configured and the helper objects to report configurator errors. 

Complete import configuration attributes 

Buildship 3.0 now offers all configuration options on all preference levels. Users can set the Gradle user home, JVM arguments and more for the entire workspace, for a specific Gradle build or for a single task execution.

 

Announcement: https://discuss.gradle.org/t/buildship-3-0-is-now-available

Update site: https://download.eclipse.org/buildship/updates/e410/releases/3.x/3.0.0.v20181205-1821

Release Date
Release Type
Major release (API breakage)
This release is part of Eclipse IDE 2018-12