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;
}
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);
}
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());
}
}
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);
}
}
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));
}
Aggregations