Skip to content

Commit

Permalink
Convert BndExportJarHandler into reusable UI component
Browse files Browse the repository at this point in the history
Currently the BndExportJarHandler is bound to Bndtools tooling
completely, but now using the adapter pattern can be used in any context
where a IProject can be adapted to (bnd) Project

Signed-off-by: Christoph Läubrich <[email protected]>
  • Loading branch information
laeubi committed Nov 14, 2023
1 parent 1e9abcc commit 6779563
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bndtools.core/src/bndtools/command/BndExportJarHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.resources.WorkspaceJob;
import org.eclipse.core.runtime.Adapters;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
Expand All @@ -24,7 +25,6 @@
import aQute.lib.io.IO;
import biz.aQute.resolve.Bndrun;
import bndtools.Plugin;
import bndtools.central.Central;
import bndtools.launch.util.LaunchUtils;

public class BndExportJarHandler extends AbstractHandler {
Expand All @@ -47,8 +47,8 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {

File exportDir = bndrun.getBase();

if (Central.isBndProject(project)) {
Project bndProject = Central.getProject(project);
Project bndProject = Adapters.adapt(project, Project.class);
if (bndProject != null) {
bndrun.setBase(bndProject.getBase());
exportDir = IO.getBasedFile(bndProject.getTargetDir(), "export");
exportDir.mkdirs();
Expand All @@ -61,7 +61,7 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
File exported = IO.getBasedFile(exportDir, export.getKey());
resource.write(exported);
exported.setLastModified(resource.lastModified());
if (Central.isBndProject(project)) {
if (bndProject != null) {
project.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}
Expand Down

0 comments on commit 6779563

Please sign in to comment.