如何在 ant(1) 中执行 makefile(4) 规则?
我想知道如何在 ant(1) 中执行相当于特定 makefile(4) 规则的操作。 makefile(4) 规则执行以下操作: 1) 启动一个不会终止的进程,并将一行写入其标准输出流; 2)从进程中读取行; 3) 使用该行构造一个文件; 4) 使用该文件作为参数启动第二个进程,该进程不会终止。概括地说,makefile(4) 规则是
program1 | while read arg; do \
echo $$arg >file; \
program2 file; \
done
注意:“program1”写入一行; “program1”和“program2”都不会终止。
在 ant(1) 中如何做到这一点?
I would like to know how to do something in ant(1) that's equivalent to a particular makefile(4) rule. The makefile(4) rule does the following: 1) starts a process that doesn't terminate and that writes one line to its standard output stream; 2) reads the line from the process; 3) constructs a file using the line; and 4) starts a second process that doesn't terminate using the file as an argument. Schematically, the makefile(4) rule is
program1 | while read arg; do \
echo $arg >file; \
program2 file; \
done
NOTE: "program1" writes one line; neither "program1" nor "program2" terminates.
How can this be done in ant(1)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够使用
ProcessBuilder
如下所述:然后您的
java
任务相当简单:
附录:
您可以在
脚本任务
。我没有看到直接使用标准输入和输出的方法,但您可以使用
loadfile 任务
从文件加载属性。下面是一个从源文件获取版本号的示例。You should be able to use
ProcessBuilder
as outlined below:Then your
java
task is fairly straightforward:Addendum:
You can use any Apache BSF or JSR 223 supported language in the
script task
. I don't see a way to use standard input and output directly, but you can use theloadfile task
to load a property from a file. Here's an example that obtains a version number from a source file.