Package org.codehaus.plexus.util.cli

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


  private Thread setupCommandLine(final int monitorPort,
      final String monitorKey, final List<String> args) {
    final String javaExe = System.getProperty("java.home") + File.separator
      + "bin" + File.separator + "java";
    final Commandline commandline = new Commandline(StringUtils.quoteAndEscape(javaExe, '"'));
    final String classPath =
      System.getProperty("java.class.path") + File.pathSeparator + pluginPath;
    commandline.createArg().setValue("-ea");
    commandline.createArg().setValue("-cp");
    commandline.createArg().setValue(classPath);
    commandline.createArg().setValue("-Dmonitor.port=" + monitorPort);
    commandline.createArg().setValue("-Dmonitor.key=" + monitorKey);
    commandline.createArg().setValue("-Dappengine.sdk.root=" + System.getProperty("appengine.sdk.root"));
    commandline.createArg().setValue(AppEnginePluginMonitor.class.getName());
    commandline.addArguments(args.toArray(new String[args.size()]));

    final StreamConsumer outConsumer = new StreamConsumer() {
      public void consumeLine(final String line) {
        consumeOutputLine(line);
      }
    };

    final StreamConsumer errConsumer = new StreamConsumer() {
      public void consumeLine(final String line) {
        consumeErrorLine(line);
      }
    };

    if (log.isDebugEnabled()) {
      log.debug("Forking executable: " + commandline.getExecutable());
      log.debug("Command line: " + commandline.toString());
    }

    return new Thread(new Runnable() {
      public void run() {
        try {
View Full Code Here


        throws ScmException
    {
        PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
        actualLocation = PerforceScmProvider.getRepoPath( getLogger(), prepo, files.getBasedir() );
        PerforceStatusConsumer consumer = new PerforceStatusConsumer();
        Commandline command = readOpened( prepo, files, consumer );

        if ( consumer.isSuccess() )
        {
            List<ScmFile> scmfiles = createResults( actualLocation, consumer );
            return new StatusScmResult( command.toString(), scmfiles );
        }

        return new StatusScmResult( command.toString(), "Unable to get status", consumer
                .getOutput(), consumer.isSuccess() );
    }
View Full Code Here

    /** {@inheritDoc} */
    protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet files, String message,
                                           boolean binary )
        throws ScmException
    {
        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files );
        PerforceAddConsumer consumer = new PerforceAddConsumer();
        try
        {
            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
            int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err );

            if ( exitCode != 0 )
            {
                String cmdLine = CommandLineUtils.toString( cl.getCommandline() );

                StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() );
                msg.append( '\n' );
                msg.append( "Command line was:" + cmdLine );

                throw new CommandLineException( msg.toString() );
            }
        }
        catch ( CommandLineException e )
        {
            if ( getLogger().isErrorEnabled() )
            {
                getLogger().error( "CommandLineException " + e.getMessage(), e );
            }
        }

        return new AddScmResult( cl.toString(), consumer.getAdditions() );
    }
View Full Code Here

    }

    private Commandline readOpened( PerforceScmProviderRepository prepo, ScmFileSet files,
                                    PerforceStatusConsumer consumer )
    {
        Commandline cl = createOpenedCommandLine( prepo, files.getBasedir(), actualLocation );
        try
        {
            if ( getLogger().isDebugEnabled() )
            {
                getLogger().debug( PerforceScmProvider.clean( "Executing " + cl.toString() ) );
            }

            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
            int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err );

            if ( exitCode != 0 )
            {
                String cmdLine = CommandLineUtils.toString( cl.getCommandline() );

                StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() );
                msg.append( '\n' );
                msg.append( "Command line was:" + cmdLine );
View Full Code Here

    }

    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
                                                 ScmFileSet files )
    {
        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
        command.createArg().setValue( "add" );

        for ( File file : files.getFileList() )
        {
            command.createArg().setValue( file.getName() );
        }
        return command;
    }
View Full Code Here

        throws Exception
    {
        ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
        PerforceScmProviderRepository svnRepository =
            (PerforceScmProviderRepository) repository.getProviderRepository();
        Commandline cl = PerforceEditCommand.createCommandLine( svnRepository, workingDir, files );

        assertCommandLine( commandLine, null, cl );
    }
View Full Code Here

    }

    public static Commandline createOpenedCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
                                                       String location )
    {
        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
        command.createArg().setValue( "opened" );
        command.createArg().setValue( PerforceScmProvider.getCanonicalRepoPath( location ) );
        return command;
    }
View Full Code Here

                                                          ScmVersion endVersion )
        throws ScmException
    {
        PerforceScmProviderRepository p4repo = (PerforceScmProviderRepository) repo;
        String clientspec = PerforceScmProvider.getClientspecName( getLogger(), p4repo, fileSet.getBasedir() );
        Commandline cl = createCommandLine( p4repo, fileSet.getBasedir(), clientspec, null, startDate, endDate, startVersion, endVersion );

        String location = PerforceScmProvider.getRepoPath( getLogger(), p4repo, fileSet.getBasedir() );
        PerforceChangesConsumer consumer =
            new PerforceChangesConsumer( getLogger() );

        try
        {
            if ( getLogger().isDebugEnabled() )
            {
                getLogger().debug( PerforceScmProvider.clean( "Executing " + cl.toString() ) );
            }

            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
            int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err );

            if ( exitCode != 0 )
            {
                String cmdLine = CommandLineUtils.toString( cl.getCommandline() );

                StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() );
                msg.append( '\n' );
                msg.append( "Command line was:" + cmdLine );

                throw new CommandLineException( msg.toString() );
            }
        }
        catch ( CommandLineException e )
        {
            if ( getLogger().isErrorEnabled() )
            {
                getLogger().error( "CommandLineException " + e.getMessage(), e );
            }
        }

        List<String> changes = consumer.getChanges();

        cl = PerforceScmProvider.createP4Command( p4repo, fileSet.getBasedir() );
        cl.createArg().setValue( "describe" );
        cl.createArg().setValue( "-s" );

        for( String change : changes )
        {
            cl.createArg().setValue( change );
        }

        PerforceDescribeConsumer describeConsumer =
            new PerforceDescribeConsumer( location, datePattern, getLogger() );

        try
        {
            if ( getLogger().isDebugEnabled() )
            {
                getLogger().debug( PerforceScmProvider.clean( "Executing " + cl.toString() ) );
            }

            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
            int exitCode = CommandLineUtils.executeCommandLine( cl, describeConsumer, err );

            if ( exitCode != 0 )
            {
                String cmdLine = CommandLineUtils.toString( cl.getCommandline() );

                StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() );
                msg.append( '\n' );
                msg.append( "Command line was:" + cmdLine );

                throw new CommandLineException( msg.toString() );
            }
        }
        catch ( CommandLineException e )
        {
            if ( getLogger().isErrorEnabled() )
            {
                getLogger().error( "CommandLineException " + e.getMessage(), e );
            }
        }

        ChangeLogSet cls = new ChangeLogSet( describeConsumer.getModifications(), null, null );
        cls.setStartVersion(startVersion);
        cls.setEndVersion(endVersion);
        return new ChangeLogScmResult( cl.toString(), cls );
    }
View Full Code Here

    /** {@inheritDoc} */
    protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet files, ScmVersion startRev,
                                                ScmVersion endRev )
        throws ScmException
    {
        Commandline cl =
            createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), startRev, endRev );
        PerforceDiffConsumer consumer = new PerforceDiffConsumer();
        if ( getLogger().isInfoEnabled() )
        {
            getLogger().info( "Executing: " + PerforceScmProvider.clean( cl.toString() ) );
        }
        boolean success = false;
        try
        {
            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
            int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err );

            if ( exitCode != 0 )
            {
                String cmdLine = CommandLineUtils.toString( cl.getCommandline() );

                StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() );
                msg.append( '\n' );
                msg.append( "Command line was:" + cmdLine );

                throw new CommandLineException( msg.toString() );
            }
        }
        catch ( CommandLineException e )
        {
            if ( getLogger().isErrorEnabled() )
            {
                getLogger().error( "CommandLineException " + e.getMessage(), e );
            }
        }

        return new DiffScmResult( cl.toString(), success ? "Diff successful" : "Unable to diff", consumer
            .getOutput(), success );
    }
View Full Code Here

                                                 String clientspec,
                                                 ScmBranch branch, Date startDate, Date endDate,
                                                 ScmVersion startVersion, ScmVersion endVersion )
    {
        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd:HH:mm:ss");
        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );

        if ( clientspec != null )
        {
            command.createArg().setValue( "-c" );
            command.createArg().setValue( clientspec );
        }
        command.createArg().setValue( "changes" );
        command.createArg().setValue( "-t" );

        StringBuilder fileSpec = new StringBuilder("...");
        if ( startDate != null )
        {
            fileSpec.append( "@" )
                 .append( dateFormat.format(startDate) )
                 .append( "," );

            if ( endDate != null )
            {
                fileSpec.append( dateFormat.format(endDate) );
            }
            else
            {
                fileSpec.append( "now" );
            }
        }

        if ( startVersion != null )
        {
            fileSpec.append("@").append(startVersion.getName()).append(",");

            if ( endVersion != null )
            {
                fileSpec.append( endVersion.getName() );
            }
            else
            {
                fileSpec.append("now");
            }
        }

        command.createArg().setValue( fileSpec.toString() );

        return command;
    }
View Full Code Here

TOP

Related Classes of org.codehaus.plexus.util.cli.Commandline$Argument

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.