use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class R5RepoContentProvider method generateIndex.
public void generateIndex(Set<File> files, OutputStream output, String repoName, URI baseUri, boolean pretty, Registry registry, LogService log) throws Exception {
RepoIndex indexer;
if (log != null)
indexer = new RepoIndex(log);
else
indexer = new RepoIndex();
indexer.addAnalyzer(new KnownBundleAnalyzer(), FrameworkUtil.createFilter("(name=*)"));
if (registry != null) {
List<ResourceAnalyzer> analyzers = registry.getPlugins(ResourceAnalyzer.class);
for (ResourceAnalyzer analyzer : analyzers) {
// TODO: where to get the filter property??
indexer.addAnalyzer(analyzer, null);
}
}
long modified = 0;
for (File file : files) modified = Math.max(modified, file.lastModified());
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.REPOSITORY_NAME, repoName);
config.put(ResourceIndexer.ROOT_URL, baseUri.toString());
config.put(ResourceIndexer.PRETTY, Boolean.toString(pretty));
config.put(ResourceIndexer.COMPRESSED, Boolean.toString(!pretty));
config.put(org.osgi.service.indexer.impl.RepoIndex.REPOSITORY_INCREMENT_OVERRIDE, Long.toString(modified));
indexer.index(files, output, config);
}
use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class TestStandaloneLibrary method testKnownBundlesExtra.
public void testKnownBundlesExtra() throws Exception {
Properties extras = new Properties();
extras.setProperty("org.eclipse.equinox.ds;[1.4,1.5)", "cap=extra;extra=wibble");
KnownBundleAnalyzer knownBundlesAnalyzer = new KnownBundleAnalyzer();
knownBundlesAnalyzer.setKnownBundlesExtra(extras);
RepoIndex indexer = new RepoIndex();
indexer.addAnalyzer(knownBundlesAnalyzer, FrameworkUtil.createFilter("(name=*)"));
StringWriter writer = new StringWriter();
File tempDir = createTempDir();
File tempFile = copyToTempFile(tempDir, "testdata/org.eclipse.equinox.ds-1.4.0.jar");
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
indexer.indexFragment(Collections.singleton(tempFile), writer, config);
assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/org.eclipse.equinox.ds-1.4.0.extra-fragment.txt")), writer.toString().trim());
deleteWithException(tempDir);
}
use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class Index method printCopyright.
public static void printCopyright(PrintStream out) throws IOException {
String version = "";
String copyright = "";
Enumeration<URL> urls = Index.class.getClassLoader().getResources("META-INF/MANIFEST.MF");
while (urls.hasMoreElements()) {
URL url = urls.nextElement();
Manifest m = new Manifest(url.openStream());
String bsn = m.getMainAttributes().getValue("Bundle-SymbolicName");
if (bsn != null && bsn.equals("org.osgi.impl.bundle.repoindex.cli")) {
version = m.getMainAttributes().getValue("Bundle-Version");
copyright = m.getMainAttributes().getValue("Bundle-Copyright");
break;
}
}
out.println("RepoIndex | Resource Indexer v" + version);
out.println(copyright);
}
use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class TestStandaloneLibrary method testBasicServiceInvocation.
public void testBasicServiceInvocation() throws Exception {
ResourceIndexer indexer = new RepoIndex();
StringWriter writer = new StringWriter();
File tempDir = createTempDir();
File tempFile = copyToTempFile(tempDir, "testdata/01-bsn+version.jar");
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
indexer.indexFragment(Collections.singleton(tempFile), writer, config);
assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/fragment-basic.txt")), writer.toString().trim());
deleteWithException(tempDir);
}
use of org.osgi.service.indexer.impl.RepoIndex in project bnd by bndtools.
the class TestStandaloneLibrary method testKnownBundleRecognition.
public void testKnownBundleRecognition() throws Exception {
RepoIndex indexer = new RepoIndex();
indexer.addAnalyzer(new KnownBundleAnalyzer(), FrameworkUtil.createFilter("(name=*)"));
StringWriter writer = new StringWriter();
File tempDir = createTempDir();
File tempFile = copyToTempFile(tempDir, "testdata/org.eclipse.equinox.ds-1.4.0.jar");
Map<String, String> config = new HashMap<String, String>();
config.put(ResourceIndexer.ROOT_URL, tempDir.getAbsoluteFile().toURI().toString());
indexer.indexFragment(Collections.singleton(tempFile), writer, config);
assertEquals(readStream(TestStandaloneLibrary.class.getResourceAsStream("/testdata/org.eclipse.equinox.ds-1.4.0.fragment.txt")), writer.toString().trim());
deleteWithException(tempDir);
}
Aggregations