98.7.3. 执行 Ant 脚本
以下示例通过构建文件 CamelExecBuildFile.xml 执行 Apache Ant (Windows),提供 ant.bat 在系统路径中,并且 CamelExecBuildFile.xml 位于当前目录中。
from("direct:exec")
.to("exec:ant.bat?args=-f CamelExecBuildFile.xml")
在下一个示例中,at .bat 命令通过 -l 将输出重定向到 CamelExecOutFile.txt。文件 CamelExecOutFile.txt 用作带 outFile=CamelExecOutFile.txt 的文件。该示例假定 ant.bat 位于系统路径中,并且 CamelExecBuildFile.xml 位于当前目录中。
from("direct:exec")
.to("exec:ant.bat?args=-f CamelExecBuildFile.xml -l CamelExecOutFile.txt&outFile=CamelExecOutFile.txt")
.process(new Processor() {
public void process(Exchange exchange) throws Exception {
InputStream outFile = exchange.getIn().getBody(InputStream.class);
assertIsInstanceOf(InputStream.class, outFile);
// do something with the out file here
}
});