Search in sources :

Example 1 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class ReactorRepositoryManagerTest method testTargetPlatformComputationInIntegration.

@Test
public void testTargetPlatformComputationInIntegration() throws Exception {
    subject = getService(ReactorRepositoryManagerFacade.class);
    ReactorProject currentProject = new ReactorProjectStub("reactor-artifact");
    TargetPlatformConfigurationStub tpConfig = new TargetPlatformConfigurationStub();
    tpConfig.addP2Repository(new MavenRepositoryLocation(null, ResourceUtil.resourceFile("repositories/launchers").toURI()));
    subject.computePreliminaryTargetPlatform(currentProject, tpConfig, new ExecutionEnvironmentConfigurationStub("JavaSE-1.7"), null, null);
    ReactorProjectIdentities upstreamProject = new ReactorProjectIdentitiesStub(ResourceUtil.resourceFile("projectresult"));
    subject.computeFinalTargetPlatform(currentProject, Arrays.asList(upstreamProject));
    P2TargetPlatform finalTP = (P2TargetPlatform) currentProject.getContextValue("org.eclipse.tycho.core.TychoConstants/targetPlatform");
    Collection<IInstallableUnit> units = finalTP.getInstallableUnits();
    // units from the p2 repository
    assertThat(units, hasItem(unitWithId("org.eclipse.equinox.launcher")));
    // units from the upstream project
    assertThat(units, hasItem(unitWithId("bundle")));
    assertThat(units, hasItem(unitWithId("bundle.source")));
// TODO get artifact
}
Also used : ReactorRepositoryManagerFacade(org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManagerFacade) TargetPlatformConfigurationStub(org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub) ExecutionEnvironmentConfigurationStub(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfigurationStub) MavenRepositoryLocation(org.eclipse.tycho.core.resolver.shared.MavenRepositoryLocation) ReactorProjectIdentitiesStub(org.eclipse.tycho.test.util.ReactorProjectIdentitiesStub) ReactorProject(org.eclipse.tycho.ReactorProject) ReactorProjectStub(org.eclipse.tycho.p2.impl.test.ReactorProjectStub) P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) ReactorProjectIdentities(org.eclipse.tycho.ReactorProjectIdentities) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) Test(org.junit.Test)

Example 2 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class DefaultDependencyArtifactsTest method testDoNotCacheArtifactsThatRepresentReactorProjects.

@Test
public void testDoNotCacheArtifactsThatRepresentReactorProjects() {
    // IInstallableUnit #hashCode and #equals methods only use (version,id) tuple to determine IU equality
    // Reactor projects are expected to produce different IUs potentially with the same (version,id) during the build
    // This test verifies that different DefaultTargetPlatform can have the same reactor project with different IUs
    // even when IUs (version,id) are the same
    ReactorProject project = new DefaultReactorProject(new MavenProject());
    ArtifactKey key = new DefaultArtifactKey("type", "id", "version");
    File location = new File("location");
    DefaultDependencyArtifacts tp1 = new DefaultDependencyArtifacts();
    tp1.addArtifact(new DefaultArtifactDescriptor(key, location, project, null, asSet(new FunnyEquals("id", "a"))));
    DefaultDependencyArtifacts tp2 = new DefaultDependencyArtifacts();
    tp2.addArtifact(new DefaultArtifactDescriptor(key, location, project, null, asSet(new FunnyEquals("id", "b"))));
    // 
    Assert.assertEquals(// 
    "a", ((FunnyEquals) tp1.getArtifact(location).get(null).getInstallableUnits().iterator().next()).getData());
    // 
    Assert.assertEquals(// 
    "b", ((FunnyEquals) tp2.getArtifact(location).get(null).getInstallableUnits().iterator().next()).getData());
}
Also used : DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) ArtifactKey(org.eclipse.tycho.ArtifactKey) MavenProject(org.apache.maven.project.MavenProject) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) DefaultArtifactDescriptor(org.eclipse.tycho.core.osgitools.DefaultArtifactDescriptor) DefaultArtifactKey(org.eclipse.tycho.DefaultArtifactKey) File(java.io.File) Test(org.junit.Test)

Example 3 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class TestMojo method getBuildOutputDirectories.

private String getBuildOutputDirectories() {
    StringBuilder sb = new StringBuilder();
    ReactorProject reactorProject = getReactorProject();
    sb.append(reactorProject.getOutputDirectory());
    sb.append(',').append(reactorProject.getTestOutputDirectory());
    for (BuildOutputJar outputJar : osgiBundle.getEclipsePluginProject(reactorProject).getOutputJars()) {
        if (".".equals(outputJar.getName())) {
            // handled above
            continue;
        }
        appendCommaSeparated(sb, outputJar.getOutputDirectory().getAbsolutePath());
    }
    return sb.toString();
}
Also used : BuildOutputJar(org.eclipse.tycho.core.osgitools.project.BuildOutputJar) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject)

Example 4 with ReactorProject

use of org.eclipse.tycho.ReactorProject 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 5 with ReactorProject

use of org.eclipse.tycho.ReactorProject in project tycho by eclipse.

the class TargetPlatformMojo method getTransitivelyReferencedTychoProjects.

private void getTransitivelyReferencedTychoProjects(Collection<MavenProject> candidateProjects, HashSet<GAV> consideredProjects, List<ReactorProjectIdentities> result) throws MojoExecutionException {
    for (MavenProject reactorProject : candidateProjects) {
        if (!enterProject(reactorProject, consideredProjects)) {
            continue;
        }
        // check for target platform relevant build results (registered by either p2-metadata-default or attach-artifacts)
        File metadataXml = getAttachedArtifact(reactorProject, RepositoryLayoutHelper.CLASSIFIER_P2_METADATA);
        if (metadataXml == null) {
            continue;
        }
        File artifactXml = getAttachedArtifact(reactorProject, RepositoryLayoutHelper.CLASSIFIER_P2_ARTIFACTS);
        // found a Tycho project -> include in target platform
        logger.debug("Adding reactor project: " + reactorProject.toString());
        ReactorProject tychoReactorProject = DefaultReactorProject.adapt(reactorProject);
        verifyIndexFileLocations(tychoReactorProject, metadataXml, artifactXml);
        result.add(tychoReactorProject.getIdentities());
        getTransitivelyReferencedTychoProjects(reactorProject.getProjectReferences().values(), consideredProjects, result);
    }
}
Also used : MavenProject(org.apache.maven.project.MavenProject) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) File(java.io.File)

Aggregations

ReactorProject (org.eclipse.tycho.ReactorProject)32 File (java.io.File)20 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)16 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)10 ArtifactKey (org.eclipse.tycho.ArtifactKey)8 MavenProject (org.apache.maven.project.MavenProject)6 ArrayList (java.util.ArrayList)5 HashMap (java.util.HashMap)5 LinkedHashSet (java.util.LinkedHashSet)4 Artifact (org.apache.maven.artifact.Artifact)4 Dependency (org.apache.maven.model.Dependency)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 DefaultArtifactKey (org.eclipse.tycho.DefaultArtifactKey)4 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)4 DefaultDependencyArtifacts (org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts)4 Test (org.junit.Test)4 IOException (java.io.IOException)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)3