sashikab
sashikab

Reputation: 61

how to remove java System.out.println from ant script

how to remove java System.out.println from ant script? (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)

Upvotes: 0

Views: 342

Answers (2)

sashikab
sashikab

Reputation: 61

We can use this in the ant file.

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

Upvotes: 1

SoorajSethumadhavan
SoorajSethumadhavan

Reputation: 117

In build.xml file, preparation phase, before the mkdir commands, provide:

<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 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.

Upvotes: 1

Related Questions