Example #1
0
    private void configureProperties(final MavenExecutionRequest request) {
      assert request != null;
      assert config != null;

      Properties sys = new Properties();
      sys.putAll(System.getProperties());

      Properties user = new Properties();
      user.putAll(config.getProperties());

      // Add the env vars to the property set, with the "env." prefix
      boolean caseSensitive = !Os.isFamily(Os.FAMILY_WINDOWS);
      for (Map.Entry<String, String> entry : System.getenv().entrySet()) {
        String key =
            "env." + (caseSensitive ? entry.getKey() : entry.getKey().toUpperCase(Locale.ENGLISH));
        sys.setProperty(key, entry.getValue());
      }

      request.setUserProperties(user);

      // HACK: Some bits of Maven still require using System.properties :-(
      sys.putAll(user);
      System.getProperties().putAll(user);

      request.setSystemProperties(sys);
    }
  public MavenExecutionRequest createRequest(
      File file, List<String> activeProfiles, List<String> inactiveProfiles, List<String> goals)
      throws RemoteException {
    // Properties executionProperties = myMavenSettings.getProperties();
    // if (executionProperties == null) {
    //  executionProperties = new Properties();
    // }

    MavenExecutionRequest result = new DefaultMavenExecutionRequest();

    try {
      getComponent(MavenExecutionRequestPopulator.class)
          .populateFromSettings(result, myMavenSettings);

      result.setGoals(goals);

      result.setPom(file);

      getComponent(MavenExecutionRequestPopulator.class).populateDefaults(result);

      result.setSystemProperties(mySystemProperties);

      result.setActiveProfiles(activeProfiles);
      result.setInactiveProfiles(inactiveProfiles);

      return result;
    } catch (MavenExecutionRequestPopulationException e) {
      throw new RuntimeException(e);
    }
  }
 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);
 }