Search in sources :

Example 16 with TargetPlatformConfiguration

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;
}
Also used : LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver) ComponentLookupException(org.codehaus.plexus.component.repository.exception.ComponentLookupException) IOException(java.io.IOException) Properties(java.util.Properties) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) File(java.io.File) DependencyResolver(org.eclipse.tycho.core.DependencyResolver) LocalDependencyResolver(org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver)

Example 17 with TargetPlatformConfiguration

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()]);
}
Also used : TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration)

Example 18 with TargetPlatformConfiguration

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>");
    }
}
Also used : TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration)

Example 19 with TargetPlatformConfiguration

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;
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TychoProject(org.eclipse.tycho.core.TychoProject) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Properties(java.util.Properties) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Plugin(org.apache.maven.model.Plugin)

Example 20 with TargetPlatformConfiguration

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);
}
Also used : ExecutionEnvironmentConfiguration(org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration) AbstractTychoProject(org.eclipse.tycho.core.osgitools.AbstractTychoProject) Properties(java.util.Properties) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) ExecutionEnvironmentConfigurationImpl(org.eclipse.tycho.core.ee.ExecutionEnvironmentConfigurationImpl) DependencyResolver(org.eclipse.tycho.core.DependencyResolver)

Aggregations

TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)25 File (java.io.File)8 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)8 Test (org.junit.Test)7 MavenSession (org.apache.maven.execution.MavenSession)6 BuildFailureException (org.eclipse.tycho.core.shared.BuildFailureException)6 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)6 Properties (java.util.Properties)4 DependencyResolver (org.eclipse.tycho.core.DependencyResolver)4 Dependency (org.apache.maven.model.Dependency)3 MavenProject (org.apache.maven.project.MavenProject)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)2 ReactorProject (org.eclipse.tycho.ReactorProject)2 DependencyArtifacts (org.eclipse.tycho.artifacts.DependencyArtifacts)2 TargetPlatform (org.eclipse.tycho.artifacts.TargetPlatform)2 DependencyResolverConfiguration (org.eclipse.tycho.core.DependencyResolverConfiguration)2 ExecutionEnvironmentConfiguration (org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration)2