use of org.eclipse.tycho.ArtifactKey in project tycho by eclipse.
the class DefaultDependencyArtifactsTest method testInconsistentArtifacts.
@Test
public void testInconsistentArtifacts() {
DefaultDependencyArtifacts tp = new DefaultDependencyArtifacts();
ArtifactKey key = new DefaultArtifactKey("type", "id", "version");
File location = new File("location");
tp.addArtifactFile(key, location, asSet("a"));
try {
tp.addArtifactFile(key, location, asSet("b"));
} catch (IllegalStateException e) {
// expected
}
}
use of org.eclipse.tycho.ArtifactKey in project tycho by eclipse.
the class LocalDependencyResolverTest method testBundleIdParsing.
public void testBundleIdParsing() throws Exception {
DependencyArtifacts platform = getTargetPlatform(new File("src/test/resources/targetplatforms/basic"));
ArtifactDescriptor artifact = platform.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, "bundle01", null);
ArtifactKey key = artifact.getKey();
assertEquals("bundle01", key.getId());
assertEquals("0.0.1", key.getVersion());
File file = artifact.getLocation();
assertEquals("bundle01_0.0.1", file.getName());
}
use of org.eclipse.tycho.ArtifactKey in project tycho by eclipse.
the class OsgiSourceMojo method addSourceBundleManifestEntries.
private void addSourceBundleManifestEntries(MavenArchiveConfiguration mavenArchiveConfiguration) {
TychoProject projectType = projectTypes.get(project.getPackaging());
ArtifactKey artifactKey = projectType.getArtifactKey(DefaultReactorProject.adapt(project));
String symbolicName = artifactKey.getId();
String version = artifactKey.getVersion();
if (symbolicName != null && version != null) {
mavenArchiveConfiguration.addManifestEntry(BUNDLE_MANIFESTVERSION, "2");
mavenArchiveConfiguration.addManifestEntry(BUNDLE_SYMBOLICNAME, symbolicName + sourceBundleSuffix);
Version expandedVersion = getExpandedVersion(version);
mavenArchiveConfiguration.addManifestEntry(BUNDLE_VERSION, expandedVersion.toString());
mavenArchiveConfiguration.addManifestEntry(MANIFEST_HEADER_ECLIPSE_SOURCE_BUNDLE, symbolicName + ";version=\"" + expandedVersion + "\";roots:=\"" + getEclipseHeaderSourceRoots() + "\"");
mavenArchiveConfiguration.addManifestEntry(BUNDLE_NAME, I18N_KEY_PREFIX + I18N_KEY_BUNDLE_NAME);
mavenArchiveConfiguration.addManifestEntry(BUNDLE_VENDOR, I18N_KEY_PREFIX + I18N_KEY_BUNDLE_VENDOR);
mavenArchiveConfiguration.addManifestEntry(BUNDLE_LOCALIZATION, MANIFEST_BUNDLE_LOCALIZATION_BASENAME);
} else {
getLog().info("NOT adding source bundle manifest entries. Incomplete or no bundle information available.");
}
}
use of org.eclipse.tycho.ArtifactKey in project tycho by eclipse.
the class TestMojo method createEclipseInstallation.
private EquinoxInstallation createEclipseInstallation() throws MojoExecutionException {
DependencyResolver platformResolver = dependencyResolverLocator.lookupDependencyResolver(project);
final List<Dependency> extraDependencies = getExtraDependencies();
List<ReactorProject> reactorProjects = getReactorProjects();
final DependencyResolverConfiguration resolverConfiguration = new DependencyResolverConfiguration() {
@Override
public OptionalResolutionAction getOptionalResolutionAction() {
return OptionalResolutionAction.IGNORE;
}
@Override
public List<Dependency> getExtraRequirements() {
return extraDependencies;
}
};
DependencyArtifacts testRuntimeArtifacts = platformResolver.resolveDependencies(session, project, null, reactorProjects, resolverConfiguration);
if (testRuntimeArtifacts == null) {
throw new MojoExecutionException("Cannot determinate build target platform location -- not executing tests");
}
work.mkdirs();
EquinoxInstallationDescription testRuntime = new DefaultEquinoxInstallationDescription();
testRuntime.setDefaultBundleStartLevel(defaultStartLevel);
testRuntime.addBundlesToExplode(getBundlesToExplode());
testRuntime.addFrameworkExtensions(getFrameworkExtensions());
if (bundleStartLevel != null) {
for (BundleStartLevel level : bundleStartLevel) {
testRuntime.addBundleStartLevel(level);
}
}
TestFrameworkProvider provider = providerHelper.selectProvider(getProjectType().getClasspath(project), getMergedProviderProperties(), providerHint);
createSurefireProperties(provider);
for (ArtifactDescriptor artifact : testRuntimeArtifacts.getArtifacts(ArtifactType.TYPE_ECLIPSE_PLUGIN)) {
// note that this project is added as directory structure rooted at project basedir.
// project classes and test-classes are added via dev.properties file (see #createDevProperties())
// all other projects are added as bundle jars.
ReactorProject otherProject = artifact.getMavenProject();
if (otherProject != null) {
if (otherProject.sameProject(project)) {
testRuntime.addBundle(artifact.getKey(), project.getBasedir());
continue;
}
File file = otherProject.getArtifact(artifact.getClassifier());
if (file != null) {
testRuntime.addBundle(artifact.getKey(), file);
continue;
}
}
testRuntime.addBundle(artifact);
}
Set<Artifact> testFrameworkBundles = providerHelper.filterTestFrameworkBundles(provider, pluginArtifacts);
for (Artifact artifact : testFrameworkBundles) {
DevBundleInfo devInfo = workspaceState.getBundleInfo(session, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), project.getPluginArtifactRepositories());
if (devInfo != null) {
testRuntime.addBundle(devInfo.getArtifactKey(), devInfo.getLocation(), true);
testRuntime.addDevEntries(devInfo.getSymbolicName(), devInfo.getDevEntries());
} else {
File bundleLocation = artifact.getFile();
ArtifactKey bundleArtifactKey = getBundleArtifactKey(bundleLocation);
testRuntime.addBundle(bundleArtifactKey, bundleLocation, true);
}
}
testRuntime.addDevEntries(getTestBundleSymbolicName(), getBuildOutputDirectories());
reportsDirectory.mkdirs();
return installationFactory.createInstallation(testRuntime, work);
}
use of org.eclipse.tycho.ArtifactKey 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;
}
Aggregations