use of aQute.bnd.build.Project in project bndtools by bndtools.
the class ReleaseAction method selectionChanged.
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
IFile[] locations = getLocations(selection);
bndFiles = new LinkedHashMap<Project, List<File>>();
for (IFile iFile : locations) {
File file = iFile.getLocation().toFile();
Project project;
try {
IProject iProject = iFile.getProject();
project = Central.getWorkspace().getProject(iProject.getName());
// .bnd files exists in cnf that are unreleasable
if (project == null || project.isCnf()) {
continue;
}
} catch (Exception e) {
throw new RuntimeException(e);
}
List<File> projectFiles = bndFiles.get(project);
if (projectFiles == null) {
projectFiles = new ArrayList<File>();
bndFiles.put(project, projectFiles);
}
projectFiles.add(file);
}
}
use of aQute.bnd.build.Project in project bndtools by bndtools.
the class WorkspaceAnalyserJob method getBuildOrder.
private static List<Project> getBuildOrder(IProgressMonitor monitor, Workspace workspace) throws Exception {
List<Project> outlist = new ArrayList<Project>();
monitor.setTaskName(Messages.calculatingBuildPath);
for (Project project : workspace.getAllProjects()) {
monitor.subTask(String.format(Messages.resolvingDependenciesForProject, project.getName()));
Collection<Project> dependsOn = project.getDependson();
getBuildOrder(dependsOn, outlist);
if (!outlist.contains(project)) {
outlist.add(project);
}
monitor.worked(1);
}
return outlist;
}
use of aQute.bnd.build.Project in project bndtools by bndtools.
the class ExportPatternsListPart method getProject.
Project getProject() {
Project project = null;
try {
BndEditModel model = (BndEditModel) getManagedForm().getInput();
File bndFile = model.getBndResource();
IPath path = Central.toPath(bndFile);
IFile resource = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
project = Central.getProject(resource.getProject());
} catch (Exception e) {
logger.logError("Error getting project from editor model", e);
}
return project;
}
use of aQute.bnd.build.Project in project bndtools by bndtools.
the class ExportPatternsListPart method findSourcePackagesWithoutPackageInfo.
private Collection<FileVersionTuple> findSourcePackagesWithoutPackageInfo(Collection<? extends ExportedPackage> pkgs) throws Exception {
Map<String, FileVersionTuple> result = new HashMap<String, FileVersionTuple>();
Project project = getProject();
if (project != null) {
Collection<File> sourceDirs = project.getSourcePath();
for (File sourceDir : sourceDirs) {
for (ExportedPackage pkg : pkgs) {
if (!result.containsKey(pkg.getName())) {
File pkgDir = new File(sourceDir, pkg.getName().replace('.', '/'));
if (pkgDir.isDirectory()) {
PackageInfoStyle existingPkgInfo = PackageInfoStyle.findExisting(pkgDir);
if (existingPkgInfo == null)
result.put(pkg.getName(), new FileVersionTuple(pkg.getName(), pkgDir));
}
}
}
}
}
return result.values();
}
use of aQute.bnd.build.Project in project bndtools by bndtools.
the class ResolutionWizard method performFinish.
@Override
public boolean performFinish() {
Collection<Resource> resources;
ResolutionResult result = resultsPage.getResult();
if (result != null && result.getOutcome() == ResolutionResult.Outcome.Resolved)
resources = result.getResourceWirings().keySet();
else
resources = Collections.emptyList();
// Open stream for physical paths list in target dir
PrintStream pathsStream = null;
try {
File targetDir;
Project bndProject = model.getProject();
targetDir = bndProject.getTargetDir();
if (targetDir == null)
targetDir = file.getLocation().toFile().getParentFile();
if (!targetDir.exists() && !targetDir.mkdirs()) {
throw new IOException("Could not create target directory " + targetDir);
}
File pathsFile = new File(targetDir, file.getName() + RESOLVED_PATHS_EXTENSION);
pathsStream = new PrintStream(pathsFile, "UTF-8");
} catch (Exception e) {
logger.logError("Unable to write resolved path list in target directory for project " + file.getProject().getName(), e);
}
// Generate -runbundles and path list
try {
List<VersionedClause> runBundles = new ArrayList<VersionedClause>(resources.size());
for (Resource resource : resources) {
VersionedClause runBundle = resourceToRunBundle(resource);
//[cs] Skip dups
if (runBundles.contains(runBundle)) {
continue;
}
runBundles.add(runBundle);
if (pathsStream != null) {
VersionedClause runBundleWithUri = runBundle.clone();
URI uri = ResourceUtils.getURI(ResourceUtils.getContentCapability(resource));
runBundleWithUri.getAttribs().put(BndConstants.RESOLUTION_URI_ATTRIBUTE, uri.toString());
StringBuilder builder = new StringBuilder();
runBundleWithUri.formatTo(builder, clauseAttributeSorter);
pathsStream.println(builder.toString());
}
}
Collections.sort(runBundles, new Comparator<VersionedClause>() {
@Override
public int compare(VersionedClause vc1, VersionedClause vc2) {
int diff = vc1.getName().compareTo(vc2.getName());
if (diff != 0)
return diff;
String r1 = vc1.getVersionRange();
if (r1 == null)
r1 = "";
String r2 = vc2.getVersionRange();
if (r2 == null)
r2 = "";
return r1.compareTo(r2);
}
});
// Do not change the order of existing runbundles because they migh have been ordered manually
List<VersionedClause> diffAddBundles = new ArrayList<>(runBundles);
List<VersionedClause> oldRunBundles = model.getRunBundles();
if (oldRunBundles == null)
oldRunBundles = Collections.emptyList();
else
diffAddBundles.removeAll(oldRunBundles);
List<VersionedClause> diffRemvedBundles = new ArrayList<>(oldRunBundles);
diffRemvedBundles.removeAll(runBundles);
List<VersionedClause> updatedRunBundles = new ArrayList<>(oldRunBundles);
updatedRunBundles.addAll(diffAddBundles);
updatedRunBundles.removeAll(diffRemvedBundles);
// do not use getRunBundles().addAll, because it will not reflect in UI or File
model.setRunBundles(updatedRunBundles);
} finally {
if (pathsStream != null) {
IO.close(pathsStream);
}
}
return true;
}
Aggregations