use of org.eclipse.tycho.classpath.ClasspathEntry in project tycho by eclipse.
the class TychoTest method testBundleExtraClasspath.
public void testBundleExtraClasspath() throws Exception {
File basedir = getBasedir("projects/extraclasspath");
File platformLocation = new File("src/test/resources/targetplatforms/basic");
List<MavenProject> projects = getSortedProjects(basedir, platformLocation);
assertEquals(3, projects.size());
MavenProject b01 = projects.get(1);
MavenProject b02 = projects.get(2);
OsgiBundleProject projectType = (OsgiBundleProject) lookup(TychoProject.class, b02.getPackaging());
List<ClasspathEntry> classpath = projectType.getClasspath(b02);
assertEquals(5, classpath.size());
// this bundle
assertEquals(1, classpath.get(0).getLocations().size());
assertEquals(canonicalFile("target/projects/extraclasspath/b02/target/classes"), classpath.get(0).getLocations().get(0).getCanonicalFile());
// reference to external bundle entry not on classpath
assertEquals(1, classpath.get(1).getLocations().size());
assertEquals(canonicalFile("target/local-repo/.cache/tycho/org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar/launcher.properties"), classpath.get(1).getLocations().get(0).getCanonicalFile());
// reference to reactor project entry
assertEquals(1, classpath.get(2).getLocations().size());
assertEquals(canonicalFile("target/projects/extraclasspath/b01/target/lib/nested.jar-classes"), classpath.get(2).getLocations().get(0).getCanonicalFile());
// reference to external bundle
assertEquals(1, classpath.get(3).getLocations().size());
assertEquals(canonicalFile("src/test/resources/targetplatforms/basic/plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar"), classpath.get(3).getLocations().get(0).getCanonicalFile());
// reference to project local folder
assertEquals(1, classpath.get(4).getLocations().size());
assertEquals(new File(basedir, "b02/classes").getCanonicalFile(), classpath.get(4).getLocations().get(0).getCanonicalFile());
}
use of org.eclipse.tycho.classpath.ClasspathEntry in project tycho by eclipse.
the class AbstractJUnitProviderTest method classPath.
static List<ClasspathEntry> classPath(String... entries) {
List<ClasspathEntry> result = new ArrayList<>();
for (String entry : entries) {
int colonIndex = entry.indexOf(':');
assertNotSame(-1, colonIndex);
String id = entry.substring(0, colonIndex);
String version = entry.substring(colonIndex + 1);
result.add(new DefaultClasspathEntry(null, new DefaultArtifactKey(ArtifactType.TYPE_ECLIPSE_PLUGIN, id, version), null, null));
}
return result;
}
use of org.eclipse.tycho.classpath.ClasspathEntry in project tycho by eclipse.
the class AbstractJUnitProvider method isEnabled.
@Override
public boolean isEnabled(List<ClasspathEntry> testBundleClassPath, Properties surefireProperties) {
Set<String> junitBundleNames = getJUnitBundleNames();
VersionRange range = getJUnitVersionRange();
for (ClasspathEntry classpathEntry : testBundleClassPath) {
ArtifactKey artifactKey = classpathEntry.getArtifactKey();
if (junitBundleNames.contains(artifactKey.getId())) {
Version version = Version.parseVersion(artifactKey.getVersion());
if (range.includes(version)) {
return true;
}
}
}
return false;
}
use of org.eclipse.tycho.classpath.ClasspathEntry in project tycho by eclipse.
the class OsgiBundleProject method getDependencyWalker.
@Override
public ArtifactDependencyWalker getDependencyWalker(MavenProject project) {
final DependencyArtifacts artifacts = getDependencyArtifacts(project);
final List<ClasspathEntry> cp = getClasspath(project);
return new ArtifactDependencyWalker() {
@Override
public void walk(ArtifactDependencyVisitor visitor) {
for (ClasspathEntry entry : cp) {
ArtifactDescriptor artifact = artifacts.getArtifact(entry.getArtifactKey());
ArtifactKey key = artifact.getKey();
File location = artifact.getLocation();
ReactorProject project = artifact.getMavenProject();
String classifier = artifact.getClassifier();
Set<Object> installableUnits = artifact.getInstallableUnits();
PluginDescription plugin = new DefaultPluginDescription(key, location, project, classifier, null, installableUnits);
visitor.visitPlugin(plugin);
}
}
@Override
public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) {
}
@Override
public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor artifactDependencyVisitor) {
}
@Override
public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) {
}
};
}
use of org.eclipse.tycho.classpath.ClasspathEntry 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