Skip to content

Commit c51c0fa

Browse files
committed
Align with Buildship 3.0's API
Previously, the plugin was incorrectly using Buildship 3.1 API while claiming compatibility with 3.0. This could lead to NoSuchMethodErrors at runtime. This commit updates the code to use Buildship 3.0 API. It also updates the manifest to constrain the version of the org.eclipse.buildship.core bundle to 3.0.x versions. Lastly, the Eclipse repository that is used has been rolled back to 2019-03 as 2019-06 bundles Buildship 3.1. Closes gh-121
1 parent 1a563b8 commit c51c0fa

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

Diff for: pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
<main.basedir>${basedir}</main.basedir>
3232
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
3333
<java.version>1.8</java.version>
34-
<eclipse.repository>https://download.eclipse.org/releases/2019-06/201906191000</eclipse.repository>
34+
<eclipse.repository>https://download.eclipse.org/releases/2019-03/201903201000</eclipse.repository>
3535
<eclipse.checkstyle.repository>https://dl.bintray.com/eclipse-cs/eclipse-cs/8.18.0</eclipse.checkstyle.repository>
3636
<tycho.disableP2Mirrors>true</tycho.disableP2Mirrors>
3737
<ant.version>1.8.1</ant.version>

Diff for: spring-javaformat-eclipse/io.spring.javaformat.eclipse/META-INF/MANIFEST.MF

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Require-Bundle: org.eclipse.ui,
1616
org.eclipse.m2e.jdt;resolution:=optional,
1717
org.eclipse.m2e.core;resolution:=optional,
1818
org.eclipse.m2e.maven.runtime;resolution:=optional,
19-
org.eclipse.buildship.core;bundle-version="3.0.0";resolution:=optional,
19+
org.eclipse.buildship.core;bundle-version="[3.0.0,3.1.0)";resolution:=optional,
2020
net.sf.eclipsecs.core;bundle-version="8.18.0";resolution:=optional
2121
Bundle-ClassPath: .,
2222
lib/spring-javaformat-formatter-eclipse.jar,

Diff for: spring-javaformat-eclipse/io.spring.javaformat.eclipse/src/io/spring/javaformat/eclipse/gradle/RefreshProjectsSettingsJob.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,10 @@
2626

2727
import org.eclipse.buildship.core.GradleBuild;
2828
import org.eclipse.buildship.core.internal.CorePlugin;
29+
import org.eclipse.buildship.core.internal.workspace.FetchStrategy;
2930
import org.eclipse.buildship.core.internal.workspace.InternalGradleBuild;
3031
import org.eclipse.buildship.core.internal.workspace.InternalGradleWorkspace;
32+
import org.eclipse.buildship.core.internal.workspace.ModelProviderUtil;
3133
import org.eclipse.core.resources.IProject;
3234
import org.eclipse.core.resources.ResourcesPlugin;
3335
import org.eclipse.core.runtime.CoreException;
@@ -97,15 +99,15 @@ private void configureProjects(IProgressMonitor monitor) throws CoreException, I
9799

98100
private void configureProject(IProject project, InternalGradleBuild build, IProgressMonitor monitor)
99101
throws CoreException, IOException {
100-
Collection<EclipseProject> projects = build.getModelProvider()
101-
.fetchEclipseProjectAndRunSyncTasks(this.tokenSource, monitor);
102+
Set<EclipseProject> projects = ModelProviderUtil.fetchAllEclipseProjects(build, this.tokenSource,
103+
FetchStrategy.FORCE_RELOAD, monitor);
102104
if (hasSpringFormatPlugin(projects)) {
103105
ProjectSettingsFilesLocator locator = new ProjectSettingsFilesLocator(getSearchFolders(projects));
104106
locator.locateSettingsFiles().applyToProject(project, monitor);
105107
}
106108
}
107109

108-
private boolean hasSpringFormatPlugin(Collection<EclipseProject> projects) {
110+
private boolean hasSpringFormatPlugin(Set<EclipseProject> projects) {
109111
for (EclipseProject project : projects) {
110112
for (GradleTask task : project.getGradleProject().getTasks()) {
111113
if (isSpringFormatPlugin(task)) {
@@ -120,7 +122,7 @@ private boolean isSpringFormatPlugin(GradleTask task) {
120122
return TASK_NAME.equals(task.getName());
121123
}
122124

123-
private Set<File> getSearchFolders(Collection<EclipseProject> projects) {
125+
private Set<File> getSearchFolders(Set<EclipseProject> projects) {
124126
Set<File> searchFolders = new LinkedHashSet<>();
125127
for (EclipseProject project : projects) {
126128
while (project != null) {

0 commit comments

Comments
 (0)