Package org.apache.tools.ant.types

Examples of org.apache.tools.ant.types.CommandlineJava


    log("Test class names:\n" + testClassPerLine, Project.MSG_VERBOSE);

    Files.write(testClassPerLine, classNamesFile, Charsets.UTF_8);

    // Prepare command line for java execution.
    CommandlineJava commandline;
    commandline = (CommandlineJava) getCommandline().clone();
    commandline.createClasspath(getProject()).add(addSlaveClasspath());
    commandline.setClassname(SlaveMainSafe.class.getName());
    if (slave.slaves == 1) {
      commandline.createArgument().setValue(SlaveMain.OPTION_FREQUENT_FLUSH);
    }

    // Set up full output files.
    File sysoutFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".sysout", getTempDir());
    File syserrFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".syserr", getTempDir());

    // Set up communication channel.
    File eventFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".events", getTempDir());
    temporaryFiles.add(eventFile);
    commandline.createArgument().setValue(SlaveMain.OPTION_EVENTSFILE);
    commandline.createArgument().setFile(eventFile);
   
    if (sysouts) {
      commandline.createArgument().setValue(SlaveMain.OPTION_SYSOUTS);
    }

    InputStream eventStream = new TailInputStream(eventFile);

    // Set up input suites file.
    commandline.createArgument().setValue("@" + classNamesFile.getAbsolutePath());

    // Emit command line before -stdin to avoid confusion.
    slave.slaveCommandLine = escapeAndJoin(commandline.getCommandline());
    log("Forked JVM process command line (may need escape sequences for your shell):\n" +
        slave.slaveCommandLine, Project.MSG_VERBOSE);

    commandline.createArgument().setValue(SlaveMain.OPTION_STDIN);

    final EventBus eventBus = new EventBus("slave-" + slave.id);
    final DiagnosticsListener diagnosticsListener = new DiagnosticsListener(slave, this);
    eventBus.register(diagnosticsListener);
    eventBus.register(new AggregatingListener(aggregatedBus, slave));
View Full Code Here


    log("Test class names:\n" + testClassPerLine, Project.MSG_VERBOSE);

    Files.write(testClassPerLine, classNamesFile, Charsets.UTF_8);

    // Prepare command line for java execution.
    CommandlineJava commandline;
    commandline = (CommandlineJava) getCommandline().clone();
    commandline.createClasspath(getProject()).add(addSlaveClasspath());
    commandline.setClassname(SlaveMainSafe.class.getName());
    if (slave.slaves == 1) {
      commandline.createArgument().setValue(SlaveMain.OPTION_FREQUENT_FLUSH);
    }

    // Set up full output files.
    File sysoutFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".sysout", getTempDir());
    File syserrFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".syserr", getTempDir());

    // Set up communication channel.
    File eventFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".events", getTempDir());
    temporaryFiles.add(eventFile);
    commandline.createArgument().setValue(SlaveMain.OPTION_EVENTSFILE);
    commandline.createArgument().setFile(eventFile);
   
    if (sysouts) {
      commandline.createArgument().setValue(SlaveMain.OPTION_SYSOUTS);
    }

    InputStream eventStream = new TailInputStream(eventFile);

    // Set up input suites file.
    commandline.createArgument().setValue("@" + classNamesFile.getAbsolutePath());

    // Emit command line before -stdin to avoid confusion.
    slave.slaveCommandLine = escapeAndJoin(commandline.getCommandline());
    log("Forked JVM process command line (may need escape sequences for your shell):\n" +
        slave.slaveCommandLine, Project.MSG_VERBOSE);

    commandline.createArgument().setValue(SlaveMain.OPTION_STDIN);

    final EventBus eventBus = new EventBus("slave-" + slave.id);
    final DiagnosticsListener diagnosticsListener = new DiagnosticsListener(slave, this);
    eventBus.register(diagnosticsListener);
    eventBus.register(new AggregatingListener(aggregatedBus, slave));
View Full Code Here

     * our execute method
     */
    public boolean execute()
        throws BuildException {
        getJspc().log("Using jasper compiler", Project.MSG_VERBOSE);
        CommandlineJava cmd = setupJasperCommand();


        try {
            // Create an instance of the compiler, redirecting output to
            // the project log
            Java java = (Java) (getProject().createTask("java"));
            if (getJspc().getClasspath() != null) {
                getProject().log("using user supplied classpath: "+getJspc().getClasspath(),
                    Project.MSG_DEBUG);
                java.setClasspath(getJspc().getClasspath()
                                  .concatSystemClasspath("ignore"));
            } else {
                Path classpath=new Path(getProject());
                classpath=classpath.concatSystemClasspath("only");
                getProject().log("using system classpath: "+classpath, Project.MSG_DEBUG);
                java.setClasspath(classpath);
            }
            java.setDir(getProject().getBaseDir());
            java.setClassname("org.apache.jasper.JspC");
            //this is really irritating; we need a way to set stuff
            String args[] = cmd.getJavaCommand().getArguments();
            for (int i = 0; i < args.length; i++) {
                java.createArg().setValue(args[i]);
            }
            java.setFailonerror(getJspc().getFailonerror());
            //we are forking here to be sure that if JspC calls
View Full Code Here

    /**
     * build up a command line
     * @return a command line for jasper
     */
    private CommandlineJava setupJasperCommand() {
        CommandlineJava cmd = new CommandlineJava();
        JspC jspc = getJspc();
        addArg(cmd, "-d", jspc.getDestdir());
        addArg(cmd, "-p", jspc.getPackage());
        addArg(cmd, "-v" + jspc.getVerbose());
        addArg(cmd, "-uriroot", jspc.getUriroot());
View Full Code Here

    /**
     * Executes the given classname with the given arguments as it
     * was a command line application.
     */
    protected void run(String classname, Vector args) throws BuildException {
        CommandlineJava cmdj = new CommandlineJava();
        cmdj.setClassname(classname);
        for (int i = 0; i < args.size(); i++) {
            cmdj.createArgument().setValue((String) args.elementAt(i));
        }
        run(cmdj);
    }
View Full Code Here

     */
    private static final int ERRORS = 1;

    public void execute() throws BuildException {

        CommandlineJava commandline = new CommandlineJava();

        if ("text".equals(format)) {
            commandline.setClassname("jdepend.textui.JDepend");
        } else
        if ("xml".equals(format)) {
            commandline.setClassname("jdepend.xmlui.JDepend");
        }

        if (_jvm != null) {
            commandline.setVm(_jvm);
        }

        if (getSourcespath() == null) {
            throw new BuildException("Missing Sourcepath required argument");
        }
View Full Code Here

      return compileSourcepath.createPath();
   }

   public void execute() throws BuildException
   {
      CommandlineJava cmd = new CommandlineJava();
      if (verbose)
         cmd.createArgument().setValue("-verbose");
      if (suppress)
         cmd.createArgument().setValue("-suppress");
      if (destDir != null)
      {
         cmd.createArgument().setValue("-destdir");
         cmd.createArgument().setFile(destDir);
      }

      logAndAddFilesToCompile(cmd);

      getProject().log("compileSourcepath: "+compileSourcepath, Project.MSG_DEBUG);
      try
      {
         // Create an instance of the compiler, redirecting output to
         // the project log
         if (classpath == null)
            throw new BuildException("No classpath");
         classpath.append(compilerClasspath);
         Java java = (Java) (getProject().createTask("java"));
         if (getClasspath() != null)
         {
            getProject().log("using user supplied classpath: " + getClasspath(), Project.MSG_DEBUG);
            java.setClasspath(getClasspath().concatSystemClasspath("ignore"));
         }
         else
         {
            Path classpath = new Path(getProject());
            classpath = classpath.concatSystemClasspath("only");
            getProject().log("using system classpath: " + classpath, Project.MSG_DEBUG);
            java.setClasspath(classpath);
         }

         java.setDir(getProject().getBaseDir());
         java.setClassname("org.jboss.ant.tasks.retrocheck.Checker");
         //this is really irritating; we need a way to set stuff
         String args[] = cmd.getJavaCommand().getArguments();
         for (int i = 0; i < args.length; i++)
         {
            java.createArg().setValue(args[i]);
         }
         java.setFailonerror(getFailonerror());
View Full Code Here

    log("Test class names:\n" + testClassPerLine, Project.MSG_VERBOSE);

    Files.write(testClassPerLine, classNamesFile, Charsets.UTF_8);

    // Prepare command line for java execution.
    CommandlineJava commandline;
    commandline = (CommandlineJava) getCommandline().clone();
    commandline.createClasspath(getProject()).add(addSlaveClasspath());
    commandline.setClassname(SlaveMainSafe.class.getName());
    if (slave.slaves == 1) {
      commandline.createArgument().setValue(SlaveMain.OPTION_FREQUENT_FLUSH);
    }

    // Set up full output files.
    File sysoutFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".sysout", getTempDir());
    File syserrFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".syserr", getTempDir());

    // Set up communication channel.
    File eventFile = tempFile(uniqueSeed,
        "junit4-J" + slave.id, ".events", getTempDir());
    temporaryFiles.add(eventFile);
    commandline.createArgument().setValue(SlaveMain.OPTION_EVENTSFILE);
    commandline.createArgument().setFile(eventFile);
   
    if (sysouts) {
      commandline.createArgument().setValue(SlaveMain.OPTION_SYSOUTS);
    }
   
    if (debugStream) {
      commandline.createArgument().setValue(SlaveMain.OPTION_DEBUGSTREAM);
    }

    InputStream eventStream = new TailInputStream(eventFile);

    // Set up input suites file.
    commandline.createArgument().setValue("@" + classNamesFile.getAbsolutePath());

    // Emit command line before -stdin to avoid confusion.
    slave.slaveCommandLine = escapeAndJoin(commandline.getCommandline());
    log("Forked JVM process command line (may need escape sequences for your shell):\n" +
        slave.slaveCommandLine, Project.MSG_VERBOSE);

    commandline.createArgument().setValue(SlaveMain.OPTION_STDIN);

    final EventBus eventBus = new EventBus("slave-" + slave.id);
    final DiagnosticsListener diagnosticsListener = new DiagnosticsListener(slave, this);
    eventBus.register(diagnosticsListener);
    eventBus.register(new AggregatingListener(aggregatedBus, slave));
View Full Code Here

                runner.run();
                exitValue = runner.getRetCode();

            } else {
                CommandlineJava cmd = (CommandlineJava) commandline.clone();
               
                cmd.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner");
                cmd.createArgument().setValue(test.getName());
                cmd.createArgument().setValue("haltOnError="
                                              + test.getHaltonerror());
                cmd.createArgument().setValue("haltOnFailure="
                                              + test.getHaltonfailure());
                if (summary) {
                    log("Running " + test.getName(), Project.MSG_INFO);
                   
                    cmd.createArgument().setValue("formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter");
                }

                StringBuffer formatterArg = new StringBuffer();
                for (int i=0; i<formatters.size(); i++) {
                    FormatterElement fe = (FormatterElement) formatters.elementAt(i);
                    formatterArg.append("formatter=");
                    formatterArg.append(fe.getClassname());
                    if (fe.getUseFile()) {
                        formatterArg.append(",");
                        formatterArg.append(project.resolveFile(test.getOutfile()
                                                                +fe.getExtension())
                                            .getAbsolutePath());
                    }
                    cmd.createArgument().setValue(formatterArg.toString());
                    formatterArg.setLength(0);
                }
               
                FormatterElement[] add = test.getFormatters();
                for (int i=0; i<add.length; i++) {
                    formatterArg.append("formatter=");
                    formatterArg.append(add[i].getClassname());
                    if (add[i].getUseFile()) {
                        formatterArg.append(",");
                        formatterArg.append(project.resolveFile(test.getOutfile()
                                                                +add[i].getExtension())
                                            .getAbsolutePath());
                    }
                    cmd.createArgument().setValue(formatterArg.toString());
                    formatterArg.setLength(0);
                }

                Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN), createWatchdog());
                execute.setCommandline(cmd.getCommandline());
                if (dir != null) {
                    execute.setWorkingDirectory(dir);
                    execute.setAntRun(project);
                }
               
                log("Executing: "+cmd.toString(), Project.MSG_VERBOSE);
                try {
                    exitValue = execute.execute();
                } catch (IOException e) {
                    throw new BuildException("Process fork failed.", e,
                                             location);
View Full Code Here

     * @param  watchdog   the watchdog in charge of cancelling the test if it
     * exceeds a certain amount of time. Can be <tt>null</tt>, in this case
     * the test could probably hang forever.
     */
    private int executeAsForked(JUnitTest test, ExecuteWatchdog watchdog) throws BuildException {
        CommandlineJava cmd = (CommandlineJava) commandline.clone();

        cmd.setClassname("org.apache.tools.ant.taskdefs.optional.junit.JUnitTestRunner");
        cmd.createArgument().setValue(test.getName());
        cmd.createArgument().setValue("haltOnError=" + test.getHaltonerror());
        cmd.createArgument().setValue("haltOnFailure=" + test.getHaltonfailure());
        if (summary) {
            log("Running " + test.getName(), Project.MSG_INFO);
            cmd.createArgument().setValue("formatter=org.apache.tools.ant.taskdefs.optional.junit.SummaryJUnitResultFormatter");
        }

        StringBuffer formatterArg = new StringBuffer(128);
        final FormatterElement[] feArray = mergeFormatters(test);
        for (int i = 0; i < feArray.length; i++) {
            FormatterElement fe = feArray[i];
            formatterArg.append("formatter=");
            formatterArg.append(fe.getClassname());
            File outFile = getOutput(fe,test);
            if (outFile != null) {
                formatterArg.append(",");
                formatterArg.append( outFile );
            }
            cmd.createArgument().setValue(formatterArg.toString());
            formatterArg.setLength(0);
        }

        Execute execute = new Execute(new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_WARN), watchdog);
        execute.setCommandline(cmd.getCommandline());
        if (dir != null) {
            execute.setWorkingDirectory(dir);
            execute.setAntRun(project);
        }

        log("Executing: "+cmd.toString(), Project.MSG_VERBOSE);
        try {
            return execute.execute();
        } catch (IOException e) {
            throw new BuildException("Process fork failed.", e, location);
        }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.types.CommandlineJava

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.