public Properties getSystemEnvVars() throws Exception { return CommandLineUtils.getSystemEnvVars(); }
/** * Gets the shell environment variables for this process. Note that the returned mapping from variable names to * values will always be case-sensitive regardless of the platform, i.e. <code>getSystemEnvVars().get("path")</code> * and <code>getSystemEnvVars().get("PATH")</code> will in general return different values. However, on platforms * with case-insensitive environment variables like Windows, all variable names will be normalized to upper case. * * @return The shell environment variables, can be empty but never <code>null</code>. * @throws IOException If the environment variables could not be queried from the shell. * @see System#getenv() System.getenv() API, new in JDK 5.0, to get the same result <b>since 2.0.2 System#getenv() * will be used if available in the current running jvm.</b> */ public static Properties getSystemEnvVars() throws IOException { return getSystemEnvVars( !Os.isFamily( Os.FAMILY_WINDOWS ) ); }
/** * Add system environment variables */ public void addSystemEnvironment() throws Exception { Properties systemEnvVars = CommandLineUtils.getSystemEnvVars(); for ( Object o : systemEnvVars.keySet() ) { String key = (String) o; if ( !envVars.containsKey( key ) ) { addEnvironment( key, systemEnvVars.getProperty( key ) ); } } }
/** * Override-able for test purposes. * * @return The shell environment variables, can be empty but never <code>null</code>. * @throws IOException If the environment variables could not be queried from the shell. */ Properties getSystemEnvVars() throws IOException { return CommandLineUtils.getSystemEnvVars(); }
/** * Override-able for test purposes. * * @return The shell environment variables, can be empty but never <code>null</code>. * @throws IOException If the environment variables could not be queried from the shell. */ Properties getSystemEnvVars() throws IOException { return CommandLineUtils.getSystemEnvVars(); }
/** * @param log a logger could be null * @return the <code>MAVEN_OPTS</code> env variable value * @since 2.6 */ private static String getMavenOpts( Log log ) { String mavenOpts = null; try { mavenOpts = CommandLineUtils.getSystemEnvVars().getProperty( "MAVEN_OPTS" ); } catch ( IOException e ) { if ( log != null && log.isDebugEnabled() ) { log.debug( "IOException: " + e.getMessage() ); } } return mavenOpts; }
/** * @param log a logger could be null * @return the <code>JAVA_OPTS</code> env variable value * @since 2.6 */ private static String getJavaOpts( Log log ) { String javaOpts = null; try { javaOpts = CommandLineUtils.getSystemEnvVars().getProperty( "JAVA_OPTS" ); } catch ( IOException e ) { if ( log != null && log.isDebugEnabled() ) { log.debug( "IOException: " + e.getMessage() ); } } return javaOpts; }
/** * Gets Maven Home * * @return maven home directory */ public File getMavenHome() { if (mavenHome == null) { try { final Properties envars = CommandLineUtils.getSystemEnvVars(); final String home = envars.getProperty("M2_HOME"); if (StringUtils.isNotEmpty(home)) { mavenHome = new File(home); } } catch (IOException e) { // MAYBE Handle exception } } return mavenHome; }
/** * Gets Java home directory * * @return the Java home directory */ public File getJavaHome() { if (javaHome == null) { try { final Properties envars = CommandLineUtils.getSystemEnvVars(); final String home = envars.getProperty("JAVA_HOME"); if (StringUtils.isNotEmpty(home)) { javaHome = new File(home); } } catch (IOException e) { // MAYBE Handle exception } } return javaHome; }
mavenHome = CommandLineUtils.getSystemEnvVars().getProperty( "M2_HOME" );
/** * Detect the location of the local Maven installation, and start up the MavenInvoker using that * path. Detection uses the system property <code>maven.home</code>, and falls back to the shell * environment variable <code>M2_HOME</code>. * * @throws IOException in case the shell environment variables cannot be read */ private void startInvoker() throws IOException { if ( mavenInvoker == null ) { mavenInvoker = new DefaultInvoker(); if ( System.getProperty( "maven.home" ) == null ) { Properties envars = CommandLineUtils.getSystemEnvVars(); String mavenHome = envars.getProperty( "M2_HOME" ); if ( mavenHome != null ) { mavenInvoker.setMavenHome( new File( mavenHome ) ); } } } }
/** * Detect the location of the local Maven installation, and start up the MavenInvoker using that * path. Detection uses the system property <code>maven.home</code>, and falls back to the shell * environment variable <code>M2_HOME</code>. * * @throws IOException in case the shell environment variables cannot be read */ private void startInvoker() throws IOException { if ( mavenInvoker == null ) { mavenInvoker = new DefaultInvoker(); if ( System.getProperty( "maven.home" ) == null ) { Properties envars = CommandLineUtils.getSystemEnvVars(); String mavenHome = envars.getProperty( "M2_HOME" ); if ( mavenHome != null ) { mavenInvoker.setMavenHome( new File( mavenHome ) ); } } } }
/** * Configure a commandline to use environment variables ($PATH) * * @param cl * @param ccmAddr * @throws ScmException */ private static void configureEnvironment( Commandline cl, String ccmAddr ) throws ScmException { // We need PATH to be set for using CCM try { Properties envVars = CommandLineUtils.getSystemEnvVars(); for ( @SuppressWarnings( "rawtypes" ) Iterator i = envVars.keySet().iterator(); i.hasNext(); ) { String key = (String) i.next(); if ( !key.equalsIgnoreCase( "CCM_ADDR" ) ) { cl.addEnvironment( key, envVars.getProperty( key ) ); } } } catch ( Exception e1 ) { throw new ScmException( "Fail to add PATH environment variable.", e1 ); } cl.addEnvironment( "CCM_ADDR", ccmAddr ); }
/** * Configure a commandline to use environment variables ($PATH) * * @param cl * @param ccmAddr * @throws ScmException */ private static void configureEnvironment( Commandline cl, String ccmAddr ) throws ScmException { // We need PATH to be set for using CCM try { Properties envVars = CommandLineUtils.getSystemEnvVars(); for ( @SuppressWarnings( "rawtypes" ) Iterator i = envVars.keySet().iterator(); i.hasNext(); ) { String key = (String) i.next(); if ( !key.equalsIgnoreCase( "CCM_ADDR" ) ) { cl.addEnvironment( key, envVars.getProperty( key ) ); } } } catch ( Exception e1 ) { throw new ScmException( "Fail to add PATH environment variable.", e1 ); } cl.addEnvironment( "CCM_ADDR", ccmAddr ); }
try Properties systemEnvVars = CommandLineUtils.getSystemEnvVars(); for ( Map.Entry<?, ?> entry : systemEnvVars.entrySet() )
try Properties systemEnvVars = CommandLineUtils.getSystemEnvVars(); for ( Map.Entry<?, ?> entry : systemEnvVars.entrySet() )
/** * TODO replace with calling getExecutorConfiguratorVersion * * @see org.apache.maven.continuum.installation.InstallationService#getDefaultJdkInformations() */ public List<String> getDefaultJdkInformations() throws InstallationException { try { Properties systemEnvVars = CommandLineUtils.getSystemEnvVars( false ); String javaHome = (String) systemEnvVars.get( "JAVA_HOME" ); // olamy : JAVA_HOME can not exists with a mac user if ( StringUtils.isEmpty( javaHome ) ) { return getJavaHomeInformations( System.getProperty( "java.home" ) ); } return getJavaHomeInformations( javaHome ); } catch ( IOException e ) { throw new InstallationException( e.getMessage(), e ); } catch ( CommandLineException e ) { throw new InstallationException( e.getMessage(), e ); } }
/** * TODO replace with calling getExecutorConfiguratorVersion * * @see org.apache.maven.continuum.installation.InstallationService#getDefaultJdkInformations() */ public List<String> getDefaultJdkInformations() throws InstallationException { try { Properties systemEnvVars = CommandLineUtils.getSystemEnvVars( false ); String javaHome = (String) systemEnvVars.get( "JAVA_HOME" ); // olamy : JAVA_HOME can not exists with a mac user if ( StringUtils.isEmpty( javaHome ) ) { return getJavaHomeInformations( System.getProperty( "java.home" ) ); } return getJavaHomeInformations( javaHome ); } catch ( IOException e ) { throw new InstallationException( e.getMessage(), e ); } catch ( CommandLineException e ) { throw new InstallationException( e.getMessage(), e ); } }
private String getExecutable() { String command = "jar" + (Os.isFamily(Os.FAMILY_WINDOWS) ? ".exe" : ""); String exec = findExecutable(command, System.getProperty("java.home"), new String[]{"../bin", "bin", "../sh"}); if (exec == null) { try { Properties env = CommandLineUtils.getSystemEnvVars(); String[] variables = {"JDK_HOME", "JAVA_HOME"}; for (int i = 0; i < variables.length && exec == null; i++) { exec = findExecutable(command, env.getProperty(variables[i]), new String[]{"bin", "sh"}); } } catch (IOException e) { if (getLog().isDebugEnabled()) { getLog().warn("Failed to retrieve environment variables, cannot search for " + command, e); } else { getLog().warn("Failed to retrieve environment variables, cannot search for " + command); } } } if (exec == null) { exec = command; } return exec; }
public void execute() throws MojoExecutionException, MojoFailureException { // Weather we resolve a single branch name or not, it won't hurt to run it through property replacement. try { systemEnvVars = CommandLineUtils.getSystemEnvVars(); } catch (IOException ioe) { throw new MojoExecutionException("Unable to read System Envirionment Variables: ", ioe); } // Validate the match type. checkReleaseBranchMatchTypeParam(); ScmUtils scmUtils = new ScmUtils(systemEnvVars, scmManager, project, getLog(), masterBranchPattern, supportBranchPattern, releaseBranchPattern, hotfixBranchPattern, developmentBranchPattern); GitBranchInfo branchInfo = scmUtils.resolveBranchInfo(gitBranchExpression); getLog().debug("Building for: " + branchInfo); execute(branchInfo); }