本文整理汇总了Java中org.apache.tools.ant.DemuxOutputStream类的典型用法代码示例。如果您正苦于以下问题:Java DemuxOutputStream类的具体用法?Java DemuxOutputStream怎么用?Java DemuxOutputStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DemuxOutputStream类属于org.apache.tools.ant包,在下文中一共展示了DemuxOutputStream类的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: buildProject
import org.apache.tools.ant.DemuxOutputStream; //导入依赖的package包/类
/**
* Initializes an ant project. The base directory is the current working directory.
*
* @return Ant project.
*/
private static Project buildProject() {
Project project = new Project();
project.setBasedir(System.getProperty("user.dir"));
project.init();
DefaultLogger logger = new DefaultLogger();
project.addBuildListener(logger);
logger.setOutputPrintStream(System.out);
logger.setErrorPrintStream(System.err);
logger.setMessageOutputLevel(Project.MSG_VERBOSE);
System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
project.fireBuildStarted();
return project;
}
开发者ID:th-schwarz,项目名称:pmcms,代码行数:20,代码来源:InternalAntTool.java
示例2: runBuild
import org.apache.tools.ant.DemuxOutputStream; //导入依赖的package包/类
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);
}
}
开发者ID:apache,项目名称:ant-ivy,代码行数:63,代码来源:AntCallTriggerTest.java
示例3: main
import org.apache.tools.ant.DemuxOutputStream; //导入依赖的package包/类
public static void main(String[] args) {
// global ant project settings
Project project = new Project();
project.setBaseDir(new File(System.getProperty("user.dir")));
project.init();
DefaultLogger logger = new DefaultLogger();
project.addBuildListener(logger);
logger.setOutputPrintStream(System.out);
logger.setErrorPrintStream(System.err);
logger.setMessageOutputLevel(Project.MSG_INFO);
System.setOut(new PrintStream(new DemuxOutputStream(project, false)));
System.setErr(new PrintStream(new DemuxOutputStream(project, true)));
project.fireBuildStarted();
Throwable caught = null;
try {
// an echo example
Echo echo = new Echo();
echo.setTaskName("Echo");
echo.setProject(project);
echo.init();
echo.setMessage("Launching ...");
echo.execute();
/** initialize an java task **/
Java javaTask = new Java();
javaTask.setNewenvironment(true);
javaTask.setTaskName("runjava");
javaTask.setProject(project);
javaTask.setFork(true);
javaTask.setFailonerror(true);
javaTask.setClassname(MyClassToLaunch.class.getName());
// add some vm args
Argument jvmArgs = javaTask.createJvmarg();
jvmArgs.setLine("-Xms512m -Xmx512m");
// added some args for to class to launch
Argument taskArgs = javaTask.createArg();
taskArgs.setLine("bla path=/tmp/");
Path classPath = new Path(project, new File(System.getProperty("user.dir") + "/bin/test").getAbsolutePath());
javaTask.setClasspath(classPath);
javaTask.init();
int ret = javaTask.executeJava();
System.out.println("return code: " + ret);
} catch (BuildException e) {
caught = e;
}
project.log("finished");
project.fireBuildFinished(caught);
}
开发者ID:th-schwarz,项目名称:pmcms,代码行数:56,代码来源:MyLauncher.java
注:本文中的org.apache.tools.ant.DemuxOutputStream类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论