use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class DefaultTargetPlatformConfigurationReader method addTargetEnvironments.
private void addTargetEnvironments(TargetPlatformConfiguration result, MavenProject project, Xpp3Dom configuration) {
try {
TargetEnvironment deprecatedTargetEnvironmentSpec = getDeprecatedTargetEnvironment(configuration);
if (deprecatedTargetEnvironmentSpec != null) {
result.addEnvironment(deprecatedTargetEnvironmentSpec);
}
Xpp3Dom environmentsDom = configuration.getChild("environments");
if (environmentsDom != null) {
if (deprecatedTargetEnvironmentSpec != null) {
String message = "Deprecated target-platform-configuration <environment> element must not be combined with new <environments> element; check the (inherited) configuration of " + project.getId();
throw new RuntimeException(message);
}
for (Xpp3Dom environmentDom : environmentsDom.getChildren("environment")) {
result.addEnvironment(newTargetEnvironment(environmentDom));
}
}
} catch (TargetPlatformConfigurationException e) {
throw new RuntimeException("target-platform-configuration error in project " + project.getId(), e);
}
}
use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class P2DependencyResolver method setupProjects.
@Override
public void setupProjects(final MavenSession session, final MavenProject project, final ReactorProject reactorProject) {
TargetPlatformConfiguration configuration = (TargetPlatformConfiguration) project.getContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION);
List<TargetEnvironment> environments = configuration.getEnvironments();
Map<String, IDependencyMetadata> metadata = getDependencyMetadata(session, project, environments, OptionalResolutionAction.OPTIONAL);
Set<Object> primaryMetadata = new LinkedHashSet<>();
Set<Object> secondaryMetadata = new LinkedHashSet<>();
for (Map.Entry<String, IDependencyMetadata> entry : metadata.entrySet()) {
primaryMetadata.addAll(entry.getValue().getMetadata(true));
secondaryMetadata.addAll(entry.getValue().getMetadata(false));
}
reactorProject.setDependencyMetadata(true, primaryMetadata);
reactorProject.setDependencyMetadata(false, secondaryMetadata);
}
use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class P2DependencyResolver method doResolveDependencies.
private DependencyArtifacts doResolveDependencies(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects, DependencyResolverConfiguration resolverConfiguration, TargetPlatform targetPlatform, P2Resolver resolver, TargetPlatformConfiguration configuration) {
Map<File, ReactorProject> projects = new HashMap<>();
resolver.setEnvironments(configuration.getEnvironments());
resolver.setAdditionalFilterProperties(configuration.getProfileProperties());
for (ReactorProject otherProject : reactorProjects) {
projects.put(otherProject.getBasedir(), otherProject);
}
if (resolverConfiguration != null) {
for (Dependency dependency : resolverConfiguration.getExtraRequirements()) {
try {
resolver.addDependency(dependency.getType(), dependency.getArtifactId(), dependency.getVersion());
} catch (IllegalArtifactReferenceException e) {
throw new BuildFailureException("Invalid extraRequirement " + dependency.getType() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion() + ": " + e.getMessage(), e);
}
}
}
// get reactor project with prepared optional dependencies // TODO use original IU and have the resolver create the modified IUs
ReactorProject optionalDependencyPreparedProject = getThisReactorProject(session, project, configuration);
if (!isAllowConflictingDependencies(project, configuration)) {
List<P2ResolutionResult> results = resolver.resolveDependencies(targetPlatform, optionalDependencyPreparedProject);
MultiEnvironmentDependencyArtifacts multiPlatform = new MultiEnvironmentDependencyArtifacts(DefaultReactorProject.adapt(project));
// FIXME this is just wrong
for (int i = 0; i < configuration.getEnvironments().size(); i++) {
TargetEnvironment environment = configuration.getEnvironments().get(i);
P2ResolutionResult result = results.get(i);
DefaultDependencyArtifacts platform = newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
multiPlatform.addPlatform(environment, platform);
}
return multiPlatform;
} else {
P2ResolutionResult result = resolver.collectProjectDependencies(targetPlatform, optionalDependencyPreparedProject);
return newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
}
}
use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class ProductExportMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().warn("The packaging type 'eclipse-application' is deprecated; use 'eclipse-repository' instead. " + "See http://wiki.eclipse.org/Tycho_Messages_Explained#Eclipse_Application");
if (!productConfigurationFile.exists()) {
throw new MojoExecutionException("Product configuration file not found " + productConfigurationFile.getAbsolutePath());
}
try {
getLog().debug("Parsing productConfiguration");
productConfiguration = ProductConfiguration.read(productConfigurationFile);
} catch (IOException e) {
throw new MojoExecutionException("Error reading product configuration file", e);
}
// build results will vary from system to system without explicit target environment configuration
boolean implicitTargetEnvironment = TychoProjectUtils.getTargetPlatformConfiguration(project).isImplicitTargetEnvironment();
if (productConfiguration.includeLaunchers() && implicitTargetEnvironment && environments == null) {
throw new MojoFailureException("Product includes native launcher but no target environment was specified");
}
if (separateEnvironments) {
for (TargetEnvironment environment : getEnvironments()) {
File target = getTarget(environment);
File targetEclipse = new File(target, "eclipse");
targetEclipse.mkdirs();
generateDotEclipseProduct(targetEclipse);
generateConfigIni(environment, targetEclipse);
includeRootFiles(environment, targetEclipse);
ProductAssembler assembler = new ProductAssembler(session, manifestReader, targetEclipse, environment);
assembler.setIncludeSources(includeSources);
getDependencyWalker(environment).walk(assembler);
if (productConfiguration.includeLaunchers()) {
copyExecutable(environment, targetEclipse);
}
if (createProductArchive) {
createProductArchive(target, toString(environment));
}
}
} else {
File target = getTarget(null);
File targetEclipse = new File(target, "eclipse");
targetEclipse.mkdirs();
generateDotEclipseProduct(targetEclipse);
generateConfigIni(null, targetEclipse);
for (TargetEnvironment environment : getEnvironments()) {
includeRootFiles(environment, targetEclipse);
}
ProductAssembler assembler = new ProductAssembler(session, manifestReader, targetEclipse, null);
assembler.setIncludeSources(includeSources);
if (forcePackedDependencies) {
assembler.setUnpackFeatures(false);
assembler.setUnpackPlugins(false);
}
getDependencyWalker().walk(assembler);
if (productConfiguration.includeLaunchers()) {
for (TargetEnvironment environment : getEnvironments()) {
copyExecutable(environment, targetEclipse);
}
}
if (createProductArchive) {
createProductArchive(target, null);
}
}
try {
ProductConfiguration.write(productConfiguration, expandedProductFile);
if (p2inf.canRead()) {
FileUtils.copyFile(p2inf, new File(expandedProductFile.getParentFile(), p2inf.getName()));
}
} catch (IOException e) {
throw new MojoExecutionException("Error writing expanded product configuration file", e);
}
if (!createProductArchive || environments != null) {
project.getArtifact().setFile(expandedProductFile);
}
}
use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.
the class TargetDefinitionResolverWithPlatformSpecificUnitsTest method testSlicerResolutionWithMultiplePlatforms.
@Test
public void testSlicerResolutionWithMultiplePlatforms() throws Exception {
List<TargetEnvironment> environments = Arrays.asList(new TargetEnvironment("win32", "win32", "x86"), new TargetEnvironment("macosx", "carbon", "x86"));
targetDefinition = definitionWith(new FilterRepoLocationStubWithLauncherUnit(IncludeMode.SLICER));
subject = createResolver(environments);
TargetDefinitionContent units = subject.resolveContent(targetDefinition);
assertThat(versionedIdsOf(units), bagEquals(versionedIdList(LAUNCHER_FEATURE, LAUNCHER_FEATURE_JAR, LAUNCHER_BUNDLE, LAUNCHER_BUNDLE_WINDOWS, LAUNCHER_BUNDLE_MAC)));
}
Aggregations