org.apache.maven.shared.utils.cli.CommandLineUtils Java Examples

The following examples show how to use org.apache.maven.shared.utils.cli.CommandLineUtils. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractMojoTest.java    From sarl with Apache License 2.0 6 votes vote down vote up
private static String findDefaultMavenHome() {
	String defaultMavenHome = System.getProperty("maven.home"); //$NON-NLS-1$

	if ( defaultMavenHome == null ) {
		Properties envVars = CommandLineUtils.getSystemEnvVars();
		defaultMavenHome = envVars.getProperty("M2_HOME"); //$NON-NLS-1$
	}

	if ( defaultMavenHome == null )
	{
		File f = new File( System.getProperty( "user.home" ), "m2" ); //$NON-NLS-1$ //$NON-NLS-2$
		if ( new File( f, "bin/mvn" ).isFile() ) //$NON-NLS-1$
		{
			defaultMavenHome = f.getAbsolutePath();
		}
	}
	return defaultMavenHome;
}
 
Example #2
Source File: RunningVerifier.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void findDefaultMavenHome() {
    defaultMavenHome = System.getProperty("maven.home");

    if (defaultMavenHome == null) {
        Properties envVars = CommandLineUtils.getSystemEnvVars();
        defaultMavenHome = envVars.getProperty("M2_HOME");
    }
}
 
Example #3
Source File: RunningVerifier.java    From vertx-maven-plugin with Apache License 2.0 5 votes vote down vote up
private void findDefaultMavenHome() {
    defaultMavenHome = System.getProperty("maven.home");

    if (defaultMavenHome == null) {
        Properties envVars = CommandLineUtils.getSystemEnvVars();
        defaultMavenHome = envVars.getProperty("M2_HOME");
    }
}
 
Example #4
Source File: MavenVerifierUtil.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
static public void checkMavenExecutable(String verifierRoot) throws IOException, VerificationException {
	File mvnExecutable = new File(new Verifier(verifierRoot).getExecutable());
	if (!mvnExecutable.exists()) {
		String mavenHome = findMaven();
		if (mavenHome != null) {
			System.setProperty("maven.home", mavenHome);
		} else {
			Assert.fail("Maven home not found. Tried to call '" + mvnExecutable
					+ "'.\nConsider to set the envVar 'M2_HOME' or System property 'maven.home'.\n"
					+ "Current settings are: maven.home=" + System.getProperty("maven.home") + " M2_HOME="
					+ CommandLineUtils.getSystemEnvVars().getProperty("M2_HOME"));
		}
	}
}
 
Example #5
Source File: DockerAssemblyConfigurationSource.java    From docker-maven-plugin with Apache License 2.0 4 votes vote down vote up
private FixedStringSearchInterpolator createEnvInterpolator() {
    PrefixedPropertiesValueSource envProps = new PrefixedPropertiesValueSource(Collections.singletonList("env."),
                                                                               CommandLineUtils.getSystemEnvVars(false), true );
    return FixedStringSearchInterpolator.create( envProps );
}