use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.
the class EquinoxResolver method newState.
protected State newState(DependencyArtifacts artifacts, Properties properties, boolean ignoreEE) throws BundleException {
State state = factory.createState(true);
Map<File, Dictionary<String, String>> systemBundles = new LinkedHashMap<>();
Map<File, Dictionary<String, String>> externalBundles = new LinkedHashMap<>();
Map<File, Dictionary<String, String>> projects = new LinkedHashMap<>();
for (ArtifactDescriptor artifact : artifacts.getArtifacts(ArtifactType.TYPE_ECLIPSE_PLUGIN)) {
File location = artifact.getLocation();
Dictionary<String, String> mf = loadManifest(location);
if (isFrameworkImplementation(location, mf)) {
systemBundles.put(location, mf);
} else if (artifact.getMavenProject() != null) {
projects.put(location, mf);
} else {
externalBundles.put(location, mf);
}
}
long id = SYSTEM_BUNDLE_ID;
if (systemBundles.isEmpty()) {
// there were no OSGi framework implementations among bundles being resolve
// fabricate system.bundle to export visible JRE packages
state.addBundle(factory.createBundleDescription(state, getSystemBundleManifest(properties), "", id++));
} else {
// TODO test what happens when multiple framework implementations are present
for (Map.Entry<File, Dictionary<String, String>> entry : systemBundles.entrySet()) {
addBundle(state, id++, entry.getKey(), entry.getValue(), false);
}
}
for (Map.Entry<File, Dictionary<String, String>> entry : externalBundles.entrySet()) {
addBundle(state, id++, entry.getKey(), entry.getValue(), false);
}
for (Map.Entry<File, Dictionary<String, String>> entry : projects.entrySet()) {
// make sure reactor projects override anything from the target platform
// that has the same bundle symbolic name
addBundle(state, id++, entry.getKey(), entry.getValue(), true);
}
List<Dictionary<Object, Object>> allProps = new ArrayList<>();
// force our system.bundle
Hashtable<Object, Object> platformProperties = new Hashtable<>(properties);
platformProperties.put(StateImpl.STATE_SYSTEM_BUNDLE, state.getBundle(SYSTEM_BUNDLE_ID).getSymbolicName());
allProps.add(platformProperties);
if (ignoreEE) {
// ignoring EE by adding all known EEs
for (String profile : ExecutionEnvironmentUtils.getProfileNames()) {
Properties envProps = ExecutionEnvironmentUtils.getExecutionEnvironment(profile).getProfileProperties();
String systemPackages = envProps.getProperty("org.osgi.framework.system.packages");
String execEnv = envProps.getProperty("org.osgi.framework.executionenvironment");
Dictionary<Object, Object> prop = new Hashtable<>();
prop.put("org.osgi.framework.system.packages", systemPackages);
prop.put("org.osgi.framework.executionenvironment", execEnv);
allProps.add(prop);
}
}
Dictionary<Object, Object>[] stateProperties = allProps.toArray(new Dictionary[allProps.size()]);
state.setPlatformProperties(stateProperties);
return state;
}
use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.
the class OsgiBundleProject method resolveClassPath.
@Override
public void resolveClassPath(MavenSession session, MavenProject project) {
DependencyArtifacts artifacts = getDependencyArtifacts(project);
State state = getResolverState(project, artifacts);
if (getLogger().isDebugEnabled() && DebugUtils.isDebugEnabled(session, project)) {
getLogger().debug(resolver.toDebugString(state));
}
BundleDescription bundleDescription = state.getBundleByLocation(project.getBasedir().getAbsolutePath());
List<ClasspathEntry> classpath = new ArrayList<>();
// project itself
ArtifactDescriptor artifact = getArtifact(artifacts, project.getBasedir(), bundleDescription.getSymbolicName());
ReactorProject projectProxy = DefaultReactorProject.adapt(project);
List<File> projectClasspath = getThisProjectClasspath(artifact, projectProxy);
classpath.add(new DefaultClasspathEntry(projectProxy, artifact.getKey(), projectClasspath, null));
// build.properties/jars.extra.classpath
addExtraClasspathEntries(classpath, projectProxy, artifacts);
// dependencies
List<AccessRule> strictBootClasspathAccessRules = new ArrayList<>();
strictBootClasspathAccessRules.add(new DefaultAccessRule("java/**", false));
for (DependencyEntry entry : dependencyComputer.computeDependencies(state.getStateHelper(), bundleDescription)) {
if (EquinoxResolver.SYSTEM_BUNDLE_ID == entry.desc.getBundleId()) {
if (entry.rules != null) {
strictBootClasspathAccessRules.addAll(entry.rules);
}
if (EquinoxResolver.SYSTEM_BUNDLE_SYMBOLIC_NAME.equals(entry.desc.getSymbolicName())) {
// synthetic system.bundle has no filesystem location
continue;
}
}
File location = new File(entry.desc.getLocation());
ArtifactDescriptor otherArtifact = getArtifact(artifacts, location, entry.desc.getSymbolicName());
ReactorProject otherProject = otherArtifact.getMavenProject();
List<File> locations;
if (otherProject != null) {
locations = getOtherProjectClasspath(otherArtifact, otherProject, null);
} else {
locations = getBundleClasspath(otherArtifact);
}
if (locations.isEmpty() && !entry.rules.isEmpty()) {
getLogger().warn("Empty classpath of required bundle " + otherArtifact);
}
classpath.add(new DefaultClasspathEntry(otherProject, otherArtifact.getKey(), locations, entry.rules));
}
project.setContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_CLASSPATH, classpath);
project.setContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_STRICT_BOOTCLASSPATH_ACCESSRULES, strictBootClasspathAccessRules);
project.setContextValue(TychoConstants.CTX_ECLIPSE_PLUGIN_BOOTCLASSPATH_EXTRA_ACCESSRULES, dependencyComputer.computeBootClasspathExtraAccessRules(state.getStateHelper(), bundleDescription));
addPDESourceRoots(project);
}
use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.
the class OsgiBundleProject method addExtraClasspathEntries.
private void addExtraClasspathEntries(List<ClasspathEntry> classpath, ReactorProject project, DependencyArtifacts artifacts) {
EclipsePluginProject pdeProject = getEclipsePluginProject(project);
Collection<BuildOutputJar> outputJars = pdeProject.getOutputJarMap().values();
for (BuildOutputJar buildOutputJar : outputJars) {
List<String> entries = buildOutputJar.getExtraClasspathEntries();
for (String entry : entries) {
Pattern platformURL = Pattern.compile("platform:/(plugin|fragment)/([^/]*)/*(.*)");
Matcher m = platformURL.matcher(entry.trim());
String bundleId = null;
String path = null;
if (m.matches()) {
bundleId = m.group(2).trim();
path = m.group(3).trim();
if (path != null && path.length() <= 0) {
path = null;
}
ArtifactDescriptor matchingBundle = artifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, bundleId, null);
if (matchingBundle != null) {
List<File> locations;
if (matchingBundle.getMavenProject() != null) {
locations = getOtherProjectClasspath(matchingBundle, matchingBundle.getMavenProject(), path);
} else if (path != null) {
locations = getBundleEntry(matchingBundle, path);
} else {
locations = getBundleClasspath(matchingBundle);
}
classpath.add(new DefaultClasspathEntry(matchingBundle.getMavenProject(), matchingBundle.getKey(), locations, null));
} else {
getLogger().warn("Missing extra classpath entry " + entry.trim());
}
} else {
entry = entry.trim();
File file = new File(project.getBasedir(), entry).getAbsoluteFile();
if (file.exists()) {
List<File> locations = Collections.singletonList(file);
ArtifactKey projectKey = getArtifactKey(project);
classpath.add(new DefaultClasspathEntry(project, projectKey, locations, null));
} else {
getLogger().warn("Missing extra classpath entry " + entry);
}
}
}
}
}
use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.
the class ArtifactCollection method toDebugString.
public void toDebugString(StringBuilder sb, String linePrefix) {
for (ArtifactDescriptor artifact : artifacts.values()) {
sb.append(linePrefix);
sb.append(artifact.getKey().toString());
sb.append(": ");
ReactorProject project = artifact.getMavenProject();
if (project != null) {
sb.append(project.toString());
} else {
sb.append(artifact.getLocation());
}
sb.append("\n");
}
}
use of org.eclipse.tycho.ArtifactDescriptor in project tycho by eclipse.
the class MultiEnvironmentDependencyArtifacts method addPlatform.
public void addPlatform(TargetEnvironment environment, DefaultDependencyArtifacts platform) {
platforms.put(environment, platform);
for (ArtifactDescriptor artifact : platform.artifacts.values()) {
addArtifact(artifact, true);
}
nonReactorUnits.addAll(platform.nonReactorUnits);
}
Aggregations