use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class DefaultDependencyResolverFactory method lookupDependencyResolver.
public DependencyResolver lookupDependencyResolver(MavenProject project) {
Properties properties = (Properties) project.getContextValue(TychoConstants.CTX_MERGED_PROPERTIES);
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
String property = properties.getProperty("tycho.targetPlatform");
DependencyResolver resolver;
if (property != null) {
logger.warn("-Dtycho.targetPlatform is deprecated and WILL be removed in the next Tycho version.");
File location = new File(property);
if (!location.exists() || !location.isDirectory()) {
throw new RuntimeException("Invalid target platform location: " + property);
}
try {
resolver = container.lookup(DependencyResolver.class, LocalDependencyResolver.ROLE_HINT);
} catch (ComponentLookupException e) {
throw new RuntimeException("Could not instantiate required component", e);
}
try {
((LocalDependencyResolver) resolver).setLocation(new File(property));
} catch (IOException e) {
throw new RuntimeException("Could not create target platform", e);
}
return resolver;
}
String resolverRole = configuration.getTargetPlatformResolver();
if (resolverRole == null) {
resolverRole = DEFAULT_RESOLVER_HINT;
}
try {
resolver = container.lookup(DependencyResolver.class, resolverRole);
} catch (ComponentLookupException e) {
throw new RuntimeException("Could not instantiate required component", e);
}
return resolver;
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class AbstractTychoProject method getEnvironments.
protected TargetEnvironment[] getEnvironments(MavenProject project, TargetEnvironment environment) {
if (environment != null) {
return new TargetEnvironment[] { environment };
}
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
if (configuration.isImplicitTargetEnvironment()) {
// any
return null;
}
// all specified
List<TargetEnvironment> environments = configuration.getEnvironments();
return environments.toArray(new TargetEnvironment[environments.size()]);
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class AbstractTychoProject method readExecutionEnvironmentConfiguration.
public void readExecutionEnvironmentConfiguration(MavenProject project, ExecutionEnvironmentConfiguration sink) {
TargetPlatformConfiguration tpConfiguration = TychoProjectUtils.getTargetPlatformConfiguration(project);
String configuredForcedProfile = tpConfiguration.getExecutionEnvironment();
if (configuredForcedProfile != null) {
sink.overrideProfileConfiguration(configuredForcedProfile, "target-platform-configuration <executionEnvironment>");
}
String configuredDefaultProfile = tpConfiguration.getExecutionEnvironmentDefault();
if (configuredDefaultProfile != null) {
sink.setProfileConfiguration(configuredDefaultProfile, "target-platform-configuration <executionEnvironmentDefault>");
}
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class DefaultTargetPlatformConfigurationReader method getTargetPlatformConfiguration.
public TargetPlatformConfiguration getTargetPlatformConfiguration(MavenSession session, MavenProject project) throws BuildFailureException {
TargetPlatformConfiguration result = new TargetPlatformConfiguration();
// Use org.eclipse.tycho:target-platform-configuration/configuration/environment, if provided
Plugin plugin = project.getPlugin("org.eclipse.tycho:target-platform-configuration");
if (plugin != null) {
Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration();
if (configuration != null) {
if (logger.isDebugEnabled()) {
logger.debug("target-platform-configuration for " + project.toString() + ":\n" + configuration.toString());
}
addTargetEnvironments(result, project, configuration);
setTargetPlatformResolver(result, configuration);
setTarget(result, session, project, configuration);
setPomDependencies(result, configuration);
setAllowConflictingDependencies(result, configuration);
setDisableP2Mirrors(result, configuration);
setExecutionEnvironment(result, configuration);
setExecutionEnvironmentDefault(result, configuration);
setBREEHeaderSelectionPolicy(result, configuration);
setResolveWithEEContraints(result, configuration);
readFilters(result, configuration);
readDependencyResolutionConfiguration(result, configuration);
setIncludePackedArtifacts(result, configuration);
setTargetDefinitionIncludeSources(result, configuration);
}
}
if (result.getEnvironments().isEmpty()) {
TychoProject projectType = projectTypes.get(project.getPackaging());
if (projectType != null) {
TargetEnvironment env = projectType.getImplicitTargetEnvironment(project);
if (env != null) {
if (logger.isDebugEnabled()) {
logger.debug("Implicit target environment for " + project.toString() + ": " + env.toString());
}
result.addEnvironment(env);
}
}
}
if (result.getEnvironments().isEmpty()) {
// applying defaults
logger.warn("No explicit target runtime environment configuration. Build is platform dependent.");
// Otherwise, use project or execution properties, if provided
Properties properties = (Properties) project.getContextValue(TychoConstants.CTX_MERGED_PROPERTIES);
// Otherwise, use current system os/ws/nl/arch
String os = PlatformPropertiesUtils.getOS(properties);
String ws = PlatformPropertiesUtils.getWS(properties);
String arch = PlatformPropertiesUtils.getArch(properties);
result.addEnvironment(new TargetEnvironment(os, ws, arch));
result.setImplicitTargetEnvironment(true);
} else {
result.setImplicitTargetEnvironment(false);
}
return result;
}
use of org.eclipse.tycho.core.TargetPlatformConfiguration in project tycho by eclipse.
the class DefaultTychoResolver method setupProject.
@Override
public void setupProject(MavenSession session, MavenProject project, ReactorProject reactorProject) {
AbstractTychoProject dr = (AbstractTychoProject) projectTypes.get(project.getPackaging());
if (dr == null) {
return;
}
// skip if setup was already done
if (project.getContextValue(TychoConstants.CTX_MERGED_PROPERTIES) != null) {
return;
}
// generic Eclipse/OSGi metadata
dr.setupProject(session, project);
// p2 metadata
Properties properties = new Properties();
properties.putAll(project.getProperties());
// session wins
properties.putAll(session.getSystemProperties());
properties.putAll(session.getUserProperties());
project.setContextValue(TychoConstants.CTX_MERGED_PROPERTIES, properties);
setTychoEnvironmentProperties(properties, project);
TargetPlatformConfiguration configuration = configurationReader.getTargetPlatformConfiguration(session, project);
project.setContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION, configuration);
ExecutionEnvironmentConfiguration eeConfiguration = new ExecutionEnvironmentConfigurationImpl(logger, !configuration.isResolveWithEEConstraints());
dr.readExecutionEnvironmentConfiguration(project, eeConfiguration);
project.setContextValue(TychoConstants.CTX_EXECUTION_ENVIRONMENT_CONFIGURATION, eeConfiguration);
DependencyResolver resolver = dependencyResolverLocator.lookupDependencyResolver(project);
resolver.setupProjects(session, project, reactorProject);
}
Aggregations