Examples of CommandLine


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

    mainParams.add("localeList=" + localeList);
    mainParams.add("internStrings=false");
    mainParams.add("action=release");
    mainParams.add("layerOptimize=" + layerOptimize);
    mainParams.add("profileFile=" + profilePath);
    Commandline commandLine = new Commandline();
    commandLine.setExecutable(javaExec);
    commandLine.setWorkingDirectory(dojoDirectory + "/util/buildscripts");
    List<String> commandArgs = new ArrayList<String>();
    // add the class path
    if (classpathArgs.size() > 0) {
      commandArgs.add("-classpath");
      String classpath = "";
      for (int i = 0; i < classpathArgs.size(); i++) {
        classpath += (i == 0 ? "" : File.pathSeparator);
        classpath += classpathArgs.get(i);
      }
      commandArgs.add(classpath);
    }
    // add the rest...
    commandArgs.add(mainClass);
    commandArgs.add(buildFile);
    for (String param : mainParams) {
      commandArgs.add(param);
    }
    commandLine.addArguments(commandArgs.toArray(new String[commandArgs.size()]));

    try {
      log.info("Executing " + commandLine.toString());
      int resultCode = CommandLineUtils.executeCommandLine(commandLine, new LogStream(), new LogStream());
      if (resultCode > 0) {
        throw new MojoExecutionException("Result of " + commandLine + " execution is: '" + resultCode + "'.");
      }
    } catch (CommandLineException e) {
View Full Code Here

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

    private static void fixScriptPermissions( File binDirectory )
        throws InterruptedException, CommandLineException
    {
        if ( Os.isFamily( "unix" ) )
        {
            Commandline cli = new Commandline();

            cli.setExecutable( "chmod" );

            cli.createArgument().setValue( "+x" );

            cli.createArgument().setValue( new File( binDirectory, "mvn" ).getAbsolutePath() );

            cli.createArgument().setValue( new File( binDirectory, "m2" ).getAbsolutePath() );

            cli.execute().waitFor();
        }
    }
View Full Code Here

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

    }

    private void runMaven( File installation, File basedir, String[] args )
        throws Exception, InterruptedException
    {
        Commandline cli = new Commandline();

        cli.setExecutable( new File( installation, "bin/mvn" ).getAbsolutePath() );

        cli.setWorkingDirectory( basedir.getAbsolutePath() );

        cli.createArgument().setValue( "-e" );
        cli.createArgument().setValue( "--batch-mode" );

        if ( offline )
        {
            cli.createArgument().setValue( "-o" );
        }
        if ( updateSnapshots )
        {
            cli.createArgument().setValue( "--update-snapshots" );
        }

        for ( int i = 0; i < args.length; i++ )
        {
            cli.createArgument().setValue( args[i] );
        }

        System.out.println( "Running Maven... " );
        System.out.println( cli.toString() );

        int exitCode = CommandLineUtils.executeCommandLine( cli,
                                                            new WriterStreamConsumer( new PrintWriter( System.out ) ),
                                                            new WriterStreamConsumer( new PrintWriter( System.err ) ) );
View Full Code Here

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

                // hackhish defaut commandline tools not support ; or && so write a file with the script
                // and "/bin/sh -e " + tmpFile.getPath();
                FileUtils.fileWrite( tmpFile, commandLine );

                Commandline cl = new Commandline();
                cl.setExecutable( "/bin/sh" );
                //cl.createArg().setValue( "-e" );
                //cl.createArg().setValue( tmpFile.getPath() );
                cl.createArg().setFile( tmpFile );

                exitValue = CommandLineUtils.executeCommandLine( cl, stdout, stderr );
                System.out.println( "exit value " + exitValue );
                /*
                if ( exitValue == 0 )
View Full Code Here

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

        }
        catch ( FileNotFoundException e )
        {
            throw new CommandExecutionException( e.getMessage(), e );
        }
        Commandline cl = createBaseCommandLine( putty, sshExecutable, privateKey );

        int port =
            repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
        if ( port != ScpHelper.DEFAULT_SSH_PORT )
        {
            if ( putty )
            {
                cl.createArg().setLine( "-P " + port );
            }
            else
            {
                cl.createArg().setLine( "-p " + port );
            }
        }

        if ( sshArgs != null )
        {
            cl.createArg().setLine( sshArgs );
        }

        String remoteHost = this.buildRemoteHost();

        cl.createArg().setValue( remoteHost );

        cl.createArg().setValue( command );

        fireSessionDebug( "Executing command: " + cl.toString() );

        try
        {
            CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
View Full Code Here

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

        return sshExecutable.toLowerCase( Locale.ENGLISH ).indexOf( "plink" ) >= 0;
    }

    private Commandline createBaseCommandLine( boolean putty, String executable, File privateKey )
    {
        Commandline cl = new Commandline();

        cl.setExecutable( executable );

        if ( privateKey != null )
        {
            cl.createArg().setValue( "-i" );
            cl.createArg().setFile( privateKey );
        }

        String password = authenticationInfo.getPassword();
        if ( putty && password != null )
        {
            cl.createArg().setValue( "-pw" );
            cl.createArg().setValue( password );
        }

        // should check interactive flag, but scpexe never works in interactive mode right now due to i/o streams
        if ( putty )
        {
            cl.createArg().setValue( "-batch" );
        }
        else
        {
            cl.createArg().setValue( "-o" );
            cl.createArg().setValue( "BatchMode yes" );
        }
        return cl;
    }
View Full Code Here

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

        {
            fireSessionConnectionRefused();

            throw new AuthorizationException( e.getMessage() );
        }
        Commandline cl = createBaseCommandLine( putty, scpExecutable, privateKey );

        cl.setWorkingDirectory( localFile.getParentFile().getAbsolutePath() );

        int port =
            repository.getPort() == WagonConstants.UNKNOWN_PORT ? ScpHelper.DEFAULT_SSH_PORT : repository.getPort();
        if ( port != ScpHelper.DEFAULT_SSH_PORT )
        {
            cl.createArg().setLine( "-P " + port );
        }

        if ( scpArgs != null )
        {
            cl.createArg().setLine( scpArgs );
        }

        String resourceName = normalizeResource( resource );
        String remoteFile = getRepository().getBasedir() + "/" + resourceName;

        remoteFile = StringUtils.replace( remoteFile, " ", "\\ " );

        String qualifiedRemoteFile = this.buildRemoteHost() + ":" + remoteFile;
        if ( put )
        {
            cl.createArg().setValue( localFile.getName() );
            cl.createArg().setValue( qualifiedRemoteFile );
        }
        else
        {
            cl.createArg().setValue( qualifiedRemoteFile );
            cl.createArg().setValue( localFile.getName() );
        }

        fireSessionDebug( "Executing command: " + cl.toString() );

        try
        {
            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
            int exitCode = CommandLineUtils.executeCommandLine( cl, null, err );
View Full Code Here

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

            authInfo.setUserName( "guest" );
            File sshKeysTarget = new File( "target/ssh-keys" );
            FileUtils.copyDirectory( new File( "src/test/ssh-keys" ), sshKeysTarget );
            // ssh keys need to 700 permissions
            // to prevent WARNING: UNPROTECTED PRIVATE KEY FILE!
            Commandline commandline = new Commandline( "chmod" );
            commandline.createArg().setValue( "-R" );
            commandline.createArg().setValue( "700" );
            commandline.createArg().setValue( sshKeysTarget.getCanonicalPath() );
            CommandLineUtils.StringStreamConsumer out = new CommandLineUtils.StringStreamConsumer();
            CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer();
            int exitCode = CommandLineUtils.executeCommandLine( commandline, out, err );
            Streams streams = new Streams();
            streams.setOut( out.getOutput() );
View Full Code Here

Examples of org.datanucleus.util.CommandLine

     */
    public static void main(String[] args) throws Exception
    {
        SchemaTool tool = new SchemaTool();

        CommandLine cmd = new CommandLine();
        cmd.addOption("create", "create", null, LOCALISER.msg(false, "014026"));
        cmd.addOption("delete", "delete", null, LOCALISER.msg(false, "014027"));
        cmd.addOption("validate", "validate", null, LOCALISER.msg(false, "014028"));
        cmd.addOption("dbinfo", "dbinfo", null, LOCALISER.msg(false, "014029"));
        cmd.addOption("schemainfo", "schemainfo", null, LOCALISER.msg(false, "014030"));
        cmd.addOption("help", "help", null, LOCALISER.msg(false, "014033"));

        cmd.addOption("ddlFile", "ddlFile", "ddlFile", LOCALISER.msg(false, "014031"));
        cmd.addOption("completeDdl", "completeDdl", null, LOCALISER.msg(false, "014032"));

        cmd.addOption("includeAutoStart", "includeAutoStart", null, "Include Auto-Start Mechanisms");

        cmd.addOption("api", "api", "api", "API Adapter (JDO, JPA, etc)");
        cmd.addOption("v", "verbose", null, "verbose output");

        cmd.addOption("pu", "persistenceUnit", "<persistence-unit>",
            "name of the persistence unit to handle the schema for");
        cmd.addOption("props", "properties", "props", "path to a properties file");
        cmd.parse(args);

        // Remaining command line args are filenames (class files, metadata files)
        String[] filenames = cmd.getDefaultArgs();

        if (cmd.hasOption("api"))
        {
            tool.setApi(cmd.getOptionArg("api"));
        }

        // Determine the mode of operation required
        String msg = null;
        int mode = SCHEMATOOL_CREATE_MODE;
        if (cmd.hasOption("create"))
        {
            mode = SCHEMATOOL_CREATE_MODE;
            msg = LOCALISER.msg(false, "014000");
        }
        else if (cmd.hasOption("delete"))
        {
            mode = SCHEMATOOL_DELETE_MODE;
            msg = LOCALISER.msg(false, "014001");
        }
        else if (cmd.hasOption("validate"))
        {
            mode = SCHEMATOOL_VALIDATE_MODE;
            msg = LOCALISER.msg(false, "014002");
        }
        else if (cmd.hasOption("dbinfo"))
        {
            mode = SCHEMATOOL_DATABASE_INFO_MODE;
            msg = LOCALISER.msg(false, "014003");
        }
        else if (cmd.hasOption("schemainfo"))
        {
            mode = SCHEMATOOL_SCHEMA_INFO_MODE;
            msg = LOCALISER.msg(false, "014004");
        }
        else if (cmd.hasOption("help"))
        {
            System.out.println(LOCALISER.msg(false, "014023"));
            System.out.println(LOCALISER.msg(false, "014024"));
            System.out.println(LOCALISER.msg(false, "014025"));
            System.out.println(cmd.toString());
            System.out.println(LOCALISER.msg(false, "014034"));
            System.out.println(LOCALISER.msg(false, "014035"));
            System.exit(0);
        }
        LOGGER.info(msg);
        System.out.println(msg);

        // Extract the selected options
        String propsFileName = null;
        String persistenceUnitName = null;
        if (cmd.hasOption("ddlFile"))
        {
            tool.setDdlFile(cmd.getOptionArg("ddlFile"));
        }
        if (cmd.hasOption("completeDdl"))
        {
            tool.setCompleteDdl(true);
        }
        if (cmd.hasOption("includeAutoStart"))
        {
            tool.setIncludeAutoStart(true);
        }
        if (cmd.hasOption("v"))
        {
            tool.setVerbose(true);
        }

        if (cmd.hasOption("pu"))
        {
            persistenceUnitName = cmd.getOptionArg("pu");
        }
        if (cmd.hasOption("props"))
        {
            propsFileName = cmd.getOptionArg("props");
        }

        // Classpath
        msg = LOCALISER.msg(false, "014005");
        LOGGER.info(msg);
View Full Code Here

Examples of org.dmd.util.parsing.CommandLine

  StringArrayList      jars     = new StringArrayList();
 
 
  public MvwGenUtility(String[] args) throws ResultException, IOException, DmcValueException, DmcValueExceptionSet {
    initHelp();
    cl = new CommandLine();
        cl.addOption("-h",         helpFlag,  "Dumps the help message.");
        cl.addOption("-srcdir",    srcdir,    "The source directories to search.");
        cl.addOption("-workspace",   workspace,   "The workspace prefix");
        cl.addOption("-autogen",   autogen,   "Indicates that you want to generate from all configs automatically.");
        cl.addOption("-debug",     debug,       "Dump debug information.");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.