Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaModelStatus;
import org.eclipse.jdt.core.IJavaProject;
Expand Down Expand Up @@ -474,9 +473,10 @@ public static IClasspathEntry createContainerEntry() {
return JavaCore.newContainerEntry(PDECore.REQUIRED_PLUGINS_CONTAINER_PATH);
}

public static IClasspathEntry[] computeClasspathEntries(IPluginModelBase model, IProject project) {
IClasspathContainer container = new RequiredPluginsClasspathContainer(model, project);
return container.getClasspathEntries();
public static IClasspathEntry[] computeClasspathEntries(IPluginModelBase model, IProject project)
throws CoreException {
RequiredPluginsClasspathContainer container = new RequiredPluginsClasspathContainer(model, project);
return container.computeEntries();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ protected IStatus run(IProgressMonitor jobMonitor) {
IPluginModelBase model = modelManager.findModel(project);
if (model != null && PluginProject.isJavaProject(project)) {
IJavaProject javaProject = JavaCore.create(project);
RequiredPluginsClasspathContainer classpathContainer = new RequiredPluginsClasspathContainer(
model, project);
try {
if (!isUpToDate(project, classpathContainer.computeEntries(), request.container())) {
updateProjects.put(javaProject, classpathContainer);
IClasspathEntry[] entries = ClasspathComputer.computeClasspathEntries(model,
javaProject.getProject());
if (!isUpToDate(project, entries, request.container())) {
updateProjects.put(javaProject, PDEClasspathContainerSaveHelper.containerOf(entries));
errorsPerProject.remove(project);
saveState(project, classpathContainer);
saveState(project, entries);
}
} catch (CoreException e) {
errorsPerProject.put(project, e.getStatus());
Expand Down Expand Up @@ -213,13 +213,13 @@ private static boolean isUpToDate(IProject project, IClasspathEntry[] currentEnt
return true;
}

private static void saveState(IProject project, RequiredPluginsClasspathContainer classpathContainer) {
private static void saveState(IProject project, IClasspathEntry[] entries) {
synchronized (project) {
try {
File stateFile = getStateFile(project);
stateFile.getParentFile().mkdirs();
try (BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(stateFile))) {
PDEClasspathContainerSaveHelper.writeContainer(classpathContainer, stream);
PDEClasspathContainerSaveHelper.writeContainerEntries(entries, stream);
}
} catch (Exception e) {
// can't write then...
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.osgi.service.resolver.BaseDescription;
Expand Down Expand Up @@ -72,7 +71,7 @@
import aQute.bnd.build.Workspace;
import aQute.bnd.osgi.Constants;

class RequiredPluginsClasspathContainer implements IClasspathContainer {
class RequiredPluginsClasspathContainer {

@SuppressWarnings("nls")
private static final Set<String> JUNIT5_RUNTIME_PLUGINS = Set.of("org.junit", //
Expand Down Expand Up @@ -114,30 +113,6 @@ class RequiredPluginsClasspathContainer implements IClasspathContainer {
this.project = project;
}

@Override
public int getKind() {
return K_APPLICATION;
}

@Override
public IPath getPath() {
return PDECore.REQUIRED_PLUGINS_CONTAINER_PATH;
}

@Override
public String getDescription() {
return PDECoreMessages.RequiredPluginsClasspathContainer_description;
}

@Override
public IClasspathEntry[] getClasspathEntries() {
try {
return computeEntries();
} catch (CoreException e) {
return new IClasspathEntry[0];
}
}

IClasspathEntry[] computeEntries() throws CoreException {
if (fEntries == null) {
if (fModel == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ public static IClasspathContainer emptyContainer() {
return new SerializableClasspathContainer();
}

public static void writeContainer(IClasspathContainer container, OutputStream output) throws IOException {
public static IClasspathContainer containerOf(IClasspathEntry[] entries) {
return new SerializableClasspathContainer(entries);
}

public static void writeContainerEntries(IClasspathEntry[] entries, OutputStream output) throws IOException {
ObjectOutputStream os = new ObjectOutputStream(new BufferedOutputStream(output)) {
{
enableReplaceObject(true);
Expand All @@ -90,7 +94,7 @@ protected Object replaceObject(Object o) throws IOException {
return super.replaceObject(o);
}
};
os.writeObject(new SerializableClasspathContainer(container.getClasspathEntries()));
os.writeObject(new SerializableClasspathContainer(entries));
os.flush();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,7 @@ public String getDescription() {

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + Arrays.hashCode(entries);
return result;
return Arrays.hashCode(entries);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*******************************************************************************/
package org.eclipse.pde.internal.ui.wizards;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
Expand Down Expand Up @@ -199,7 +200,10 @@ private void createRealEntries() {
entry = ClasspathComputer.createContainerEntry();
IPluginModelBase model = PluginRegistry.findModel(javaProject.getProject());
if (model != null) {
realEntries = ClasspathComputer.computeClasspathEntries(model, javaProject.getProject());
try {
realEntries = ClasspathComputer.computeClasspathEntries(model, javaProject.getProject());
} catch (CoreException e) {
}
}
} else {
try {
Expand Down
Loading