Search in sources :

Example 6 with DependencyArtifacts

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;
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) LegacySupport(org.apache.maven.plugin.LegacySupport) MavenExecutionResult(org.apache.maven.execution.MavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) DefaultMavenExecutionResult(org.apache.maven.execution.DefaultMavenExecutionResult) MavenExecutionRequest(org.apache.maven.execution.MavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DefaultMavenExecutionRequest(org.apache.maven.execution.DefaultMavenExecutionRequest) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) MavenSession(org.apache.maven.execution.MavenSession) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) DefaultRepositorySystemSession(org.sonatype.aether.util.DefaultRepositorySystemSession) MavenProject(org.apache.maven.project.MavenProject) StubArtifactRepository(org.apache.maven.plugin.testing.stubs.StubArtifactRepository)

Example 7 with DependencyArtifacts

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);
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) File(java.io.File)

Example 8 with DependencyArtifacts

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);
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) BundleStartLevel(org.eclipse.sisu.equinox.launching.BundleStartLevel) ArtifactKey(org.eclipse.tycho.ArtifactKey) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) Dependency(org.apache.maven.model.Dependency) DependencyResolverConfiguration(org.eclipse.tycho.core.DependencyResolverConfiguration) Artifact(org.apache.maven.artifact.Artifact) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) EquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription) DefaultEquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.DefaultEquinoxInstallationDescription) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) DevBundleInfo(org.eclipse.tycho.dev.DevBundleInfo) DefaultEquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.DefaultEquinoxInstallationDescription) TestFrameworkProvider(org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider) File(java.io.File)

Example 9 with DependencyArtifacts

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) {
        }
    };
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) ArtifactKey(org.eclipse.tycho.ArtifactKey) ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) ReactorProject(org.eclipse.tycho.ReactorProject) ArtifactDependencyWalker(org.eclipse.tycho.core.ArtifactDependencyWalker) Feature(org.eclipse.tycho.model.Feature) ArtifactDependencyVisitor(org.eclipse.tycho.core.ArtifactDependencyVisitor) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ClasspathEntry(org.eclipse.tycho.classpath.ClasspathEntry) File(java.io.File) PluginDescription(org.eclipse.tycho.core.PluginDescription) UpdateSite(org.eclipse.tycho.model.UpdateSite)

Example 10 with DependencyArtifacts

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);
        }
    }
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) FileLocker(org.eclipse.tycho.locking.facade.FileLocker) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) File(java.io.File)

Aggregations

DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)16 File (java.io.File)13 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)8 MavenProject (org.apache.maven.project.MavenProject)5 DependencyResolver (org.eclipse.tycho.core.DependencyResolver)5 BundleDescription (org.eclipse.osgi.service.resolver.BundleDescription)4 State (org.eclipse.osgi.service.resolver.State)4 ReactorProject (org.eclipse.tycho.ReactorProject)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 ArtifactKey (org.eclipse.tycho.ArtifactKey)3 DependencyResolverConfiguration (org.eclipse.tycho.core.DependencyResolverConfiguration)3 DependencyEntry (org.eclipse.tycho.core.osgitools.DependencyComputer.DependencyEntry)3 DefaultMavenExecutionRequest (org.apache.maven.execution.DefaultMavenExecutionRequest)2 DefaultMavenExecutionResult (org.apache.maven.execution.DefaultMavenExecutionResult)2 MavenExecutionRequest (org.apache.maven.execution.MavenExecutionRequest)2 MavenExecutionResult (org.apache.maven.execution.MavenExecutionResult)2 MavenSession (org.apache.maven.execution.MavenSession)2 Dependency (org.apache.maven.model.Dependency)2 LegacySupport (org.apache.maven.plugin.LegacySupport)2 StubArtifactRepository (org.apache.maven.plugin.testing.stubs.StubArtifactRepository)2