use of org.eclipse.tycho.core.osgitools.OsgiManifest in project tycho by eclipse.
the class DefaultBundleReaderTest method testLoadManifestFromJar.
public void testLoadManifestFromJar() throws Exception {
File jar = new File("src/test/resources/bundlereader/jarshape/test.jar");
OsgiManifest manifest = bundleReader.loadManifest(jar);
assertEquals("org.eclipse.tycho.test", manifest.getBundleSymbolicName());
}
use of org.eclipse.tycho.core.osgitools.OsgiManifest in project tycho by eclipse.
the class DefaultEquinoxInstallationFactory method createInstallation.
@Override
public EquinoxInstallation createInstallation(EquinoxInstallationDescription description, File location) {
Set<String> bundlesToExplode = description.getBundlesToExplode();
List<File> frameworkExtensions = description.getFrameworkExtensions();
Map<String, BundleStartLevel> startLevel = description.getBundleStartLevel();
BundleStartLevel defaultBundleStartLevel = description.getDefaultBundleStartLevel();
if (defaultBundleStartLevel == null) {
defaultBundleStartLevel = new BundleStartLevel(null, 4, false);
}
Map<ArtifactKey, File> effective = new LinkedHashMap<>();
for (ArtifactDescriptor artifact : description.getBundles()) {
ArtifactKey key = artifact.getKey();
File file = artifact.getLocation();
OsgiManifest mf = manifestReader.loadManifest(file);
boolean directoryShape = bundlesToExplode.contains(key.getId()) || mf.isDirectoryShape();
if (!file.isDirectory() && directoryShape) {
String filename = key.getId() + "_" + key.getVersion();
File unpacked = new File(location, "plugins/" + filename);
unpacked.mkdirs();
unpack(file, unpacked);
effective.put(key, unpacked);
} else {
effective.put(key, file);
}
}
try {
location.mkdirs();
Properties p = new Properties();
p.putAll(description.getPlatformProperties());
String newOsgiBundles = toOsgiBundles(effective, startLevel, defaultBundleStartLevel);
p.setProperty("osgi.bundles", newOsgiBundles);
// see https://bugs.eclipse.org/bugs/show_bug.cgi?id=234069
p.setProperty("osgi.bundlefile.limit", "100");
// @see SimpleConfiguratorConstants#PROP_KEY_EXCLUSIVE_INSTALLATION
// p.setProperty("org.eclipse.equinox.simpleconfigurator.exclusiveInstallation", "false");
p.setProperty("osgi.install.area", "file:" + location.getAbsolutePath().replace('\\', '/'));
p.setProperty("osgi.configuration.cascaded", "false");
p.setProperty("osgi.framework", "org.eclipse.osgi");
p.setProperty("osgi.bundles.defaultStartLevel", String.valueOf(defaultBundleStartLevel.getLevel()));
// fix osgi.framework
String url = p.getProperty("osgi.framework");
if (url != null) {
File file;
ArtifactDescriptor desc = description.getBundle(url, null);
if (desc != null) {
url = "file:" + desc.getLocation().getAbsolutePath().replace('\\', '/');
} else if (url.startsWith("file:")) {
String path = url.substring("file:".length());
file = new File(path);
if (!file.isAbsolute()) {
file = new File(location, path);
}
url = "file:" + file.getAbsolutePath().replace('\\', '/');
}
}
if (url != null) {
p.setProperty("osgi.framework", url);
}
if (!frameworkExtensions.isEmpty()) {
// see osgi.framework.extensions at http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.platform.doc.isv%2Freference%2Fmisc%2Fruntime-options.html
Collection<String> bundleNames = unpackFrameworkExtensions(location, frameworkExtensions);
p.setProperty("osgi.framework", copySystemBundle(description, location));
p.setProperty("osgi.framework.extensions", StringUtils.join(bundleNames.iterator(), ","));
}
if (!description.getDevEntries().isEmpty()) {
p.put("osgi.dev", createDevProperties(location, description.getDevEntries()));
}
File configIni = new File(location, TychoConstants.CONFIG_INI_PATH);
File configurationLocation = configIni.getParentFile();
configurationLocation.mkdirs();
FileOutputStream fos = new FileOutputStream(configIni);
try {
p.store(fos, null);
} finally {
fos.close();
}
return new DefaultEquinoxInstallation(description, location, configurationLocation);
} catch (IOException e) {
throw new RuntimeException("Exception creating test eclipse runtime", e);
}
}
use of org.eclipse.tycho.core.osgitools.OsgiManifest in project tycho by eclipse.
the class DefaultEquinoxInstallationFactory method unpackFrameworkExtensions.
private List<String> unpackFrameworkExtensions(File location, Collection<File> frameworkExtensions) throws IOException {
List<String> bundleNames = new ArrayList<>();
for (File bundleFile : frameworkExtensions) {
OsgiManifest mf = manifestReader.loadManifest(bundleFile);
bundleNames.add(mf.getBundleSymbolicName());
File bundleDir = new File(location, "plugins/" + mf.getBundleSymbolicName() + "_" + mf.getBundleVersion());
if (bundleFile.isFile()) {
unpack(bundleFile, bundleDir);
} else {
FileUtils.copyDirectoryStructure(bundleFile, bundleDir);
}
}
return bundleNames;
}
use of org.eclipse.tycho.core.osgitools.OsgiManifest in project tycho by eclipse.
the class DefaultBundleReaderTest method testLoadManifestFromDir.
public void testLoadManifestFromDir() throws Exception {
File dir = new File("src/test/resources/bundlereader/dirshape");
OsgiManifest manifest = bundleReader.loadManifest(dir);
assertEquals("org.eclipse.tycho.test", manifest.getBundleSymbolicName());
}
use of org.eclipse.tycho.core.osgitools.OsgiManifest in project tycho by eclipse.
the class LocalDependencyResolver method getArtifactKey.
public ArtifactKey getArtifactKey(MavenSession session, File plugin) {
OsgiManifest mf = manifestReader.loadManifest(plugin);
ArtifactKey key = mf.toArtifactKey();
return key;
}
Aggregations