Skip to content

Commit

Permalink
[m2e native] Fix native launch delegate for m2e
Browse files Browse the repository at this point in the history
Changed NativeBndLaunchDelegate launch delegate so that it uses
LaunchUtils.createRun(), which abstracts away the differences
between the Bnd workspace model and M2E model.

Fixes #4868.

Signed-off-by: Fr Jeremy Krieg <[email protected]>
Signed-off-by: BJ Hargrave <[email protected]>
  • Loading branch information
kriegfrj authored and bjhargrave committed Sep 29, 2021
1 parent 70f81a5 commit d1057e6
Showing 1 changed file with 4 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,12 @@

import static bndtools.launch.LaunchConstants.PLUGIN_ID;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Callable;

import org.bndtools.api.RunMode;
import org.bndtools.api.launch.LaunchConstants;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
Expand All @@ -29,7 +28,6 @@

import aQute.bnd.build.Project;
import aQute.bnd.build.ProjectLauncher;
import aQute.bnd.build.Run;
import aQute.bnd.build.RunSession;
import aQute.bnd.osgi.Processor;
import aQute.lib.io.IO;
Expand Down Expand Up @@ -81,34 +79,12 @@ public void launch(ILaunchConfiguration configuration, String mode, final ILaunc
return;
}

IProject parent = targetResource.getProject();
if (parent == null) {
p.error("Not part of a project " + targetResource);
Project model = LaunchUtils.createRun(targetResource, RunMode.LAUNCH);
if (model == null) {
p.error("Cannot locate Bnd launch for " + targetResource);
return;
}

Project parentModel = Central.getProject(parent);
if (parentModel == null) {
p.error("Cannot locate Bnd project for " + targetResource);
return;
}

Project model;
if (targetResource.getName()
.equals(Project.BNDFILE)) {
model = parentModel;
} else {

File file = targetResource.getLocation()
.toFile();
if (file == null || !file.isFile()) {
p.error("No file associated with the entry " + targetResource);
return;
}

model = new Run(parentModel.getWorkspace(), parentModel.getBase(), file);
}

monitor.setTaskName("Target is " + model);

boolean debug = "debug".equals(mode);
Expand Down

0 comments on commit d1057e6

Please sign in to comment.