Ant output to 2 different sources?

I run Ant with the output filed to the log file:

ant -logfile file.txt target-name

I would also like to print some progress information on the console. The answer seems to be a BuildEvent listener that writes to the console every time a new target is hit, but the documentation explicitly states:

The listener should not access System.out and System.err directly, since ouput in these threads is redirected by the Ant kernel to the assembly event system.

Did I miss something? Is there any way to do this?

+3
source share
3 answers

Ant replaces the System.out and System.err threads to reassign messages printed there through its own logging system.

, ACTUAL OS, java.io.FileDescriptor # out

+3

Log4jListener.

log4j , . <echo> level, , .

+3

! , , .

- , , Carej, java.io.FileDescriptor # out Ant scriptdef :

<scriptdef name="progress-text" language="javascript" >
  output = new java.io.PrintStream(new java.io.FileOutputStream(java.io.FileDescriptor.err))
  output.println(self.text)
</scriptdef>

, ? ?


EDIT: 2 , - :

All this gave me a little more confidence in this approach.

+1
source

Source: https://habr.com/ru/post/1723745/


All Articles