use of aQute.bnd.build.ProjectBuilder in project bnd by bndtools.
the class LocationTest method testBasic.
public void testBasic() throws Exception {
Project project = ws.getProject("p1");
assertNotNull(project);
ProjectBuilder sub1 = project.getSubBuilder("sub1");
assertNotNull(sub1);
ProjectBuilder sub2 = project.getSubBuilder("sub2");
assertNotNull(sub2);
assertTrue(find(sub1, "sub1", "p1/sub1.bnd", 4));
assertTrue(find(sub1, "bnd.bnd", "p1/bnd.bnd", 4));
assertTrue(find(project, "bnd.bnd", "p1/bnd.bnd", 4));
assertTrue(find(sub1, "i1", "p1/i1.bnd", 2));
assertTrue(find(project, "i1", "p1/i1.bnd", 2));
assertTrue(find(sub1, "i2", "p1/i2.bnd", 2));
assertTrue(find(project, "i2", "p1/i2.bnd", 2));
assertTrue(find(sub2, "sub2", "p1/sub2.bnd", 3));
assertTrue(find(sub2, "bnd.bnd", "p1/bnd.bnd", 4));
assertTrue(find(sub2, "workspace", "cnf/build.bnd", 6));
assertTrue(find(project, "workspace", "cnf/build.bnd", 6));
assertTrue(find(project.getWorkspace(), "workspace", "cnf/build.bnd", 6));
}
use of aQute.bnd.build.ProjectBuilder in project bndtools by bndtools.
the class BundleVersionErrorHandler method generateMarkerData.
@Override
public List<MarkerData> generateMarkerData(IProject project, Project model, Location location) throws Exception {
List<MarkerData> result = new LinkedList<MarkerData>();
IFile bndFile = null;
LineLocation loc = null;
BundleInfo info = (BundleInfo) location.details;
try (ProjectBuilder pb = model.getBuilder(null)) {
for (Builder builder : pb.getSubBuilders()) {
if (builder.getBsn().equals(info.bsn)) {
File propsFile = builder.getPropertiesFile();
// Try to find in the sub-bundle file
if (propsFile != null) {
bndFile = project.getWorkspace().getRoot().getFileForLocation(new Path(propsFile.getAbsolutePath()));
if (bndFile != null) {
loc = findBundleVersionHeader(bndFile);
}
}
if (loc == null) {
// Not found in sub-bundle file, try bnd.bnd
bndFile = project.getFile(Project.BNDFILE);
loc = findBundleVersionHeader(bndFile);
}
if (loc == null) {
// Not found in bnd.bnd, try build.bnd. Marker will appear on bnd.bnd
IFile buildFile = Central.getWorkspaceBuildFile();
loc = findBundleVersionHeader(buildFile);
if (loc != null) {
loc = new LineLocation();
loc.lineNum = 1;
loc.start = 1;
loc.end = 1;
}
}
if (loc == null) {
// Not found in build.bnd, try included files. Marker will appear on bnd.bnd
List<File> extensions = Central.getWorkspace().getIncluded();
if (extensions != null) {
for (File extension : extensions) {
loc = findBundleVersionHeader(Central.toResource(extension));
if (loc != null) {
loc = new LineLocation();
loc.lineNum = 1;
loc.start = 1;
loc.end = 1;
break;
}
}
}
}
if (loc != null) {
Map<String, Object> attribs = new HashMap<String, Object>();
attribs.put(IMarker.MESSAGE, location.message);
attribs.put(IMarker.LINE_NUMBER, loc.lineNum);
attribs.put(IMarker.CHAR_START, loc.start);
attribs.put(IMarker.CHAR_END, loc.end);
String qualifier = null;
String currentVersion = builder.getUnprocessedProperty(Constants.BUNDLE_VERSION, "");
if (currentVersion != null) {
Matcher m = VERSION_ACCEPTING_MACRO.matcher(currentVersion);
if (m.matches()) {
qualifier = m.group(4);
}
}
attribs.put(PROP_SUGGESTED_VERSION, info.suggestedVersion.toString() + (qualifier != null ? '.' + qualifier : ""));
result.add(new MarkerData(bndFile, attribs, true, BndtoolsConstants.MARKER_JAVA_BASELINE));
}
}
}
}
return result;
}
use of aQute.bnd.build.ProjectBuilder in project bndtools by bndtools.
the class ReleaseHelper method doRelease.
private static boolean doRelease(ReleaseContext context, List<Baseline> diffs, List<IReleaseParticipant> participants) throws Exception {
boolean ret = true;
if (!preRelease(context, participants)) {
postRelease(context, participants, false);
displayErrors(context);
return false;
}
try (ProjectBuilder pb = context.getProject().getBuilder(null)) {
List<Builder> builders = pb.getSubBuilders();
for (Baseline diff : diffs) {
Builder builder = null;
for (Builder b : builders) {
if (b.getBsn().equals(diff.getBsn())) {
builder = b;
break;
}
}
if (builder != null) {
if (!release(context, participants, builder)) {
ret = false;
}
}
}
}
return ret;
}
use of aQute.bnd.build.ProjectBuilder in project bndtools by bndtools.
the class ReleaseHelper method updateProject.
public static void updateProject(ReleaseContext context) throws Exception {
try (ProjectBuilder pb = context.getProject().getBuilder(null)) {
for (Builder builder : pb.getSubBuilders()) {
Baseline current = getBaselineForBuilder(builder, context);
if (current == null) {
continue;
}
for (Info info : current.getPackageInfos()) {
context.getProject().setPackageInfo(info.packageName, info.suggestedVersion);
}
updateBundleVersion(context, current, builder);
}
}
}
use of aQute.bnd.build.ProjectBuilder in project bndtools by bndtools.
the class WorkspaceAnalyserJob method run.
@Override
protected IStatus run(IProgressMonitor monitor) {
IProgressMonitor mon = monitor;
if (mon == null) {
mon = new NullProgressMonitor();
}
try {
Collection<Project> projects = Activator.getWorkspace().getAllProjects();
mon.beginTask(Messages.workspaceReleaseJob, projects.size() * 2);
List<Project> orderedProjects = getBuildOrder(mon, Activator.getWorkspace());
if (mon.isCanceled()) {
return Status.CANCEL_STATUS;
}
final List<ProjectDiff> projectDiffs = new ArrayList<ProjectDiff>();
mon.setTaskName(Messages.processingProjects);
for (Project project : orderedProjects) {
IProject eProject = ReleaseUtils.getProject(project);
if (!isIncluded(eProject)) {
mon.worked(1);
continue;
}
if ("".equals(project.getProperty(Constants.RELEASEREPO, null))) {
mon.worked(1);
continue;
}
if (eProject == null || !eProject.isOpen() || !eProject.isAccessible()) {
mon.worked(1);
continue;
}
List<Baseline> jarDiffs = null;
try (ProjectBuilder pb = project.getBuilder(null)) {
for (Builder b : pb.getSubBuilders()) {
mon.subTask(String.format(Messages.processingProject, b.getBsn()));
Baseline jarDiff = DiffHelper.createBaseline(b);
if (jarDiff != null) {
if (jarDiffs == null) {
jarDiffs = new ArrayList<Baseline>();
}
jarDiffs.add(jarDiff);
}
}
}
if (jarDiffs != null && jarDiffs.size() > 0) {
projectDiffs.add(new ProjectDiff(project, jarDiffs));
}
if (mon.isCanceled()) {
return Status.CANCEL_STATUS;
}
mon.worked(1);
}
if (projectDiffs.size() == 0) {
Runnable runnable = new Runnable() {
@Override
public void run() {
MessageDialog.openInformation(shell, Messages.releaseWorkspaceBundles, Messages.noBundlesRequireRelease);
}
};
if (Display.getCurrent() == null) {
Display.getDefault().syncExec(runnable);
} else {
runnable.run();
}
return Status.OK_STATUS;
}
ReleaseHelper.initializeProjectDiffs(projectDiffs);
Runnable runnable = new Runnable() {
@Override
public void run() {
WorkspaceReleaseDialog dialog = new WorkspaceReleaseDialog(shell, projectDiffs, false);
int ret = dialog.open();
if (ret == 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();
}
} catch (Exception e) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage(), e);
}
return Status.OK_STATUS;
}
Aggregations