Search in sources :

Example 1 with Execute

use of org.apache.tools.ant.taskdefs.Execute in project groovy by apache.

the class Groovyc method runForked.

private void runForked(String[] commandLine) {
    // use the main method in FileSystemCompiler
    // new LogStreamHandler ( attributes , Project.MSG_INFO , Project.MSG_WARN ) ) ;
    final Execute executor = new Execute();
    executor.setAntRun(getProject());
    executor.setWorkingDirectory(getProject().getBaseDir());
    executor.setCommandline(commandLine);
    try {
        executor.execute();
    } catch (final IOException ioe) {
        throw new BuildException("Error running forked groovyc.", ioe);
    }
    final int returnCode = executor.getExitValue();
    if (returnCode != 0) {
        taskSuccess = false;
        if (errorProperty != null) {
            getProject().setNewProperty(errorProperty, "true");
        }
        if (failOnError) {
            throw new BuildException("Forked groovyc returned error code: " + returnCode);
        } else {
            log.error("Forked groovyc returned error code: " + returnCode);
        }
    }
}
Also used : Execute(org.apache.tools.ant.taskdefs.Execute) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException)

Example 2 with Execute

use of org.apache.tools.ant.taskdefs.Execute in project groovy-core by groovy.

the class Groovyc method runForked.

private void runForked(String[] commandLine) {
    // use the main method in FileSystemCompiler
    // new LogStreamHandler ( attributes , Project.MSG_INFO , Project.MSG_WARN ) ) ;
    final Execute executor = new Execute();
    executor.setAntRun(getProject());
    executor.setWorkingDirectory(getProject().getBaseDir());
    executor.setCommandline(commandLine);
    try {
        executor.execute();
    } catch (final IOException ioe) {
        throw new BuildException("Error running forked groovyc.", ioe);
    }
    final int returnCode = executor.getExitValue();
    if (returnCode != 0) {
        taskSuccess = false;
        if (errorProperty != null) {
            getProject().setNewProperty(errorProperty, "true");
        }
        if (failOnError) {
            throw new BuildException("Forked groovyc returned error code: " + returnCode);
        } else {
            log.error("Forked groovyc returned error code: " + returnCode);
        }
    }
}
Also used : Execute(org.apache.tools.ant.taskdefs.Execute) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException)

Example 3 with Execute

use of org.apache.tools.ant.taskdefs.Execute in project randomizedtesting by randomizedtesting.

the class JUnit4 method forkProcess.

/**
   * Execute a slave process. Pump events to the given event bus.
   */
@SuppressForbidden("legitimate sysstreams.")
private Execute forkProcess(ForkedJvmInfo slaveInfo, EventBus eventBus, CommandlineJava commandline, InputStream eventStream, OutputStream sysout, OutputStream syserr, RandomAccessFile streamsBuffer) {
    try {
        final LocalSlaveStreamHandler streamHandler = new LocalSlaveStreamHandler(eventBus, testsClassLoader, System.err, eventStream, sysout, syserr, heartbeat, streamsBuffer);
        // Add certain properties to allow identification of the forked JVM from within
        // the subprocess. This can be used for policy files etc.
        final Path cwd = getWorkingDirectory(slaveInfo);
        Variable v = new Variable();
        v.setKey(CHILDVM_SYSPROP_CWD);
        v.setFile(cwd.toAbsolutePath().normalize().toFile());
        commandline.addSysproperty(v);
        v = new Variable();
        v.setKey(SysGlobals.CHILDVM_SYSPROP_JVM_ID);
        v.setValue(Integer.toString(slaveInfo.id));
        commandline.addSysproperty(v);
        v = new Variable();
        v.setKey(SysGlobals.CHILDVM_SYSPROP_JVM_COUNT);
        v.setValue(Integer.toString(slaveInfo.slaves));
        commandline.addSysproperty(v);
        // Emit command line before -stdin to avoid confusion.
        slaveInfo.slaveCommandLine = escapeAndJoin(commandline.getCommandline());
        log("Forked child JVM at '" + cwd.toAbsolutePath().normalize() + "', command (may need escape sequences for your shell):\n" + slaveInfo.slaveCommandLine, Project.MSG_VERBOSE);
        final Execute execute = new Execute();
        execute.setCommandline(commandline.getCommandline());
        execute.setVMLauncher(true);
        execute.setWorkingDirectory(cwd.toFile());
        execute.setStreamHandler(streamHandler);
        execute.setNewenvironment(newEnvironment);
        if (env.getVariables() != null)
            execute.setEnvironment(env.getVariables());
        log("Starting JVM J" + slaveInfo.id, Project.MSG_DEBUG);
        execute.execute();
        return execute;
    } catch (IOException e) {
        throw new BuildException("Could not start the child process. Run ant with -verbose to get" + " the execution details.", e);
    }
}
Also used : Path(java.nio.file.Path) Variable(org.apache.tools.ant.types.Environment.Variable) Execute(org.apache.tools.ant.taskdefs.Execute) IOException(java.io.IOException) BuildException(org.apache.tools.ant.BuildException) SuppressForbidden(com.carrotsearch.randomizedtesting.annotations.SuppressForbidden)

Example 4 with Execute

use of org.apache.tools.ant.taskdefs.Execute in project randomizedtesting by randomizedtesting.

the class JUnit4 method executeSlave.

/**
   * Attach listeners and execute a slave process.
   */
private void executeSlave(final ForkedJvmInfo slave, final EventBus aggregatedBus) throws Exception {
    final String uniqueSeed = new SimpleDateFormat("yyyyMMdd_HHmmss_SSS", Locale.ROOT).format(new Date());
    final Path classNamesFile = tempFile(uniqueSeed, "junit4-J" + slave.id, ".suites", getTempDir());
    temporaryFiles.add(classNamesFile);
    final Path classNamesDynamic = tempFile(uniqueSeed, "junit4-J" + slave.id, ".dynamic-suites", getTempDir());
    final Path streamsBufferFile = tempFile(uniqueSeed, "junit4-J" + slave.id, ".spill", getTempDir());
    // Dump all test class names to a temporary file.
    String testClassPerLine = Joiner.on("\n").join(slave.testSuites);
    log("Test class names:\n" + testClassPerLine, Project.MSG_VERBOSE);
    Files.write(classNamesFile, testClassPerLine.getBytes(StandardCharsets.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.
    Path sysoutFile = tempFile(uniqueSeed, "junit4-J" + slave.id, ".sysout", getTempDir());
    Path syserrFile = tempFile(uniqueSeed, "junit4-J" + slave.id, ".syserr", getTempDir());
    // Set up communication channel.
    Path eventFile = tempFile(uniqueSeed, "junit4-J" + slave.id, ".events", getTempDir());
    temporaryFiles.add(eventFile);
    commandline.createArgument().setValue(SlaveMain.OPTION_EVENTSFILE);
    commandline.createArgument().setFile(eventFile.toFile());
    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.toAbsolutePath().normalize());
    // not using it.
    if (dynamicAssignmentRatio > 0) {
        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));
    final AtomicReference<Charset> clientCharset = new AtomicReference<Charset>();
    final AtomicBoolean clientWithLimitedCharset = new AtomicBoolean();
    final PrintWriter w = new PrintWriter(Files.newBufferedWriter(classNamesDynamic, StandardCharsets.UTF_8));
    eventBus.register(new Object() {

        @Subscribe
        public void onIdleSlave(final SlaveIdle idleSlave) {
            aggregatedBus.post(new SlaveIdle() {

                @Override
                public void finished() {
                    idleSlave.finished();
                }

                @Override
                public void newSuite(String suiteName) {
                    if (!clientCharset.get().newEncoder().canEncode(suiteName)) {
                        clientWithLimitedCharset.set(true);
                        log("Forked JVM J" + slave.id + " skipped suite (cannot encode suite name in charset " + clientCharset.get() + "): " + suiteName, Project.MSG_WARN);
                        return;
                    }
                    log("Forked JVM J" + slave.id + " stole suite: " + suiteName, Project.MSG_VERBOSE);
                    w.println(suiteName);
                    w.flush();
                    idleSlave.newSuite(suiteName);
                }
            });
        }

        @Subscribe
        public void onBootstrap(final BootstrapEvent e) {
            Charset cs = Charset.forName(((BootstrapEvent) e).getDefaultCharsetName());
            clientCharset.set(cs);
            slave.start = System.currentTimeMillis();
            slave.setBootstrapEvent(e);
            aggregatedBus.post(new ChildBootstrap(slave));
        }

        @Subscribe
        public void receiveQuit(QuitEvent e) {
            slave.end = System.currentTimeMillis();
        }
    });
    Closer closer = Closer.create();
    closer.register(eventStream);
    closer.register(w);
    try {
        OutputStream sysout = closer.register(new BufferedOutputStream(Files.newOutputStream(sysoutFile)));
        OutputStream syserr = closer.register(new BufferedOutputStream(Files.newOutputStream(syserrFile)));
        RandomAccessFile streamsBuffer = closer.register(new RandomAccessFile(streamsBufferFile.toFile(), "rw"));
        Execute execute = forkProcess(slave, eventBus, commandline, eventStream, sysout, syserr, streamsBuffer);
        log("Forked JVM J" + slave.id + " finished with exit code: " + execute.getExitValue(), Project.MSG_DEBUG);
        if (execute.isFailure()) {
            final int exitStatus = execute.getExitValue();
            switch(exitStatus) {
                case SlaveMain.ERR_NO_JUNIT:
                    throw new BuildException("Forked JVM's classpath must include a junit4 JAR.");
                case SlaveMain.ERR_OLD_JUNIT:
                    throw new BuildException("Forked JVM's classpath must use JUnit 4.10 or newer.");
                default:
                    Closeables.close(sysout, false);
                    Closeables.close(syserr, false);
                    StringBuilder message = new StringBuilder();
                    if (exitStatus == SlaveMain.ERR_OOM) {
                        message.append("Forked JVM ran out of memory.");
                    } else {
                        message.append("Forked process returned with error code: ").append(exitStatus).append(".");
                    }
                    if (Files.size(sysoutFile) > 0 || Files.size(syserrFile) > 0) {
                        if (exitStatus != SlaveMain.ERR_OOM) {
                            message.append(" Very likely a JVM crash. ");
                        }
                        if (jvmOutputAction.contains(JvmOutputAction.PIPE)) {
                            message.append(" Process output piped in logs above.");
                        } else if (!jvmOutputAction.contains(JvmOutputAction.IGNORE)) {
                            if (Files.size(sysoutFile) > 0) {
                                message.append(" See process stdout at: " + sysoutFile.toAbsolutePath());
                            }
                            if (Files.size(syserrFile) > 0) {
                                message.append(" See process stderr at: " + syserrFile.toAbsolutePath());
                            }
                        }
                    }
                    throw new BuildException(message.toString());
            }
        }
    } catch (Throwable t) {
        throw closer.rethrow(t);
    } finally {
        try {
            closer.close();
        } finally {
            com.google.common.io.Files.asByteSource(classNamesDynamic.toFile()).copyTo(com.google.common.io.Files.asByteSink(classNamesFile.toFile(), FileWriteMode.APPEND));
            Files.delete(classNamesDynamic);
            Files.delete(streamsBufferFile);
            // Check sysout/syserr lengths.
            checkJvmOutput(aggregatedBus, sysoutFile, slave, "stdout");
            checkJvmOutput(aggregatedBus, syserrFile, slave, "stderr");
        }
    }
    if (!diagnosticsListener.quitReceived()) {
        throw new BuildException("Quit event not received from the forked process? This may indicate JVM crash or runner bugs.");
    }
    if (clientWithLimitedCharset.get() && dynamicAssignmentRatio > 0) {
        throw new BuildException("Forked JVM J" + slave.id + " was not be able to decode class names when using" + " charset: " + clientCharset + ". Do not use " + "dynamic suite balancing to work around this problem (-DdynamicAssignmentRatio=0).");
    }
}
Also used : Execute(org.apache.tools.ant.taskdefs.Execute) BufferedOutputStream(java.io.BufferedOutputStream) TeeOutputStream(com.carrotsearch.randomizedtesting.TeeOutputStream) OutputStream(java.io.OutputStream) EventBus(com.google.common.eventbus.EventBus) Subscribe(com.google.common.eventbus.Subscribe) BufferedOutputStream(java.io.BufferedOutputStream) AggregatingListener(com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatingListener) PrintWriter(java.io.PrintWriter) AggregatedQuitEvent(com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedQuitEvent) QuitEvent(com.carrotsearch.ant.tasks.junit4.events.QuitEvent) Path(java.nio.file.Path) Closer(com.google.common.io.Closer) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream) BootstrapEvent(com.carrotsearch.ant.tasks.junit4.events.BootstrapEvent) Charset(java.nio.charset.Charset) AtomicReference(java.util.concurrent.atomic.AtomicReference) CommandlineJava(org.apache.tools.ant.types.CommandlineJava) Date(java.util.Date) SuiteHint(com.carrotsearch.ant.tasks.junit4.balancers.SuiteHint) AtomicBoolean(java.util.concurrent.atomic.AtomicBoolean) ChildBootstrap(com.carrotsearch.ant.tasks.junit4.events.aggregated.ChildBootstrap) RandomAccessFile(java.io.RandomAccessFile) SlaveMainSafe(com.carrotsearch.ant.tasks.junit4.slave.SlaveMainSafe) BuildException(org.apache.tools.ant.BuildException) SimpleDateFormat(java.text.SimpleDateFormat)

Example 5 with Execute

use of org.apache.tools.ant.taskdefs.Execute in project jangaroo-tools by CoreMedia.

the class JoodocTask method execute.

public void execute() throws BuildException {
    if ("javadoc2".equals(taskType)) {
        log("!! javadoc2 is deprecated. Use javadoc instead. !!");
    }
    Vector packagesToDoc = new Vector();
    Path sourceDirs = new Path(getProject());
    if (packageList != null && sourcePath == null) {
        String msg = "sourcePath attribute must be set when " + "specifying packagelist.";
        throw new BuildException(msg);
    }
    if (sourcePath != null) {
        sourceDirs.addExisting(sourcePath);
    }
    parsePackages(packagesToDoc, sourceDirs);
    if (packagesToDoc.size() != 0 && sourceDirs.size() == 0) {
        String msg = "sourcePath attribute must be set when " + "specifying package names.";
        throw new BuildException(msg);
    }
    Vector sourceFilesToDoc = (Vector) sourceFiles.clone();
    addFileSets(sourceFilesToDoc);
    if (packageList == null && packagesToDoc.size() == 0 && sourceFilesToDoc.size() == 0) {
        throw new BuildException("No source files and no packages have " + "been specified.");
    }
    log("Generating Javadoc", Project.MSG_INFO);
    Commandline toExecute = (Commandline) cmd.clone();
    // ------------------------------------------ general javadoc arguments
    if (doctitle != null) {
        toExecute.createArgument().setValue("-doctitle");
        toExecute.createArgument().setValue(expand(doctitle.getText()));
    }
    if (header != null) {
        toExecute.createArgument().setValue("-header");
        toExecute.createArgument().setValue(expand(header.getText()));
    }
    if (footer != null) {
        toExecute.createArgument().setValue("-footer");
        toExecute.createArgument().setValue(expand(footer.getText()));
    }
    if (bottom != null) {
        toExecute.createArgument().setValue("-bottom");
        toExecute.createArgument().setValue(expand(bottom.getText()));
    }
    if (classpath == null) {
        classpath = (new Path(getProject())).concatSystemClasspath("last");
    } else {
        classpath = classpath.concatSystemClasspath("ignore");
    }
    if (!javadoc1) {
        if (classpath.size() > 0) {
            toExecute.createArgument().setValue("-classpath");
            toExecute.createArgument().setPath(classpath);
        }
        if (sourceDirs.size() > 0) {
            toExecute.createArgument().setValue("-sourcepath");
            toExecute.createArgument().setPath(sourceDirs);
        }
    } else {
        //sourceDirs.append(classpath);
        if (sourceDirs.size() > 0) {
            toExecute.createArgument().setValue("-classpath");
            toExecute.createArgument().setPath(sourceDirs);
        }
    }
    if (version && doclet == null) {
        toExecute.createArgument().setValue("-version");
    }
    if (author && doclet == null) {
        toExecute.createArgument().setValue("-author");
    }
    if (javadoc1 || doclet == null) {
        if (destDir == null) {
            String msg = "destDir attribute must be set!";
            throw new BuildException(msg);
        }
    }
    if (!javadoc1) {
        if (doclet != null) {
            if (doclet.getName() == null) {
                throw new BuildException("The doclet name must be " + "specified.", getLocation());
            } else {
                toExecute.createArgument().setValue("-doclet");
                toExecute.createArgument().setValue(doclet.getName());
                if (doclet.getPath() != null) {
                    Path docletPath = doclet.getPath().concatSystemClasspath("ignore");
                    if (docletPath.size() != 0) {
                        toExecute.createArgument().setValue("-docletpath");
                        toExecute.createArgument().setPath(docletPath);
                    }
                }
                for (Enumeration e = doclet.getParams(); e.hasMoreElements(); ) {
                    DocletParam param = (DocletParam) e.nextElement();
                    if (param.getName() == null) {
                        throw new BuildException("Doclet parameters must " + "have a name");
                    }
                    toExecute.createArgument().setValue(param.getName());
                    if (param.getValue() != null) {
                        toExecute.createArgument().setValue(param.getValue());
                    }
                }
            }
        }
        if (bootclasspath != null && bootclasspath.size() > 0) {
            toExecute.createArgument().setValue("-bootclasspath");
            toExecute.createArgument().setPath(bootclasspath);
        }
        // add the links arguments
        if (links.size() != 0) {
            for (Enumeration e = links.elements(); e.hasMoreElements(); ) {
                LinkArgument la = (LinkArgument) e.nextElement();
                if (la.getHref() == null || la.getHref().length() == 0) {
                    log("No href was given for the link - skipping", Project.MSG_VERBOSE);
                    continue;
                } else {
                    // is the href a valid URL
                    try {
                        URL base = new URL("file://.");
                        new URL(base, la.getHref());
                    } catch (MalformedURLException mue) {
                        // ok - just skip
                        log("Link href \"" + la.getHref() + "\" is not a valid url - skipping link", Project.MSG_WARN);
                        continue;
                    }
                }
                if (la.isLinkOffline()) {
                    File packageListLocation = la.getPackagelistLoc();
                    if (packageListLocation == null) {
                        throw new BuildException("The package list " + " location for link " + la.getHref() + " must be provided because the link is " + "offline");
                    }
                    File packageListFile = new File(packageListLocation, "package-list");
                    if (packageListFile.exists()) {
                        try {
                            String packageListURL = fileUtils.getFileURL(packageListLocation).toExternalForm();
                            toExecute.createArgument().setValue("-linkoffline");
                            toExecute.createArgument().setValue(la.getHref());
                            toExecute.createArgument().setValue(packageListURL);
                        } catch (MalformedURLException ex) {
                            log("Warning: Package list location was " + "invalid " + packageListLocation, Project.MSG_WARN);
                        }
                    } else {
                        log("Warning: No package list was found at " + packageListLocation, Project.MSG_VERBOSE);
                    }
                } else {
                    toExecute.createArgument().setValue("-link");
                    toExecute.createArgument().setValue(la.getHref());
                }
            }
        }
        //                XPath_Packages org.apache.xalan.xpath*"
        if (group != null) {
            StringTokenizer tok = new StringTokenizer(group, ",", false);
            while (tok.hasMoreTokens()) {
                String grp = tok.nextToken().trim();
                int space = grp.indexOf(" ");
                if (space > 0) {
                    String name = grp.substring(0, space);
                    String pkgList = grp.substring(space + 1);
                    toExecute.createArgument().setValue("-group");
                    toExecute.createArgument().setValue(name);
                    toExecute.createArgument().setValue(pkgList);
                }
            }
        }
        // add the group arguments
        if (groups.size() != 0) {
            for (Enumeration e = groups.elements(); e.hasMoreElements(); ) {
                GroupArgument ga = (GroupArgument) e.nextElement();
                String title = ga.getTitle();
                String packages = ga.getPackages();
                if (title == null || packages == null) {
                    throw new BuildException("The title and packages must " + "be specified for group " + "elements.");
                }
                toExecute.createArgument().setValue("-group");
                toExecute.createArgument().setValue(expand(title));
                toExecute.createArgument().setValue(packages);
            }
        }
        // JavaDoc 1.4 parameters
        if (javadoc4) {
            for (Enumeration e = tags.elements(); e.hasMoreElements(); ) {
                Object element = e.nextElement();
                if (element instanceof TagArgument) {
                    TagArgument ta = (TagArgument) element;
                    toExecute.createArgument().setValue("-tag");
                    toExecute.createArgument().setValue(ta.getParameter());
                } else {
                    ExtensionInfo tagletInfo = (ExtensionInfo) element;
                    toExecute.createArgument().setValue("-taglet");
                    toExecute.createArgument().setValue(tagletInfo.getName());
                    if (tagletInfo.getPath() != null) {
                        Path tagletPath = tagletInfo.getPath().concatSystemClasspath("ignore");
                        if (tagletPath.size() != 0) {
                            toExecute.createArgument().setValue("-tagletpath");
                            toExecute.createArgument().setPath(tagletPath);
                        }
                    }
                }
            }
            if (source != null) {
                toExecute.createArgument().setValue("-source");
                toExecute.createArgument().setValue(source);
            }
        }
    }
    File tmpList = null;
    PrintWriter srcListWriter = null;
    try {
        /**
             * Write sourcefiles and package names to a temporary file
             * if requested.
             */
        if (useExternalFile) {
            if (tmpList == null) {
                tmpList = fileUtils.createTempFile("javadoc", "", null);
                toExecute.createArgument().setValue("@" + tmpList.getAbsolutePath());
            }
            srcListWriter = new PrintWriter(new FileWriter(tmpList.getAbsolutePath(), true));
        }
        Enumeration e = packagesToDoc.elements();
        while (e.hasMoreElements()) {
            String packageName = (String) e.nextElement();
            if (useExternalFile) {
                srcListWriter.println(packageName);
            } else {
                toExecute.createArgument().setValue(packageName);
            }
        }
        e = sourceFilesToDoc.elements();
        while (e.hasMoreElements()) {
            SourceFile sf = (SourceFile) e.nextElement();
            String sourceFileName = sf.getFile().getAbsolutePath();
            if (useExternalFile) {
                srcListWriter.println(sourceFileName);
            } else {
                toExecute.createArgument().setValue(sourceFileName);
            }
        }
    } catch (IOException e) {
        tmpList.delete();
        throw new BuildException("Error creating temporary file", e, getLocation());
    } finally {
        if (srcListWriter != null) {
            srcListWriter.close();
        }
    }
    if (packageList != null) {
        toExecute.createArgument().setValue("@" + packageList);
    }
    log(toExecute.describeCommand(), Project.MSG_VERBOSE);
    log("Javadoc execution", Project.MSG_INFO);
    JavadocOutputStream out = new JavadocOutputStream(Project.MSG_INFO);
    JavadocOutputStream err = new JavadocOutputStream(Project.MSG_WARN);
    Execute exe = new Execute(new PumpStreamHandler(out, err));
    exe.setAntRun(getProject());
    /*
         * No reason to change the working directory as all filenames and
         * path components have been resolved already.
         *
         * Avoid problems with command line length in some environments.
         */
    exe.setWorkingDirectory(null);
    try {
        exe.setCommandline(toExecute.getCommandline());
        int ret = 0;
        String[] arguments = toExecute.getArguments();
        for (int i = 0; i < arguments.length; i++) {
            String argument = arguments[i];
            System.out.println(i + ") " + argument);
        }
        // int ret =exe.execute();
        Main.main(arguments);
        if (ret != 0 && failOnError) {
            throw new BuildException("Javadoc returned " + ret, getLocation());
        }
    } finally {
        if (tmpList != null) {
            tmpList.delete();
            tmpList = null;
        }
        out.logFlush();
        err.logFlush();
        try {
            out.close();
            err.close();
        } catch (IOException e) {
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) Commandline(org.apache.tools.ant.types.Commandline) Execute(org.apache.tools.ant.taskdefs.Execute) FileWriter(java.io.FileWriter) URL(java.net.URL) PumpStreamHandler(org.apache.tools.ant.taskdefs.PumpStreamHandler) Vector(java.util.Vector) PrintWriter(java.io.PrintWriter) Path(org.apache.tools.ant.types.Path) Enumeration(java.util.Enumeration) IOException(java.io.IOException) StringTokenizer(java.util.StringTokenizer) BuildException(org.apache.tools.ant.BuildException) File(java.io.File)

Aggregations

BuildException (org.apache.tools.ant.BuildException)6 Execute (org.apache.tools.ant.taskdefs.Execute)6 IOException (java.io.IOException)4 File (java.io.File)2 FileWriter (java.io.FileWriter)2 PrintWriter (java.io.PrintWriter)2 Path (java.nio.file.Path)2 SuiteHint (com.carrotsearch.ant.tasks.junit4.balancers.SuiteHint)1 BootstrapEvent (com.carrotsearch.ant.tasks.junit4.events.BootstrapEvent)1 QuitEvent (com.carrotsearch.ant.tasks.junit4.events.QuitEvent)1 AggregatedQuitEvent (com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatedQuitEvent)1 AggregatingListener (com.carrotsearch.ant.tasks.junit4.events.aggregated.AggregatingListener)1 ChildBootstrap (com.carrotsearch.ant.tasks.junit4.events.aggregated.ChildBootstrap)1 SlaveMainSafe (com.carrotsearch.ant.tasks.junit4.slave.SlaveMainSafe)1 TeeOutputStream (com.carrotsearch.randomizedtesting.TeeOutputStream)1 SuppressForbidden (com.carrotsearch.randomizedtesting.annotations.SuppressForbidden)1 EventBus (com.google.common.eventbus.EventBus)1 Subscribe (com.google.common.eventbus.Subscribe)1 Closer (com.google.common.io.Closer)1 BufferedInputStream (java.io.BufferedInputStream)1