Package org.codehaus.plexus.util.cli

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


    }

    static Commandline buildCmd( File workingDir, String[] cmdAndArgs )
        throws ScmException
    {
        Commandline cmd = new Commandline();
        cmd.setExecutable( HgCommandConstants.EXEC );
        cmd.addArguments( cmdAndArgs );
        if ( workingDir != null )
        {
            cmd.setWorkingDirectory( workingDir.getAbsolutePath() );

            if ( !workingDir.exists() )
            {
                boolean success = workingDir.mkdirs();
                if ( !success )
View Full Code Here


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

        configureEnvironment( cl, ccmAddr );

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

        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

     */
    public static Commandline checkoutProject( File directory, String projectSpec, ScmVersion version, String purpose,
                                               String release, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( CO );
        cl.createArg().setValue( "-subprojects" ); // Checkout sub-projects
        cl.createArg().setValue( "-rel" ); // Relative

        if ( version != null && StringUtils.isNotEmpty( version.getName() ) )
        {
            cl.createArg().setValue( "-t" ); // Version
            cl.createArg().setValue( version.getName() );
        }

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

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

        if ( directory != null )
        {
            cl.createArg().setValue( "-path" );
            try
            {
                cl.createArg().setValue( directory.getCanonicalPath() );
            }
            catch ( IOException e )
            {
                throw new ScmException( "Invalid directory", e );
            }
        }
        cl.createArg().setValue( "-p" );
        cl.createArg().setValue( projectSpec );

        return cl;
    }
View Full Code Here

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

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( CI );
        if ( comment != null && !comment.equals( "" ) )
        {
            cl.createArg().setValue( "-c" );
            cl.createArg().setValue( comment );
        }
        cl.createArg().setValue( "-p" );
        cl.createArg().setValue( projectSpec );

        return cl;
    }
View Full Code Here

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

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( CI );
        if ( comment != null && !comment.equals( "" ) )
        {
            cl.createArg().setValue( "-c" );
            cl.createArg().setValue( comment );
        }

        if ( files.size() > 0 )
        {
            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 synchronize( String projectSpec, String ccmAddr )
        throws ScmException
    {
        Commandline cl = new Commandline();

        configureEnvironment( cl, ccmAddr );

        cl.setExecutable( CCM );
        cl.createArg().setValue( SYNC );
        cl.createArg().setValue( "-r" ); // Recursive
        cl.createArg().setValue( "-p" );
        cl.createArg().setValue( projectSpec );

        return cl;
    }
View Full Code Here

        return (BlameScmResult) command.execute( repository, fileSet, params );
    }

    public static Commandline createP4Command( PerforceScmProviderRepository repo, File workingDir )
    {
        Commandline command = new Commandline();
        command.setExecutable( "p4" );
        if ( workingDir != null )
        {
            // SCM-209
            command.createArg().setValue( "-d" );
            command.createArg().setValue( workingDir.getAbsolutePath() );
        }

        if ( repo.getHost() != null )
        {
            command.createArg().setValue( "-p" );
            String value = repo.getHost();
            if ( repo.getPort() != 0 )
            {
                value += ":" + Integer.toString( repo.getPort() );
            }
            command.createArg().setValue( value );
        }

        if ( StringUtils.isNotEmpty( repo.getUser() ) )
        {
            command.createArg().setValue( "-u" );
            command.createArg().setValue( repo.getUser() );
        }

        if ( StringUtils.isNotEmpty( repo.getPassword() ) )
        {
            command.createArg().setValue( "-P" );
            command.createArg().setValue( repo.getPassword() );
        }
        return command;
    }
View Full Code Here

                // to see if the user has Perforce installed.  If not, we mark
                // the provider as "not live" (or dead, I suppose!) and skip
                // anything that requires an active server connection.
                try
                {
                    Commandline command = new Commandline();
                    command.setExecutable( "p4" );
                    Process proc = command.execute();
                    BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
                    @SuppressWarnings( "unused" )
                    String line;
                    while ( ( line = br.readLine() ) != null )
                    {
View Full Code Here

        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();

        int exitCode;

        Commandline cl;
        String projectDirectory = "";

        try
        {
            // Since clearcase only wants to checkout to a non-existent directory, first delete the working dir
            // if it already exists
            FileUtils.deleteDirectory( workingDirectory );
            // First create the view
            String viewName = getUniqueViewName( repo, workingDirectory.getAbsolutePath() );
            String streamIdentifier = getStreamIdentifier( repo.getStreamName(), repo.getVobName() );
            cl = createCreateViewCommandLine( workingDirectory, viewName, streamIdentifier );
            if ( getLogger().isInfoEnabled() )
            {
                getLogger().info( "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() );
            }
            exitCode =
                CommandLineUtils.executeCommandLine( cl, new CommandLineUtils.StringStreamConsumer(), stderr );

            if ( exitCode == 0 )
            {
                File configSpecLocation;

                if ( !repo.isAutoConfigSpec() )
                {
                    configSpecLocation = repo.getConfigSpec();
                    if ( version != null && StringUtils.isNotEmpty( version.getName() ) )
                    {
                        // Another config spec is needed in this case.
                        //
                        // One option how to implement this would be to use a name convention for the config specs,
                        // e.g. the tag name could be appended to the original config spec name.
                        // If the config spec from the SCM URL would be \\myserver\configspecs\someproj.txt
                        // and the tag name would be mytag, the new config spec location could be
                        // \\myserver\configspecs\someproj-mytag.txt
                        //
                        throw new UnsupportedOperationException(
                            "Building on a label not supported with user-specified config specs" );
                    }
                }
                else
                {

                    // write config spec to temp file
                    String configSpec;
                    if ( !repo.hasElements() )
                    {
                        configSpec = createConfigSpec( repo.getLoadDirectory(), version );
                    }
                    else
                    {
                        configSpec = createConfigSpec( repo.getLoadDirectory(), repo.getElementName(), version );
                    }
                    if ( getLogger().isInfoEnabled() )
                    {
                        getLogger().info( "Created config spec for view '" + viewName + "':\n" + configSpec );
                    }
                    configSpecLocation = writeTemporaryConfigSpecFile( configSpec, viewName );

                    // When checking out from ClearCase, the directory structure of the
                    // SCM system is repeated within the checkout directory. E.g. if you check out the
                    // project "my/project" to "/some/dir", the project sources are actually checked out
                    // to "my/project/some/dir".
                    projectDirectory = repo.getLoadDirectory();
                    // strip off leading / to make the path relative
                    if ( projectDirectory.startsWith( "/" ) )
                    {
                        projectDirectory = projectDirectory.substring( 1 );
                    }
                }

                cl = createUpdateConfigSpecCommandLine( workingDirectory, configSpecLocation, viewName );

                if ( getLogger().isInfoEnabled() )
                {
                    getLogger().info( "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() );
                }
                exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );

            }
        }
        catch ( CommandLineException ex )
        {
            throw new ScmException( "Error while executing clearcase command.", ex );
        }
        catch ( IOException ex )
        {
            throw new ScmException( "Error while deleting working directory.", ex );
        }

        if ( exitCode != 0 )
        {
            return new CheckOutScmResult( cl.toString(), "The cleartool command failed.", stderr.getOutput(), false );
        }

        return new CheckOutScmResult( cl.toString(), consumer.getCheckedOutFiles(), projectDirectory );
    }
View Full Code Here

//    }

    protected Commandline createCreateViewCommandLine( File workingDirectory, String viewName, String streamIdentifier )
        throws IOException
    {
        Commandline command = new Commandline();

        // We have to execute from 1 level up from the working dir, since we had to delete the working dir
        command.setWorkingDirectory( workingDirectory.getParentFile().getAbsolutePath() );

        command.setExecutable( "cleartool" );

        command.createArg().setValue( "mkview" );
        command.createArg().setValue( "-snapshot" );
        command.createArg().setValue( "-tag" );
        command.createArg().setValue( viewName );

        if ( isClearCaseUCM() )
        {
            command.createArg().setValue( "-stream" );
            command.createArg().setValue( streamIdentifier );
        }

        if ( !isClearCaseLT() )
        {
            if ( useVWS() )
            {
                command.createArg().setValue( "-vws" );
                command.createArg().setValue( getViewStore() + viewName + ".vws" );
            }
        }

        command.createArg().setValue( workingDirectory.getCanonicalPath() );

        return command;
    }
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.