Skip to content

Commit

Permalink
drop support for older than, and require Eclipse 2022-12
Browse files Browse the repository at this point in the history
that is, require org.eclipse.core.resources version >= 3.18.100
  • Loading branch information
haubi committed Mar 7, 2024
1 parent 6720d9c commit 1fd61a4
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 182 deletions.
2 changes: 1 addition & 1 deletion bundles/org.eclipse.tea.core.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Require-Bundle: org.eclipse.core.runtime,
org.eclipse.e4.core.contexts,
org.eclipse.e4.core.di,
org.eclipse.e4.core.services,
org.eclipse.core.resources,
org.eclipse.core.resources;bundle-version="3.18.100",
org.eclipse.ui.forms,
org.eclipse.e4.ui.workbench,
org.eclipse.emf.ecore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@
import org.eclipse.tea.core.services.TaskingLifeCycleListener;
import org.eclipse.tea.core.services.TaskingLog;
import org.eclipse.ui.PlatformUI;
import org.osgi.framework.Bundle;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.Version;
import org.osgi.service.component.annotations.Component;

/**
Expand All @@ -60,35 +57,8 @@ public class AutoBuildDeactivator implements TaskingLifeCycleListener {
private boolean autoBuildOriginalState = false;
private static AtomicInteger nestCount = new AtomicInteger(0);

// Suppressing the Auto Build with brute force after the Full Build is
// necessary for larger applications, to avoid Auto Build iterations for
// minutes right after we know everything was built from scratch.
// But since Eclipse 2022-12, suppressing the Auto Build does more harm than
// good. In particular, it may lead to this error when closing Eclipse:
// "Unable to save workspace - Trees in ambiguous order (Bug 352867)"
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=352867
// Fortunately, it turns out that the Auto Build does not run for minutes
// any more, when enabled right after the Full Build. On the other hand,
// suppressing the Auto Build is not known to fail up to Eclipse 2022-06,
// and also was not reported to fail so far with Eclipse 2022-09.
// Being conservative, we continue to suppress the Auto Build before
// Eclipse 2022-12, based on the OSGi version of org.eclipse.core.resources:
// Eclipse 2022-06: org.eclipse.core.resources:3.17.0
// Eclipse 2022-09: org.eclipse.core.resources:3.18.0
// Eclipse 2022-12: org.eclipse.core.resources:3.18.100
private static final boolean haveGoodAutoBuild = getHaveGoodAutoBuild(new Version(3, 18, 100));
private static final Map<IProject, ElementTree> suppressedProjects = new HashMap<>();

private static boolean getHaveGoodAutoBuild(Version worksSince) {
Bundle bundle = FrameworkUtil.getBundle(ResourcesPlugin.class);
if (bundle != null && "org.eclipse.core.resources".equals(bundle.getSymbolicName())) {
return bundle.getVersion().compareTo(worksSince) >= 0;
}
// Something completely wrong, or bundle has been renamed:
// Assume this was done after suppressing Auto Build became obsolete.
return true;
}

public Workspace getWorkspace() {
return ((Workspace) ResourcesPlugin.getWorkspace());
}
Expand Down Expand Up @@ -136,59 +106,6 @@ public synchronized void finish(TaskExecutionContext context, TaskingLog log, Mu
}
}

/**
* Allows to suppress a build of the specified projects. This has two
* effects. After finishing the currently running task chain, auto build
* will be enabled and forced by Eclipse - at this point, auto build is
* immediately cancelled and the force flag is reset. After that, the "last
* built" state of each of the given projects is updated with the current
* state.
*
* @param project
* the project to assume to be cleanly built.
*/
public static void avoidBuild(IProject project) {
if (haveGoodAutoBuild) {
return;
}
synchronized (suppressedProjects) {
ElementTree currentTree = null;
try {
IBuildConfiguration bc = project.getActiveBuildConfig();
int highestStamp = 0;
for (ICommand c : ((Project) project).internalGetDescription().getBuildSpec(false)) {
IncrementalProjectBuilder builder = ((BuildCommand) c).getBuilder(bc);

Method getTree = InternalBuilder.class.getDeclaredMethod("getLastBuiltTree");
getTree.setAccessible(true);
ElementTree t = (ElementTree) getTree.invoke(builder);
getTree.setAccessible(false);

if (t != null) {
Field stampField = ElementTree.class.getDeclaredField("treeStamp");
stampField.setAccessible(true);
int stamp = (int) stampField.get(t);
stampField.setAccessible(false);

if (stamp > highestStamp) {
highestStamp = stamp;
currentTree = t;
}
}
}
} catch (Exception e) {
e.printStackTrace();
// oups;
}

if (currentTree != null) {
suppressedProjects.put(project, currentTree);
} else {
System.err.println("no tree for " + project);
}
}
}

private boolean setAutoBuild(TaskingLog log, boolean autoBuild, boolean suppressBuild) {
boolean originalState = false;
synchronized (suppressedProjects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.tea.core.services.TaskProgressTracker;
import org.eclipse.tea.core.services.TaskingLog;
import org.eclipse.tea.core.ui.internal.listeners.AutoBuildDeactivator;
import org.eclipse.tea.library.build.chain.TeaBuildChain;
import org.eclipse.tea.library.build.chain.TeaBuildElement;
import org.eclipse.tea.library.build.config.TeaBuildConfig;
Expand Down Expand Up @@ -74,7 +73,6 @@ public Map<TeaBuildElement, IStatus> visit(List<TeaBuildElement> elements) {
TeaBuildUtil.tryCompile(projects.keySet());
projects.values().stream().forEach(e -> {
results.put(e, Status.OK_STATUS);
AutoBuildDeactivator.avoidBuild(e.getPlugin().getData().getProject());
});
} catch (Exception ex) {
projects.values().stream().forEach(e -> results.put(e,
Expand All @@ -100,7 +98,6 @@ public Map<TeaBuildElement, IStatus> visit(List<TeaBuildElement> elements) {
} else {
p.done();
results.put(p, Status.OK_STATUS);
AutoBuildDeactivator.avoidBuild(p.getPlugin().getData().getProject());
}
}
}
Expand Down
49 changes: 0 additions & 49 deletions sites/org.eclipse.tea.repository/target-platform.target

This file was deleted.

46 changes: 0 additions & 46 deletions sites/org.eclipse.tea.repository/target-platform.tpd

This file was deleted.

0 comments on commit 1fd61a4

Please sign in to comment.