org.apache.tools.ant.DemuxOutputStream Java Examples
The following examples show how to use
org.apache.tools.ant.DemuxOutputStream.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AntBuilder.java From groovy with Apache License 2.0 | 4 votes |
@SuppressFBWarnings(value = "DM_DEFAULT_ENCODING", justification = "We are only wrapping stdout/stderr which are likely created with default encoding") private PrintStream printStream(DemuxOutputStream outputStream) { // we could make a saveStreamEncoding but seems like a rare scenario return new PrintStream(outputStream); }
Example #2
Source File: AntCallTriggerTest.java From ant-ivy with Apache License 2.0 | 4 votes |
private void runBuild(File buildFile, Vector<String> targets, int messageLevel) throws BuildException { final Project project = new Project(); project.setCoreLoader(null); Throwable error = null; try { addBuildListeners(project, messageLevel); addInputHandler(project, null); PrintStream err = System.err; PrintStream out = System.out; InputStream in = System.in; // use a system manager that prevents from System.exit() SecurityManager oldsm = null; oldsm = System.getSecurityManager(); // SecurityManager can not be installed here for backwards // compatibility reasons (PD). Needs to be loaded prior to // ant class if we are going to implement it. // System.setSecurityManager(new NoExitSecurityManager()); try { project.setDefaultInputStream(System.in); System.setIn(new DemuxInputStream(project)); System.setOut(new PrintStream(new DemuxOutputStream(project, false))); System.setErr(new PrintStream(new DemuxOutputStream(project, true))); project.fireBuildStarted(); project.init(); project.setUserProperty("ant.version", Main.getAntVersion()); project.setUserProperty("ant.file", buildFile.getAbsolutePath()); ProjectHelper.configureProject(project, buildFile); // make sure that we have a target to execute if (targets.size() == 0 && project.getDefaultTarget() != null) { targets.addElement(project.getDefaultTarget()); } project.executeTargets(targets); } finally { // put back the original security manager // The following will never eval to true. (PD) if (oldsm != null) { System.setSecurityManager(oldsm); } System.setOut(out); System.setErr(err); System.setIn(in); } } catch (RuntimeException | Error exc) { error = exc; throw exc; } finally { project.fireBuildFinished(error); } }