Package org.apache.tools.ant.taskdefs

Examples of org.apache.tools.ant.taskdefs.Redirector


        cmdline.createArgument().setValue(target.toString());

        log(cmdline.describeCommand(), Project.MSG_VERBOSE);

        // redirect output generated by ANTLR to temporary file
        Redirector r = new Redirector(this);
        File f;
        try {
            f = File.createTempFile("depend", null, getOutputdirectory());
            f.deleteOnExit();
            log("Write dependencies for '" + target.toString() + "' to file '" + f.getCanonicalPath() + "'", Project.MSG_VERBOSE);
            r.setOutput(f);
            r.setAlwaysLog(false);
            r.createStreams();
        } catch (IOException e) {
            throw new BuildException("Redirection of output failed: " + e);
        }

        // execute antlr -depend ...
        int err = 0;
        try {
            err = run(cmdline.getCommandline(), r.getOutputStream(), null);
        } catch (IOException e) {
            try {
                r.complete();
                log("Redirection of output terminated.", Project.MSG_VERBOSE);
            } catch (IOException ex) {
                log("Termination of output redirection failed: " + ex, Project.MSG_ERR);
            }
            throw new BuildException(e, getLocation());
        } finally {
            try {
                bos.close();
            } catch (IOException e) {
                // ignore
            }
        }

        try {
            r.complete();
            log("Redirection of output terminated.", Project.MSG_VERBOSE);
        } catch (IOException e) {
            log("Termination of output redirection failed: " + e, Project.MSG_ERR);
        }
View Full Code Here


import org.apache.tools.ant.taskdefs.Execute;
import org.apache.tools.ant.taskdefs.Redirector;

public class CommandRunnerImpl implements CommandRunner {
    public int fork(Task task, String[] command) throws BuildException {
        Redirector redirector = new Redirector(task);
        redirector.createStreams();
        Execute exe = new Execute(redirector.createHandler());
        exe.setAntRun(task.getProject());
        exe.setWorkingDirectory(task.getProject().getBaseDir());
        exe.setCommandline(command);
        try {
            int rc = exe.execute();
            redirector.complete();
            return rc;
        } catch (IOException e) {
            throw new BuildException(e, task.getLocation());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.tools.ant.taskdefs.Redirector

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.