Skip to content

Commit

Permalink
[PDE-Connector] simplify bundle-root set to make activator obsolete
Browse files Browse the repository at this point in the history
We already use the internal class
org.eclipse.pde.internal.core.project.PDEProject to get the Bundle-Root,
so we can also it to set the Bundle-Root, which makes the activator for
m2e.pde.connector obsolete.
  • Loading branch information
HannesWell committed Nov 27, 2022
1 parent 6702e7b commit d07bc99
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 54 deletions.
1 change: 0 additions & 1 deletion org.eclipse.m2e.pde.connector/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ Require-Bundle: org.eclipse.m2e.core;bundle-version="[2.0.0,3.0.0)",
org.eclipse.pde.core,
org.eclipse.jdt.core,
org.eclipse.pde.ds.annotations
Bundle-Activator: org.eclipse.m2e.pde.connector.Activator
Service-Component: OSGI-INF/org.eclipse.m2e.pde.connector.PDEBuildProjectFileResolver.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import org.eclipse.pde.core.build.IBuildModel;
import org.eclipse.pde.core.plugin.IPluginModelBase;
import org.eclipse.pde.core.plugin.PluginRegistry;
import org.eclipse.pde.core.project.IBundleProjectService;

public class PDEProjectHelper {

Expand Down Expand Up @@ -155,27 +154,23 @@ static void addPDENature(IProject project, IPath manifestPath, IProgressMonitor
setManifestLocaton(project, manifestPath, monitor);
}

@SuppressWarnings("restriction")
private static void setManifestLocaton(IProject project, IPath manifestPath, IProgressMonitor monitor)
throws CoreException {
IBundleProjectService projectService = Activator.getBundleProjectService().orElseThrow();
IContainer bundleRoot = null; // in case of configuration update, reset to the default value
if (manifestPath != null) {
IPath bundleRootPath;
IFile manifest;
if (manifestPath.toFile().toPath().endsWith("META-INF")) {
bundleRootPath = manifestPath.removeLastSegments(1);
manifest = project.getFolder(manifestPath).getFile("MANIFEST.MF");
} else if (manifestPath.toFile().toPath().endsWith(Path.of("META-INF", "MANIFEST.MF"))) {
bundleRootPath = manifestPath.removeLastSegments(2);
manifest = project.getFile(manifestPath);
} else {
return;
}
manifest.refreshLocal(IResource.DEPTH_ZERO, monitor);
projectService.setBundleRoot(project, bundleRootPath.isEmpty() ? null : bundleRootPath);
} else {
// in case of configuration update, reset to the default value
projectService.setBundleRoot(project, null);
bundleRoot = manifest.getParent().getParent();
}
org.eclipse.pde.internal.core.project.PDEProject.setBundleRoot(project, bundleRoot);
}

/**
Expand Down

0 comments on commit d07bc99

Please sign in to comment.