Example usage for org.apache.maven.properties.internal EnvironmentUtils addEnvVars

List of usage examples for org.apache.maven.properties.internal EnvironmentUtils addEnvVars

Introduction

In this page you can find the example usage for org.apache.maven.properties.internal EnvironmentUtils addEnvVars.

Prototype

public static void addEnvVars(Properties props) 

Source Link

Document

Adds the environment variables in the form of properties whose keys are prefixed with env.

Usage

From source file:com.googlecode.ounit.executor.MavenRunner.java

License:Open Source License

protected void initialize() throws PlexusContainerException, ComponentLookupException, IOException {

    logger.setThreshold(logLevel);//  w w w.  jav a 2  s . c  o m

    if (world == null)
        world = new ClassWorld("plexus.core", Thread.currentThread().getContextClassLoader());
    ContainerConfiguration cc = new DefaultContainerConfiguration().setClassWorld(world).setName("maven");
    container = new DefaultPlexusContainer(cc);
    executionListener = new ExecutionEventLogger(logger);
    transferListener = new MavenTransferListener(logger);
    container.setLoggerManager(new MavenLoggerManager(logger));

    Thread.currentThread().setContextClassLoader(container.getContainerRealm());

    maven = container.lookup(Maven.class);
    modelProcessor = container.lookup(ModelProcessor.class);

    // A hack to mitigate the damage done by mvn -Dtest=....
    System.clearProperty("test");

    systemProperties = new Properties();
    systemProperties.putAll(System.getProperties());
    EnvironmentUtils.addEnvVars(systemProperties);

    // Load base profiles from a config file in resources
    baseProfiles = modelProcessor.read(getClass().getResourceAsStream("/maven/baseProfiles.xml"), null)
            .getProfiles();
}

From source file:org.commonjava.emb.boot.embed.EMBEmbedder.java

License:Apache License

protected void injectProperties(final EMBExecutionRequest request) {
    final Properties systemProperties = new Properties();

    EnvironmentUtils.addEnvVars(systemProperties);
    systemProperties.putAll(System.getProperties());

    if (request.getSystemProperties() != null) {
        systemProperties.putAll(request.getSystemProperties());
    }//  w  w w  .ja v a  2  s .co  m

    request.setSystemProperties(systemProperties);
}

From source file:org.commonjava.emb.boot.main.EMBMain.java

License:Apache License

protected void populateProperties(final CommandLine commandLine, final Properties systemProperties,
        final Properties userProperties) {
    EnvironmentUtils.addEnvVars(systemProperties);

    // ----------------------------------------------------------------------
    // Options that are set on the command line become system properties
    // and therefore are set in the session properties. System properties
    // are most dominant.
    // ----------------------------------------------------------------------

    if (commandLine.hasOption(CLIManager.SET_SYSTEM_PROPERTY)) {
        final String[] defStrs = commandLine.getOptionValues(CLIManager.SET_SYSTEM_PROPERTY);

        if (defStrs != null) {
            for (int i = 0; i < defStrs.length; ++i) {
                setCliProperty(defStrs[i], userProperties);
            }/*from  www .jav a 2  s  .  c  o m*/
        }
    }

    systemProperties.putAll(System.getProperties());
}

From source file:org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.java

License:Open Source License

public static void populateSystemProperties(MavenExecutionRequest request) {
    // temporary solution for https://issues.sonatype.org/browse/MNGECLIPSE-1607
    // oddly, there are no unit tests that fail if this is commented out
    Properties systemProperties = new Properties();
    EnvironmentUtils.addEnvVars(systemProperties);
    systemProperties.putAll(System.getProperties());
    request.setSystemProperties(systemProperties);
}

From source file:org.eclipse.m2e.core.internal.embedder.MavenImpl.java

License:Open Source License

MavenExecutionRequest createExecutionRequest() throws CoreException {
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();

    // this causes problems with unexpected "stale project configuration" error markers
    // need to think how to manage ${maven.build.timestamp} properly inside workspace
    //request.setStartTime( new Date() );

    if (mavenConfiguration.getGlobalSettingsFile() != null) {
        request.setGlobalSettingsFile(new File(mavenConfiguration.getGlobalSettingsFile()));
    }/* ww w .ja v  a2 s.c  o m*/
    if (mavenConfiguration.getUserSettingsFile() != null) {
        request.setUserSettingsFile(new File(mavenConfiguration.getUserSettingsFile()));
    }

    try {
        lookup(MavenExecutionRequestPopulator.class).populateFromSettings(request, getSettings());
    } catch (MavenExecutionRequestPopulationException ex) {
        throw new CoreException(new Status(IStatus.ERROR, IMavenConstants.PLUGIN_ID, -1,
                Messages.MavenImpl_error_no_exec_req, ex));
    }

    ArtifactRepository localRepository = getLocalRepository();
    request.setLocalRepository(localRepository);
    request.setLocalRepositoryPath(localRepository.getBasedir());
    request.setOffline(mavenConfiguration.isOffline());

    request.getUserProperties().put("m2e.version", MavenPluginActivator.getVersion()); //$NON-NLS-1$
    request.getUserProperties().put(ConfigurationProperties.USER_AGENT, MavenPluginActivator.getUserAgent());

    EnvironmentUtils.addEnvVars(request.getSystemProperties());
    request.getSystemProperties().putAll(System.getProperties());

    request.setCacheNotFound(true);
    request.setCacheTransferError(true);

    // the right way to disable snapshot update
    // request.setUpdateSnapshots(false);
    return request;
}

From source file:org.kie.workbench.common.services.backend.compiler.external339.AFMavenCli.java

License:Apache License

static void populateProperties(CommandLine commandLine, Properties systemProperties,
        Properties userProperties) {

    EnvironmentUtils.addEnvVars(systemProperties);

    // ----------------------------------------------------------------------
    // Options that are set on the command line become system properties
    // and therefore are set in the session properties. System properties
    // are most dominant.
    // ----------------------------------------------------------------------

    if (commandLine.hasOption(CLIManager.SET_SYSTEM_PROPERTY)) {
        String[] defStrs = commandLine.getOptionValues(CLIManager.SET_SYSTEM_PROPERTY);

        if (defStrs != null) {
            for (String defStr : defStrs) {
                setCliProperty(defStr, userProperties);
            }/*  w  w w. j  av  a2 s .c o  m*/
        }
    }

    SystemProperties.addSystemProperties(systemProperties);

    // ----------------------------------------------------------------------
    // Properties containing info about the currently running version of Maven
    // These override any corresponding properties set on the command line
    // ----------------------------------------------------------------------

    Properties buildProperties = AFCLIReportingUtils.getBuildProperties();

    String mavenVersion = buildProperties.getProperty(AFCLIReportingUtils.BUILD_VERSION_PROPERTY);
    systemProperties.setProperty("maven.version", mavenVersion);

    String mavenBuildVersion = AFCLIReportingUtils.createMavenVersionString(buildProperties);
    systemProperties.setProperty("maven.build.version", mavenBuildVersion);
}

From source file:org.kie.workbench.common.services.backend.compiler.impl.external339.ReusableAFMavenCli.java

License:Apache License

static void populateProperties(CommandLine commandLine, Properties systemProperties, Properties userProperties,
        Properties bannedEnvVars) {

    EnvironmentUtils.addEnvVars(systemProperties);

    // ----------------------------------------------------------------------
    // Options that are set on the command line become system properties
    // and therefore are set in the session properties. System properties
    // are most dominant.
    // ----------------------------------------------------------------------

    if (commandLine.hasOption(CLIManager.SET_SYSTEM_PROPERTY)) {
        String[] defStrs = commandLine.getOptionValues(CLIManager.SET_SYSTEM_PROPERTY);

        if (defStrs != null) {
            for (String defStr : defStrs) {
                setCliProperty(defStr, userProperties);
            }/*from w w w  .j a v  a2 s .c  o m*/
        }
    }

    SystemProperties.addSystemProperties(systemProperties);
    purgeBannedProperties(systemProperties, bannedEnvVars);// purged from the env vars who breaks the build

    // ----------------------------------------------------------------------
    // Properties containing info about the currently running version of Maven
    // These override any corresponding properties set on the command line
    // ----------------------------------------------------------------------

    Properties buildProperties = AFCLIReportingUtils.getBuildProperties();

    String mavenVersion = buildProperties.getProperty(AFCLIReportingUtils.BUILD_VERSION_PROPERTY);
    systemProperties.setProperty("maven.version", mavenVersion);

    String mavenBuildVersion = AFCLIReportingUtils.createMavenVersionString(buildProperties);
    systemProperties.setProperty("maven.build.version", mavenBuildVersion);
}

From source file:org.springframework.ide.vscode.commons.maven.MavenBridge.java

License:Open Source License

@SuppressWarnings("deprecation")
MavenExecutionRequest createExecutionRequest() throws MavenException {
    MavenExecutionRequest request = new DefaultMavenExecutionRequest();

    // this causes problems with unexpected "stale project configuration"
    // error markers
    // need to think how to manage ${maven.build.timestamp} properly inside
    // workspace//from ww w . j  ava 2s .c o  m
    // request.setStartTime( new Date() );

    if (mavenConfiguration.getGlobalSettingsFile() != null) {
        request.setGlobalSettingsFile(new File(mavenConfiguration.getGlobalSettingsFile()));
    }

    File userSettingsFile = SettingsXmlConfigurationProcessor.DEFAULT_USER_SETTINGS_FILE;

    if (mavenConfiguration.getUserSettingsFile() != null) {
        userSettingsFile = new File(mavenConfiguration.getUserSettingsFile());
    }
    request.setUserSettingsFile(userSettingsFile);

    try {
        lookup(MavenExecutionRequestPopulator.class).populateFromSettings(request, getSettings());
    } catch (MavenExecutionRequestPopulationException ex) {
        throw new MavenException(ex);
    }

    ArtifactRepository localRepository = getLocalRepository();
    request.setLocalRepository(localRepository);
    request.setLocalRepositoryPath(localRepository.getBasedir());
    // request.setOffline(mavenConfiguration.isOffline());

    // request.getUserProperties().put("m2e.version",
    // MavenPluginActivator.getVersion()); //$NON-NLS-1$
    // request.getUserProperties().put(ConfigurationProperties.USER_AGENT,
    // MavenPluginActivator.getUserAgent());

    EnvironmentUtils.addEnvVars(request.getSystemProperties());
    copyProperties(request.getSystemProperties(), System.getProperties());

    request.setCacheNotFound(true);
    request.setCacheTransferError(true);

    // request.setGlobalChecksumPolicy(mavenConfiguration.getGlobalChecksumPolicy());
    // the right way to disable snapshot update
    // request.setUpdateSnapshots(false);
    return request;
}

From source file:org.topdesk.maven.tracker.MavenCli.java

License:Apache License

static void populateProperties(CommandLine commandLine, Properties systemProperties,
        Properties userProperties) {
    EnvironmentUtils.addEnvVars(systemProperties);

    // ----------------------------------------------------------------------
    // Options that are set on the command line become system properties
    // and therefore are set in the session properties. System properties
    // are most dominant.
    // ----------------------------------------------------------------------

    if (commandLine.hasOption(CLIManager.SET_SYSTEM_PROPERTY)) {
        String[] defStrs = commandLine.getOptionValues(CLIManager.SET_SYSTEM_PROPERTY);

        if (defStrs != null) {
            for (int i = 0; i < defStrs.length; ++i) {
                setCliProperty(defStrs[i], userProperties);
            }/*from  w  ww .j  a v  a2s.  com*/
        }
    }

    systemProperties.putAll(System.getProperties());
}