use of org.eclipse.tycho.core.TargetPlatformConfiguration 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.core.TargetPlatformConfiguration in project tycho by eclipse.
the class TychoTest method testImplicitTargetEnvironment.
public void testImplicitTargetEnvironment() throws Exception {
File basedir = getBasedir("projects/implicitenvironment/simple");
List<MavenProject> projects = getSortedProjects(basedir);
assertEquals(1, projects.size());
// assertEquals("ambiguous", projects.get(0).getArtifactId());
// assertEquals("none", projects.get(0).getArtifactId());
assertEquals("simple", projects.get(0).getArtifactId());
DefaultTargetPlatformConfigurationReader resolver = lookup(DefaultTargetPlatformConfigurationReader.class);
MavenSession session;
TargetPlatformConfiguration configuration;
List<TargetEnvironment> environments;
// ambiguous
// session = newMavenSession(projects.get(0), projects);
// configuration = resolver.getTargetPlatformConfiguration(session, session.getCurrentProject());
// environments = configuration.getEnvironments();
// assertEquals(0, environments.size());
// none
// session = newMavenSession(projects.get(0), projects);
// configuration = resolver.getTargetPlatformConfiguration(session, session.getCurrentProject());
// environments = configuration.getEnvironments();
// assertEquals(0, environments.size());
// simple
session = newMavenSession(projects.get(0), projects);
configuration = resolver.getTargetPlatformConfiguration(session, session.getCurrentProject());
environments = configuration.getEnvironments();
assertEquals(1, environments.size());
TargetEnvironment env = environments.get(0);
assertEquals("foo", env.getOs());
assertEquals("bar", env.getWs());
assertEquals("munchy", env.getArch());
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class P2DependencyResolver method resolveDependencies.
@Override
public DependencyArtifacts resolveDependencies(final MavenSession session, final MavenProject project, TargetPlatform targetPlatform, List<ReactorProject> reactorProjects, DependencyResolverConfiguration resolverConfiguration) {
if (targetPlatform == null) {
targetPlatform = TychoProjectUtils.getTargetPlatform(project);
}
// TODO 364134 For compatibility reasons, target-platform-configuration includes settings for the dependency resolution
// --> split this information logically, e.g. through two distinct interfaces
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
P2Resolver osgiResolverImpl = resolverFactory.createResolver(new MavenLoggerAdapter(getLogger(), DebugUtils.isDebugEnabled(session, project)));
return doResolveDependencies(session, project, reactorProjects, resolverConfiguration, targetPlatform, osgiResolverImpl, configuration);
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration 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.core.TargetPlatformConfiguration in project tycho by eclipse.
the class AssembleRepositoryMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
try {
File destination = getAssemblyRepositoryLocation();
destination.mkdirs();
copyResources(destination);
Collection<DependencySeed> projectSeeds = TychoProjectUtils.getDependencySeeds(getProject());
if (projectSeeds.size() == 0) {
throw new MojoFailureException("No content specified for p2 repository");
}
RepositoryReferences sources = getVisibleRepositories();
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(getProject());
MirrorApplicationService mirrorApp = p2.getService(MirrorApplicationService.class);
DestinationRepositoryDescriptor destinationRepoDescriptor = new DestinationRepositoryDescriptor(destination, repositoryName, compress, xzCompress, keepNonXzIndexFiles, !createArtifactRepository, true);
mirrorApp.mirrorReactor(sources, destinationRepoDescriptor, projectSeeds, getBuildContext(), includeAllDependencies, configuration.isIncludePackedArtifacts(), profileProperties);
} catch (FacadeException e) {
throw new MojoExecutionException("Could not assemble p2 repository", e);
}
}
Aggregations