Package org.codehaus.plexus.util.cli

Examples of org.codehaus.plexus.util.cli.Commandline


     * @throws ScmException
     */
    public static Commandline create( List<File> files, String message, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( CREATE );

        if ( message != null && !message.equals( "" ) )
        {

            cl.createArg().setValue( "-c" );

            cl.createArg().setValue( message );

        }

        for ( File f : files )
        {
            try
            {
                cl.createArg().setValue( f.getCanonicalPath() );
            }
            catch ( IOException e )
            {
                throw new ScmException( "Invalid file path " + f.toString(), e );
            }
View Full Code Here


     * @throws ScmException
     */
    public static Commandline createTask( String synopsis, String release, boolean defaultTask, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( TASK );

        cl.createArg().setValue( "-create" );

        cl.createArg().setValue( "-synopsis" );
        cl.createArg().setValue( synopsis );

        if ( release != null && !release.equals( "" ) )
        {
            cl.createArg().setValue( "-release" );
            cl.createArg().setValue( release );
        }

        if ( defaultTask )
        {
            cl.createArg().setValue( "-default" );
        }

        cl.createArg().setValue( "-description" );
        cl.createArg().setValue(
            "This task was created by Maven SCM Synergy provider on " + Calendar.getInstance().getTime() );

        return cl;

    }
View Full Code Here

     * @throws ScmException
     */
    public static Commandline checkinTask( String taskSpecs, String comment, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( TASK );

        cl.createArg().setValue( "-checkin" );

        cl.createArg().setValue( taskSpecs );

        cl.createArg().setValue( "-comment" );
        cl.createArg().setValue( comment );

        return cl;

    }
View Full Code Here

     * @throws ScmException
     */
    public static Commandline delete( List<File> files, String ccmAddr, boolean replace )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( DELETE );

        if ( replace )
        {
            cl.createArg().setValue( "-replace" );
        }

        for ( File f : files )
        {
            try
            {
                cl.createArg().setValue( f.getCanonicalPath() );
            }
            catch ( IOException e )
            {
                throw new ScmException( "Invalid file path " + f.toString(), e );
            }
View Full Code Here

     * @throws ScmException
     */
    public static Commandline reconfigure( String projectSpec, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( RECONFIGURE );

        cl.createArg().setValue( "-recurse" );

        if ( projectSpec != null )
        {
            cl.createArg().setValue( "-p" );
            cl.createArg().setValue( projectSpec );
        }

        return cl;

    }
View Full Code Here

     * @throws ScmException
     */
    public static Commandline reconfigureProperties( String projectSpec, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( RECONFIGURE_PROPERTIES );

        cl.createArg().setValue( "-refresh" );
        cl.createArg().setValue( projectSpec );

        return cl;

    }
View Full Code Here

     * @throws ScmException
     */
    public static Commandline reconcileUwa( String projectSpec, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( RECONCILE );

        cl.createArg().setValue( "-r" );
        cl.createArg().setValue( "-uwa" ); // Update wa from database

        if ( projectSpec != null )
        {
            cl.createArg().setValue( "-p" );
            cl.createArg().setValue( projectSpec );
        }

        return cl;

    }
View Full Code Here

     * @throws ScmException
     */
    public static Commandline reconcileUdb( String projectSpec, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( RECONCILE );

        cl.createArg().setValue( "-r" );
        cl.createArg().setValue( "-udb" ); // Update database from wa

        if ( projectSpec != null )
        {
            cl.createArg().setValue( "-p" );
            cl.createArg().setValue( projectSpec );
        }

        return cl;

    }
View Full Code Here

     * @throws ScmException
     */
    public static Commandline dir( File directory, String format, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        try
        {
            cl.setWorkingDirectory( directory.getCanonicalPath() );
        }
        catch ( IOException e )
        {
            throw new ScmException( "Invalid directory", e );
        }

        cl.setExecutable( CCM );
        cl.createArg().setValue( DIR );
        cl.createArg().setValue( "-m" );

        // Set up the output format
        if ( format != null && !format.equals( "" ) )
        {
            cl.createArg().setValue( "-f" );
            cl.createArg().setValue( format );
        }

        return cl;

    }
View Full Code Here

        throws ScmException
    {
        try
        {
            //Build commandline
            Commandline cmd = buildCmd( workingDir, cmdAndArgs );
            if ( logger.isInfoEnabled() )
            {
                logger.info( "EXECUTING: " + maskPassword( cmd ) );
            }

            //Execute command
            int exitCode = executeCmd( consumer, cmd );

            //Return result
            List<Integer> exitCodes = DEFAULT_EXIT_CODES;
            if ( EXIT_CODE_MAP.containsKey( cmdAndArgs[0] ) )
            {
                exitCodes = EXIT_CODE_MAP.get( cmdAndArgs[0] );
            }
            boolean success = exitCodes.contains( Integer.valueOf( exitCode ) );

            //On failure (and not due to exceptions) - run diagnostics
            String providerMsg = "Execution of hg command succeded";
            if ( !success )
            {
                HgConfig config = new HgConfig( workingDir );
                providerMsg =
                    "\nEXECUTION FAILED" + "\n  Execution of cmd : " + cmdAndArgs[0] + " failed with exit code: "
                        + exitCode + "." + "\n  Working directory was: " + "\n    " + workingDir.getAbsolutePath()
                        + config.toString( workingDir ) + "\n";
                if ( logger.isErrorEnabled() )
                {
                    logger.error( providerMsg );
                }
            }

            return new ScmResult( cmd.toString(), providerMsg, consumer.getStdErr(), success );
        }
        catch ( ScmException se )
        {
            String msg =
                "EXECUTION FAILED" + "\n  Execution failed before invoking the Hg command. Last exception:" + "\n    "
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.util.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.