use of aQute.bnd.build.model.clauses.VersionedClause in project bndtools by bndtools.
the class RunRequirementsPart method doAddBundle.
private void doAddBundle() {
try {
RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(new ArrayList<VersionedClause>(), DependencyPhase.Run);
wizard.setSelectionPageTitle("Add Bundle Requirement");
WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
if (Window.OK == dialog.open()) {
List<VersionedClause> result = wizard.getSelectedBundles();
Set<Requirement> adding = new LinkedHashSet<Requirement>(result.size());
for (VersionedClause bundle : result) {
Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bundle.getName());
String versionRange = bundle.getVersionRange();
if (versionRange != null && !"latest".equals(versionRange)) {
filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
}
Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
adding.add(req);
}
updateViewerWithNewRequirements(adding);
}
} catch (Exception e) {
ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error selecting bundles.", e));
}
}
use of aQute.bnd.build.model.clauses.VersionedClause in project bndtools by bndtools.
the class RunBlacklistPart method doAddBundle.
private void doAddBundle() {
try {
RepoBundleSelectionWizard wizard = new RepoBundleSelectionWizard(new ArrayList<VersionedClause>(), DependencyPhase.Run);
wizard.setSelectionPageTitle("Add Bundle Blacklist");
WizardDialog dialog = new WizardDialog(getSection().getShell(), wizard);
if (Window.OK == dialog.open()) {
List<VersionedClause> result = wizard.getSelectedBundles();
Set<Requirement> adding = new LinkedHashSet<Requirement>(result.size());
for (VersionedClause bundle : result) {
Filter filter = new SimpleFilter(IdentityNamespace.IDENTITY_NAMESPACE, bundle.getName());
String versionRange = bundle.getVersionRange();
if (versionRange != null && !"latest".equals(versionRange)) {
filter = new AndFilter().addChild(filter).addChild(new LiteralFilter(Filters.fromVersionRange(versionRange)));
}
Requirement req = new CapReqBuilder(IdentityNamespace.IDENTITY_NAMESPACE).addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, filter.toString()).buildSyntheticRequirement();
adding.add(req);
}
updateViewerWithNewBlacklist(adding);
}
} catch (Exception e) {
ErrorDialog.openError(getSection().getShell(), "Error", null, new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, "Error selecting bundles for blacklist.", e));
}
}
use of aQute.bnd.build.model.clauses.VersionedClause in project bndtools by bndtools.
the class MapValuesContentProvider method doAdd.
void doAdd() {
IStructuredSelection selection = (IStructuredSelection) availableViewer.getSelection();
List<VersionedClause> adding = new ArrayList<VersionedClause>(selection.size());
for (Iterator<?> iter = selection.iterator(); iter.hasNext(); ) {
Object item = iter.next();
if (item instanceof RepositoryBundle) {
adding.add(RepositoryBundleUtils.convertRepoBundle((RepositoryBundle) item));
} else if (item instanceof RepositoryBundleVersion) {
adding.add(RepositoryBundleUtils.convertRepoBundleVersion((RepositoryBundleVersion) item, phase));
} else if (item instanceof ProjectBundle) {
String bsn = ((ProjectBundle) item).getBsn();
Attrs attribs = new Attrs();
attribs.put(Constants.VERSION_ATTRIBUTE, "latest");
adding.add(new VersionedClause(bsn, attribs));
}
}
if (!adding.isEmpty()) {
for (VersionedClause clause : adding) {
selectedBundles.put(clause.getName(), clause);
}
selectedViewer.add(adding.toArray());
availableViewer.refresh();
propSupport.firePropertyChange(PROP_SELECTION, null, selectedBundles);
}
}
use of aQute.bnd.build.model.clauses.VersionedClause in project bnd by bndtools.
the class RunconfigToDistributionTask method execute.
@Override
public void execute() throws BuildException {
try {
createReleaseDir();
BndEditModel model = new BndEditModel();
model.loadFrom(bndFile);
Project bndProject = new Project(new Workspace(rootDir), buildProject, bndFile);
List<RepositoryPlugin> repositories = bndProject.getPlugins(RepositoryPlugin.class);
if (allowSnapshots) {
snapshots = indexBundleSnapshots();
}
for (VersionedClause runBundle : model.getRunBundles()) {
String bsn = runBundle.getName();
if (bsn.endsWith(".jar")) {
bsn = bsn.substring(0, bsn.indexOf(".jar"));
}
if (allowSnapshots && snapshots.containsKey(bsn)) {
Jar jar = snapshots.get(bsn);
jar.write(new File(outputDir, jar.getName() + "-" + jar.getVersion() + ".jar"));
} else {
Version version = null;
File foundJar = null;
for (RepositoryPlugin repo : repositories) {
SortedSet<Version> versions = repo.versions(bsn);
for (Version availableVersion : versions) {
VersionRange range = null;
if (runBundle.getVersionRange() != null && !runBundle.getVersionRange().equals(Constants.VERSION_ATTR_LATEST)) {
range = new VersionRange(runBundle.getVersionRange());
}
boolean rangeMatches = range == null || range.includes(availableVersion);
boolean availableMatches = version == null || availableVersion.compareTo(version) > 0;
if (rangeMatches && availableMatches) {
version = availableVersion;
foundJar = repo.get(bsn, version, null);
}
}
}
if (foundJar != null) {
File outputFile = new File(outputDir, foundJar.getName());
Files.copy(foundJar.toPath(), outputFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
} else {
log(bsn + " could not be found in any repository");
}
}
}
bndProject.close();
} catch (Exception e) {
e.printStackTrace();
throw new BuildException(e);
}
}
use of aQute.bnd.build.model.clauses.VersionedClause in project bnd by bndtools.
the class ResourceTest method testResourceToVersionedClause.
public void testResourceToVersionedClause() throws Exception {
ResourceBuilder rb = new ResourceBuilder();
rb.addManifest(Domain.domain(IO.getFile("../demo-fragment/generated/demo-fragment.jar")));
Resource resource = rb.build();
VersionedClause versionClause = ResourceUtils.toVersionClause(resource, "[===,==+)");
StringBuilder sb = new StringBuilder();
versionClause.formatTo(sb);
assertEquals("demo-fragment;version='[1.0.0,1.0.1)'", sb.toString());
}
Aggregations