简体   繁体   English

如何从蚂蚁脚本中删除java System.out.println

[英]how to remove java System.out.println from ant script

how to remove java System.out.println from ant script? 如何从蚂蚁脚本中删除java System.out.println? (when we compile the code from ant we should remove the existing java class system.out.println & compiled classes should not have the Sys.out.println) (当我们从ant编译代码时,我们应该删除现有的java类system.out.println和已编译的类不应具有Sys.out.println)

In build.xml file, preparation phase, before the mkdir commands, provide: 在build.xml文件的准备阶段,在mkdir命令之前,提供:

<javac srcdir="exe" includes="SysOutRemove.java"/>
<java fork="true" classname="SysOutRemove" dir="exe" failonerror="true"/>

where SysOutRemove.java is in the exe package of your project. SysOutRemove.java在项目的exe软件包中。

SysOutRemove.java should iterate through the list of directories and files in them, store the contents of each file to a reader or something, find sysout statements and replace. SysOutRemove.java应该遍历目录和文件列表,将每个文件的内容存储到读取器或其他内容中,查找sysout语句并进行替换。

We can use this in the ant file. 我们可以在ant文件中使用它。

 <replaceregexp match="System.out.println(.*);" replace="" flags="g" byline="true"> <fileset dir="${src.dir}" includes="**/*.java"/> </replaceregexp> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM