use of aQute.bnd.build.ProjectBuilder in project bndtools by bndtools.
the class BndFileCapReqLoader method getBuilder.
@Override
protected synchronized Builder getBuilder() throws Exception {
if (builder == null) {
Builder b;
IFile[] wsfiles = FileUtils.getWorkspaceFiles(file);
if (wsfiles == null || wsfiles.length == 0)
throw new Exception("Unable to determine project owner for Bnd file: " + file.getAbsolutePath());
IProject project = wsfiles[0].getProject();
// Calculate the manifest
Project bndProject = Central.getInstance().getModel(JavaCore.create(project));
if (bndProject == null)
return null;
if (file.getName().equals(Project.BNDFILE)) {
ProjectBuilder pb = bndProject.getBuilder(null);
boolean close = true;
try {
b = pb.getSubBuilders().get(0);
if (b == pb) {
close = false;
} else {
pb.removeClose(b);
}
} finally {
if (close) {
pb.close();
}
}
} else {
b = bndProject.getSubBuilder(file);
}
if (b == null) {
b = new Builder();
b.setProperties(file);
}
b.build();
builder = b;
}
return builder;
}
use of aQute.bnd.build.ProjectBuilder in project bndtools by bndtools.
the class RepositoryTreeContentProvider method getProjectBundles.
Object[] getProjectBundles(Project project) {
ProjectBundle[] result = null;
try (ProjectBuilder pb = project.getBuilder(null)) {
List<Builder> builders = pb.getSubBuilders();
result = new ProjectBundle[builders.size()];
int i = 0;
for (Builder builder : builders) {
ProjectBundle bundle = new ProjectBundle(project, builder.getBsn());
result[i++] = bundle;
}
} catch (Exception e) {
logger.logError(MessageFormat.format("Error querying sub-bundles for project {0}.", project.getName()), e);
}
return result;
}
use of aQute.bnd.build.ProjectBuilder in project bndtools by bndtools.
the class DiffHelper method createBaseline.
public static Baseline createBaseline(Builder builder) {
try {
if (builder instanceof ProjectBuilder) {
ProjectBuilder projectBuilder = (ProjectBuilder) builder;
Jar jar = null;
Jar currentJar = null;
try {
jar = projectBuilder.build();
currentJar = projectBuilder.getBaselineJar();
if (currentJar == null) {
currentJar = projectBuilder.getLastRevision();
}
if (currentJar == null) {
// $NON-NLS-1$
currentJar = new Jar(".");
}
DiffPluginImpl differ = new DiffPluginImpl();
String diffignore = projectBuilder.getProperty(Constants.DIFFIGNORE);
if (diffignore != null)
differ.setIgnore(diffignore);
Baseline baseline = new Baseline(projectBuilder, differ);
baseline.baseline(jar, currentJar, null);
return baseline;
} finally {
if (jar != null)
jar.close();
if (currentJar != null)
currentJar.close();
}
}
} catch (Exception e1) {
e1.printStackTrace();
}
return null;
}
use of aQute.bnd.build.ProjectBuilder in project bndtools by bndtools.
the class ReleaseDialogJob method run.
@Override
protected IStatus run(IProgressMonitor monitor) {
try {
monitor.beginTask(Messages.cleaningProject, 100);
monitor.setTaskName(Messages.releasing);
monitor.worked(33);
monitor.subTask(Messages.checkingExported);
final List<Baseline> diffs = new ArrayList<Baseline>();
try (ProjectBuilder pb = project.getBuilder(null)) {
for (Builder builder : pb.getSubBuilders()) {
if (subBundles != null) {
if (!subBundles.contains(builder.getPropertiesFile())) {
continue;
}
}
Baseline diff = DiffHelper.createBaseline(builder);
if (diff != null) {
diffs.add(diff);
}
}
}
if (diffs.size() == 0) {
// TODO: message
return Status.OK_STATUS;
}
monitor.worked(33);
Runnable runnable = new Runnable() {
@Override
public void run() {
List<ProjectDiff> projectDiffs = new ArrayList<ProjectDiff>();
projectDiffs.add(new ProjectDiff(project, diffs));
ReleaseHelper.initializeProjectDiffs(projectDiffs);
WorkspaceReleaseDialog dialog = new WorkspaceReleaseDialog(shell, projectDiffs, true);
if (dialog.open() == Window.OK) {
boolean runJob = false;
for (ProjectDiff diff : projectDiffs) {
if (diff.isRelease()) {
runJob = true;
break;
}
}
if (!runJob) {
return;
}
WorkspaceReleaseJob releaseJob = new WorkspaceReleaseJob(projectDiffs, dialog.getReleaseOption(), dialog.isShowMessage());
releaseJob.setRule(ResourcesPlugin.getWorkspace().getRoot());
releaseJob.schedule();
}
}
};
if (Display.getCurrent() == null) {
Display.getDefault().asyncExec(runnable);
} else {
runnable.run();
}
monitor.worked(33);
return Status.OK_STATUS;
} catch (Exception e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Error : " + e.getMessage(), e);
} finally {
monitor.done();
}
}
Aggregations