use of aQute.bnd.version.Version in project bndtools by bndtools.
the class BndContainerSourceManager method getSourceBundle.
private static File getSourceBundle(IPath path, Map<String, String> props) {
Workspace bndWorkspace;
try {
bndWorkspace = Central.getWorkspace();
if (bndWorkspace == null) {
return null;
}
} catch (final Exception e) {
return null;
}
IPath bundlePath = path;
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IResource resource = root.findMember(path);
if (resource != null) {
bundlePath = resource.getLocation();
}
try (JarInputStream jarStream = new JarInputStream(IO.stream(bundlePath.toFile()), false)) {
Manifest manifest = jarStream.getManifest();
if (manifest == null) {
return null;
}
Domain domain = Domain.domain(manifest);
Entry<String, Attrs> bsnAttrs = domain.getBundleSymbolicName();
if (bsnAttrs == null) {
return null;
}
String bsn = bsnAttrs.getKey();
String version = domain.getBundleVersion();
if (version == null) {
version = props.get("version");
}
for (RepositoryPlugin repo : RepositoryUtils.listRepositories(true)) {
if (repo == null) {
continue;
}
if (repo instanceof WorkspaceRepository) {
continue;
}
File sourceBundle = repo.get(bsn + ".source", new Version(version), props);
if (sourceBundle != null) {
return sourceBundle;
}
}
} catch (final Exception e) {
// Ignore, something went wrong, or we could not find the source bundle
}
return null;
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class MavenRepository method versions.
public SortedSet<Version> versions(String bsn) throws Exception {
File[] files = get(bsn, null);
List<Version> versions = new ArrayList<Version>();
for (File f : files) {
String version = f.getParentFile().getName();
version = Builder.cleanupVersion(version);
Version v = new Version(version);
versions.add(v);
}
if (versions.isEmpty())
return SortedList.empty();
return new SortedList<Version>(versions);
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class PomFromManifest method getVersion.
public Version getVersion() {
if (xversion != null)
return new Version(xversion);
String version = manifest.getMainAttributes().getValue(Constants.BUNDLE_VERSION);
Version v = new Version(version);
return new Version(v.getMajor(), v.getMinor(), v.getMicro());
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class JavaElement method getLocalAPI.
private Element getLocalAPI() throws Exception {
Set<Element> result = new HashSet<Element>();
for (Map.Entry<PackageRef, List<Element>> entry : packages.entrySet()) {
List<Element> set = entry.getValue();
for (Iterator<Element> i = set.iterator(); i.hasNext(); ) {
if (notAccessible.contains(analyzer.getTypeRefFromFQN(i.next().getName())))
i.remove();
}
String version = exports.get(entry.getKey()).get(Constants.VERSION_ATTRIBUTE);
if (version != null) {
Version v = new Version(version);
set.add(new Element(VERSION, v.getWithoutQualifier().toString(), null, IGNORED, IGNORED, null));
}
Element pd = new Element(PACKAGE, entry.getKey().getFQN(), set, MINOR, MAJOR, null);
result.add(pd);
}
for (JAVA java : javas) {
result.add(new Element(CLASS_VERSION, java.toString(), null, CHANGED, CHANGED, null));
}
return new Element(API, "<api>", result, CHANGED, CHANGED, null);
}
use of aQute.bnd.version.Version in project bnd by bndtools.
the class FileRepo method versions.
public List<Version> versions(String bsn) throws Exception {
File dir = new File(root, bsn);
final List<Version> versions = new ArrayList<Version>();
dir.list(new FilenameFilter() {
public boolean accept(File dir, String name) {
Matcher m = REPO_FILE.matcher(name);
if (m.matches()) {
versions.add(new Version(m.group(2)));
return true;
}
return false;
}
});
return versions;
}
Aggregations