Package org.apache.maven.shared.utils.cli

Examples of org.apache.maven.shared.utils.cli.Commandline


    public static void launchSubversion( String line, String basedir )
        throws VerificationException
    {
        try
        {
            Commandline cli = new Commandline( line );

            cli.setWorkingDirectory( basedir );

            Writer logWriter = new FileWriter( new File( basedir, LOG_FILENAME ) );

            StreamConsumer out = new WriterStreamConsumer( logWriter );

            StreamConsumer err = new WriterStreamConsumer( logWriter );

            System.out.println( "Command: " + CommandLineUtils.toString( cli.getCommandline() ) );

            int ret = CommandLineUtils.executeCommandLine( cli, out, err );

            logWriter.close();
View Full Code Here


    }

    public int run( String[] cliArgs, Map envVars, String workingDirectory, File logFile )
        throws IOException, LauncherException
    {
        Commandline cmd = new Commandline();

        cmd.setExecutable( executable );

        if ( mavenHome != null )
        {
            cmd.addEnvironment( "M2_HOME", mavenHome );
        }

        if ( envVars != null )
        {
            for ( Object o : envVars.keySet() )
            {
                String key = (String) o;

                cmd.addEnvironment( key, (String) envVars.get( key ) );
            }
        }

        if ( envVars == null || envVars.get( "JAVA_HOME" ) == null )
        {
            cmd.addEnvironment( "JAVA_HOME", System.getProperty( "java.home" ) );
        }

        cmd.addEnvironment( "MAVEN_TERMINATE_CMD", "on" );

        cmd.setWorkingDirectory( workingDirectory );

        for ( String cliArg : cliArgs )
        {
            cmd.createArg().setValue( cliArg );
        }

        Writer logWriter = new FileWriter( logFile );

        StreamConsumer out = new WriterStreamConsumer( logWriter );
View Full Code Here

        throws IOException, SurefireBooterForkException
    {
        ForkConfiguration config = getForkConfiguration( null, "java" );
        File cpElement = getTempClasspathFile();

        Commandline cli =
            config.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), true, false, null, 1 );

        String line = StringUtils.join( cli.getCommandline(), " " );
        assertTrue( line.contains( "-jar" ) );
    }
View Full Code Here

    {
        // SUREFIRE-657
        File cpElement = getTempClasspathFile();
        ForkConfiguration forkConfiguration = getForkConfiguration( "abc\ndef", null );

        final Commandline commandLine =
            forkConfiguration.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), false, false,
                                                 null, 1 );
        assertTrue( commandLine.toString().contains( "abc def" ) );
    }
View Full Code Here

        catch ( IOException e )
        {
            throw new CommandLineConfigurationException( e.getMessage(), e );
        }

        Commandline cli = new Commandline();

        cli.setExecutable( jarSignerFile );

        cli.setWorkingDirectory( request.getWorkingDirectory() );

        if ( request.isVerbose() )
        {
            cli.createArg().setValue( "-verbose" );
        }

        String keystore = request.getKeystore();
        if ( !StringUtils.isEmpty( keystore ) )
        {
            cli.createArg().setValue( "-keystore" );
            cli.createArg().setValue( keystore );
        }

        String storepass = request.getStorepass();
        if ( !StringUtils.isEmpty( storepass ) )
        {
            cli.createArg().setValue( "-storepass" );
            Arg arg = cli.createArg();
            arg.setValue( storepass );
            arg.setMask( true );
        }

        String storetype = request.getStoretype();
        if ( !StringUtils.isEmpty( storetype ) )
        {
            cli.createArg().setValue( "-storetype" );
            cli.createArg().setValue( storetype );
        }

        String providerName = request.getProviderName();
        if ( !StringUtils.isEmpty( providerName ) )
        {
            cli.createArg().setValue( "-providerName" );
            cli.createArg().setValue( providerName );
        }

        String providerClass = request.getProviderClass();
        if ( !StringUtils.isEmpty( providerClass ) )
        {
            cli.createArg().setValue( "-providerClass" );
            cli.createArg().setValue( providerClass );
        }

        String providerArg = request.getProviderArg();
        if ( !StringUtils.isEmpty( providerArg ) )
        {
            cli.createArg().setValue( "-providerArg" );
            cli.createArg().setValue( providerArg );
        }

        if ( request.isProtectedAuthenticationPath() )
        {
            cli.createArg().setValue( "-protected" );
        }

        String maxMemory = request.getMaxMemory();
        if ( StringUtils.isNotEmpty( maxMemory ) )
        {
            cli.createArg().setValue( "-J-Xmx" + maxMemory );
        }

        String[] arguments = request.getArguments();
        if ( arguments != null )
        {
            cli.addArguments( arguments );
        }

        if ( request instanceof JarSignerSignRequest )
        {
            build( (JarSignerSignRequest) request, cli );
        }

        if ( request instanceof JarSignerVerifyRequest )
        {
            build( (JarSignerVerifyRequest) request, cli );
        }

        cli.createArg().setFile( request.getArchive() );

        String alias = request.getAlias();
        if ( !StringUtils.isEmpty( alias ) )
        {
            cli.createArg().setValue( alias );
        }

        return cli;
    }
View Full Code Here

        String cli = StringUtils.join( shellCommandLine.iterator(), " " );
        System.out.println( cli );
        assertTrue( cli.endsWith( "\'" + args[0] + "\'" ) );

        Commandline commandline = new Commandline( newShell() );
        commandline.setExecutable( "chmod" );
        commandline.getShell().setQuotedArgumentsEnabled( true );
        commandline.createArg().setValue( "--password" );
        commandline.createArg().setValue( ";password" );

        List<String> lines = commandline.getShell().getShellCommandLine( commandline.getArguments() );
        System.out.println( lines  );

        assertEquals( "/bin/sh", lines.get( 0 ) );
        assertEquals( "-c", lines.get( 1 ) );
        assertEquals( "chmod --password ';password'", lines.get( 2 ) );

        commandline = new Commandline( newShell() );
        commandline.setExecutable( "chmod" );
        commandline.getShell().setQuotedArgumentsEnabled( true );
        commandline.createArg().setValue( "--password" );
        commandline.createArg().setValue( ";password" );
        lines = commandline.getShell().getShellCommandLine( commandline.getArguments() );
        System.out.println( Arrays.asList( lines ) );

        assertEquals( "/bin/sh", lines.get( 0) );
        assertEquals( "-c", lines.get( 1 ) );
        assertEquals( "chmod --password ';password'", lines.get( 2 ) );

        commandline = new Commandline( new CmdShell() );
        commandline.getShell().setQuotedArgumentsEnabled( true );
        commandline.createArg().setValue( "--password" );
        commandline.createArg().setValue( ";password" );
        lines = commandline.getShell().getShellCommandLine( commandline.getArguments() );
        System.out.println( Arrays.asList( lines ) );

        assertEquals( "cmd.exe", lines.get( 0 ) );
        assertEquals( "/X", lines.get( 1 ) );
        assertEquals( "/C", lines.get( 2 ) );
View Full Code Here

    public void testBourneShellQuotingCharacters()
        throws Exception
    {
        // { ' ', '$', ';', '&', '|', '<', '>', '*', '?', '(', ')' };
        // test with values http://steve-parker.org/sh/bourne.shtml Appendix B - Meta-characters and Reserved Words
        Commandline commandline = new Commandline( newShell() );
        commandline.setExecutable( "chmod" );
        commandline.getShell().setQuotedArgumentsEnabled( true );
        commandline.createArg().setValue( " " );
        commandline.createArg().setValue( "|" );
        commandline.createArg().setValue( "&&" );
        commandline.createArg().setValue( "||" );
        commandline.createArg().setValue( ";" );
        commandline.createArg().setValue( ";;" );
        commandline.createArg().setValue( "&" );
        commandline.createArg().setValue( "()" );
        commandline.createArg().setValue( "<" );
        commandline.createArg().setValue( "<<" );
        commandline.createArg().setValue( ">" );
        commandline.createArg().setValue( ">>" );
        commandline.createArg().setValue( "*" );
        commandline.createArg().setValue( "?" );
        commandline.createArg().setValue( "[" );
        commandline.createArg().setValue( "]" );
        commandline.createArg().setValue( "{" );
        commandline.createArg().setValue( "}" );
        commandline.createArg().setValue( "`" );

        List<String> lines = commandline.getShell().getShellCommandLine( commandline.getArguments() );
        System.out.println( lines  );

        assertEquals( "/bin/sh", lines.get( 0 ) );
        assertEquals( "-c", lines.get( 1 ) );
        assertEquals( "chmod ' ' '|' '&&' '||' ';' ';;' '&' '()' '<' '<<' '>' '>>' '*' '?' '[' ']' '{' '}' '`'",
View Full Code Here

        try
        {
            JavaToolResult result = jarSigner.execute( request );

            Commandline commandLine = result.getCommandline();

            int resultCode = result.getExitCode();

            if ( resultCode != 0 )
            {
View Full Code Here

        try
        {
            JavaToolResult result = jarSigner.execute( request );

            Commandline commandLine = result.getCommandline();

            int resultCode = result.getExitCode();

            if ( resultCode != 0 )
            {
View Full Code Here

        throws IOException, SurefireBooterForkException
    {
        ForkConfiguration config = getForkConfiguration( null, "java" );
        File cpElement = getTempClasspathFile();

        Commandline cli =
            config.createCommandLine( Collections.singletonList( cpElement.getAbsolutePath() ), true, false, null, 1 );

        String line = StringUtils.join( cli.getCommandline(), " " );
        assertTrue( line.contains( "-jar" ) );
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.shared.utils.cli.Commandline

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.