use of org.eclipse.tycho.core.osgitools.DefaultClasspathEntry.DefaultAccessRule in project tycho by eclipse.
the class AbstractOsgiCompilerMojo method configureBootclasspathAccessRules.
private void configureBootclasspathAccessRules(CompilerConfiguration compilerConfiguration) throws MojoExecutionException {
List<AccessRule> accessRules = new ArrayList<>();
if (requireJREPackageImports) {
accessRules.addAll(getStrictBootClasspathAccessRules());
} else {
accessRules.add(new DefaultAccessRule("java/**", false));
for (String pkg : getTargetExecutionEnvironment().getSystemPackages()) {
accessRules.add(new DefaultAccessRule(pkg.trim().replace('.', '/') + "/*", false));
}
// now add packages exported by framework extension bundles
accessRules.addAll(getBundleProject().getBootClasspathExtraAccessRules(project));
}
if (accessRules.size() > 0) {
compilerConfiguration.addCompilerCustomArgument("org.osgi.framework.system.packages", toString(accessRules));
}
}
use of org.eclipse.tycho.core.osgitools.DefaultClasspathEntry.DefaultAccessRule 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);
}
Aggregations