Search in sources :

Example 1 with TargetPlatform

use of org.eclipse.tycho.artifacts.TargetPlatform in project tycho by eclipse.

the class ReactorRepositoryManagerImpl method computePreliminaryTargetPlatform.

@Override
public TargetPlatform computePreliminaryTargetPlatform(ReactorProject project, TargetPlatformConfigurationStub tpConfiguration, ExecutionEnvironmentConfiguration eeConfiguration, List<ReactorProject> reactorProjects, PomDependencyCollector pomDependencies) {
    // at this point, there is only incomplete ("dependency-only") metadata for the reactor projects
    TargetPlatform result = tpFactory.createTargetPlatform(tpConfiguration, eeConfiguration, reactorProjects, pomDependencies);
    project.setContextValue(PRELIMINARY_TARGET_PLATFORM_KEY, result);
    return result;
}
Also used : P2TargetPlatform(org.eclipse.tycho.p2.target.P2TargetPlatform) TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform)

Example 2 with TargetPlatform

use of org.eclipse.tycho.artifacts.TargetPlatform in project tycho by eclipse.

the class PackageIUMojo method expandVersions.

private void expandVersions(IU iu) throws MojoFailureException {
    iuTransformer.replaceSelfQualifiers(iu, DefaultReactorProject.adapt(project).getExpandedVersion(), DefaultReactorProject.adapt(project).getBuildQualifier());
    iuTransformer.replaceQualifierInCapabilities(iu.getProvidedCapabilites(), DefaultReactorProject.adapt(project).getBuildQualifier());
    TargetPlatform targetPlatform = TychoProjectUtils.getTargetPlatformIfAvailable(project);
    if (targetPlatform == null) {
        getLog().warn("Skipping version reference expansion in p2iu project using the deprecated -Dtycho.targetPlatform configuration");
        return;
    }
    iuTransformer.replaceZerosInRequirements(iu, targetPlatform);
    iuTransformer.replaceQualifierInRequirements(iu, targetPlatform);
}
Also used : TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform)

Example 3 with TargetPlatform

use of org.eclipse.tycho.artifacts.TargetPlatform in project tycho by eclipse.

the class DefaultTychoResolver method resolveProject.

@Override
public void resolveProject(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects) {
    AbstractTychoProject dr = (AbstractTychoProject) projectTypes.get(project.getPackaging());
    if (dr == null) {
        return;
    }
    DependencyResolver resolver = dependencyResolverLocator.lookupDependencyResolver(project);
    logger.info("Computing target platform for " + project);
    TargetPlatform preliminaryTargetPlatform = resolver.computePreliminaryTargetPlatform(session, project, reactorProjects);
    TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
    DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration();
    logger.info("Resolving dependencies of " + project);
    DependencyArtifacts dependencyArtifacts = resolver.resolveDependencies(session, project, preliminaryTargetPlatform, reactorProjects, resolverConfiguration);
    if (logger.isDebugEnabled() && DebugUtils.isDebugEnabled(session, project)) {
        StringBuilder sb = new StringBuilder();
        sb.append("Resolved target platform for ").append(project).append("\n");
        dependencyArtifacts.toDebugString(sb, "  ");
        logger.debug(sb.toString());
    }
    dr.setDependencyArtifacts(session, project, dependencyArtifacts);
    logger.info("Resolving class path of " + project);
    dr.resolveClassPath(session, project);
    resolver.injectDependenciesIntoMavenModel(project, dr, dependencyArtifacts, logger);
    if (logger.isDebugEnabled() && DebugUtils.isDebugEnabled(session, project)) {
        StringBuilder sb = new StringBuilder();
        sb.append("Injected dependencies for ").append(project.toString()).append("\n");
        for (Dependency dependency : project.getDependencies()) {
            sb.append("  ").append(dependency.toString());
        }
        logger.debug(sb.toString());
    }
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) AbstractTychoProject(org.eclipse.tycho.core.osgitools.AbstractTychoProject) TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform) Dependency(org.apache.maven.model.Dependency) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) DependencyResolverConfiguration(org.eclipse.tycho.core.DependencyResolverConfiguration) DependencyResolver(org.eclipse.tycho.core.DependencyResolver)

Example 4 with TargetPlatform

use of org.eclipse.tycho.artifacts.TargetPlatform in project tycho by eclipse.

the class RepositoryReferenceTool method addTargetPlatformRepository.

/**
 * Restores the p2 metadata view on the module's build target platform that was calculated
 * during the initial dependency resolution (see
 * org.eclipse.tycho.p2.resolver.P2ResolverImpl.toResolutionResult(...)).
 */
private void addTargetPlatformRepository(RepositoryReferences sources, MavenSession session, MavenProject project) throws MojoExecutionException, MojoFailureException {
    try {
        File repositoryLocation = new File(project.getBuild().getDirectory(), "targetPlatformRepository");
        repositoryLocation.mkdirs();
        FileOutputStream stream = new FileOutputStream(new File(repositoryLocation, "content.xml"));
        try {
            MetadataSerializable serializer = osgiServices.getService(MetadataSerializable.class);
            TargetPlatform targetPlatform = TychoProjectUtils.getTargetPlatform(project);
            DependencyResolver resolver = dependencyResolverLocator.lookupDependencyResolver(project);
            TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
            DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration();
            DependencyArtifacts dependencyArtifacts = resolver.resolveDependencies(session, project, targetPlatform, DefaultReactorProject.adapt(session), resolverConfiguration);
            // this contains dependency-only metadata for 'this' project
            Set<Object> targetPlatformInstallableUnits = new HashSet<>(dependencyArtifacts.getInstallableUnits());
            for (ArtifactDescriptor artifact : dependencyArtifacts.getArtifacts()) {
                ReactorProject otherProject = artifact.getMavenProject();
                if (otherProject == null) {
                    // can't really happen
                    continue;
                }
                File artifactXml = otherProject.getArtifact(RepositoryLayoutHelper.CLASSIFIER_P2_ARTIFACTS);
                if (artifactXml != null && artifactXml.isFile()) {
                    sources.addArtifactRepository(artifactXml.getParentFile());
                }
            }
            serializer.serialize(stream, targetPlatformInstallableUnits);
        } finally {
            stream.close();
        }
        sources.addMetadataRepository(repositoryLocation);
    } catch (IOException e) {
        throw new MojoExecutionException("I/O exception while writing the build target platform to disk", e);
    }
}
Also used : DependencyArtifacts(org.eclipse.tycho.artifacts.DependencyArtifacts) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ReactorProject(org.eclipse.tycho.ReactorProject) IOException(java.io.IOException) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) DependencyResolverConfiguration(org.eclipse.tycho.core.DependencyResolverConfiguration) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) MetadataSerializable(org.eclipse.tycho.p2.metadata.MetadataSerializable) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) FileOutputStream(java.io.FileOutputStream) TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform) File(java.io.File) HashSet(java.util.HashSet)

Example 5 with TargetPlatform

use of org.eclipse.tycho.artifacts.TargetPlatform in project tycho by eclipse.

the class FeatureXmlTransformerTest method testExpandReferences.

@SuppressWarnings("deprecation")
@Test
public void testExpandReferences() throws Exception {
    subject = new FeatureXmlTransformer(new SilentLog(), new NoopFileLockService());
    Feature feature = Feature.read(new File(TestUtil.getBasedir("projects/featureXmlVersionExpansion/"), "feature.xml"));
    TargetPlatform tp = mock(TargetPlatform.class);
    when(tp.resolveArtifact("eclipse-feature", "org.eclipse.rcp", "4.5.0.qualifier")).thenReturn(rcpFeatureInTP);
    when(tp.resolveArtifact("eclipse-plugin", "org.junit4", "4.8.1.qualifier")).thenReturn(junit4InTP);
    when(tp.getArtifactLocation(junit4InTP)).thenReturn(junit4JarLocation);
    subject.expandReferences(feature, tp);
    assertThat(feature.getIncludedFeatures(), hasItem(feature("org.eclipse.rcp", "4.5.0.v20140918")));
    assertThat(feature.getPlugins(), hasItem(plugin("org.junit4", "4.8.1.v20100302")));
    PluginRef plugin = feature.getPlugins().get(0);
    assertThat(plugin.getId(), is("org.junit4"));
    // 1720 bytes rounded to kiB
    assertThat(plugin.getDownloadSize(), is(1L));
    // 2419 bytes rounded to kiB // TODO shouldn't installSize=downloadSize for unpack=false?
    assertThat(plugin.getInstallSize(), is(2L));
    assertThat(plugin.isUnpack(), is(false));
}
Also used : SilentLog(org.apache.maven.plugin.testing.SilentLog) PluginRef(org.eclipse.tycho.model.PluginRef) NoopFileLockService(org.eclipse.tycho.test.util.NoopFileLockService) TargetPlatform(org.eclipse.tycho.artifacts.TargetPlatform) Feature(org.eclipse.tycho.model.Feature) File(java.io.File) Test(org.junit.Test)

Aggregations

TargetPlatform (org.eclipse.tycho.artifacts.TargetPlatform)7 File (java.io.File)3 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)2 DependencyResolver (org.eclipse.tycho.core.DependencyResolver)2 DependencyResolverConfiguration (org.eclipse.tycho.core.DependencyResolverConfiguration)2 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)2 Test (org.junit.Test)2 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Dependency (org.apache.maven.model.Dependency)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 SilentLog (org.apache.maven.plugin.testing.SilentLog)1 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)1 ReactorProject (org.eclipse.tycho.ReactorProject)1 AbstractTychoProject (org.eclipse.tycho.core.osgitools.AbstractTychoProject)1 DefaultReactorProject (org.eclipse.tycho.core.osgitools.DefaultReactorProject)1 Feature (org.eclipse.tycho.model.Feature)1 IU (org.eclipse.tycho.model.IU)1 PluginRef (org.eclipse.tycho.model.PluginRef)1