use of org.eclipse.tycho.artifacts.DependencyArtifacts in project tycho by eclipse.
the class LocalDependencyResolverTest method getTargetPlatform.
protected DependencyArtifacts getTargetPlatform(File location) throws Exception, IOException {
LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
MavenExecutionRequest request = new DefaultMavenExecutionRequest();
request.setLocalRepository(new StubArtifactRepository(location.getAbsolutePath()));
MavenExecutionResult result = new DefaultMavenExecutionResult();
DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession();
MavenSession session = new MavenSession(getContainer(), repositorySession, request, result);
session.setProjects(new ArrayList<MavenProject>());
lookup(LegacySupport.class).setSession(session);
MavenProject project = new MavenProject();
resolver.setLocation(location);
DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, DefaultReactorProject.adapt(session), null);
return platform;
}
use of org.eclipse.tycho.artifacts.DependencyArtifacts in project tycho by eclipse.
the class LocalDependencyResolverTest method testPlatformRelativePath.
public void testPlatformRelativePath() throws Exception {
File platformPath = new File("src/test/resources/targetplatforms/basic");
DependencyArtifacts platform = getTargetPlatform(platformPath);
// absolute path to a bundle
File bundlePath = new File(platformPath, "plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar").getAbsoluteFile();
Map<String, ArtifactDescriptor> artifact = platform.getArtifact(bundlePath);
assertNotNull(artifact);
}
use of org.eclipse.tycho.artifacts.DependencyArtifacts 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.artifacts.DependencyArtifacts 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.artifacts.DependencyArtifacts in project tycho by eclipse.
the class PublishProductMojo method getExpandedLauncherBinaries.
private File getExpandedLauncherBinaries() throws MojoExecutionException, MojoFailureException {
// TODO 364134 take the executable feature from the target platform instead
DependencyArtifacts dependencyArtifacts = TychoProjectUtils.getDependencyArtifacts(getProject());
ArtifactDescriptor artifact = dependencyArtifacts.getArtifact(ArtifactType.TYPE_ECLIPSE_FEATURE, "org.eclipse.equinox.executable", null);
if (artifact == null) {
throw new MojoExecutionException("Unable to locate feature 'org.eclipse.equinox.executable'. This feature is required for native product launchers.");
}
checkMacOSLauncherCompatibility(artifact);
File equinoxExecFeature = artifact.getLocation();
if (equinoxExecFeature.isDirectory()) {
return equinoxExecFeature.getAbsoluteFile();
} else {
File unzipped = new File(getProject().getBuild().getDirectory(), artifact.getKey().getId() + "-" + artifact.getKey().getVersion());
if (unzipped.exists()) {
return unzipped.getAbsoluteFile();
}
try {
FileLocker locker = fileLockService.getFileLocker(equinoxExecFeature);
locker.lock();
try {
// unzip now then:
unzipped.mkdirs();
deflater.setSourceFile(equinoxExecFeature);
deflater.setDestDirectory(unzipped);
deflater.extract();
return unzipped.getAbsoluteFile();
} finally {
locker.release();
}
} catch (ArchiverException e) {
throw new MojoFailureException("Unable to unzip the eqiuinox executable feature", e);
}
}
}
Aggregations