Make Ant Java Task Print Blank Lines

When starting Java applications through java Ant, the task does not print empty lines. This makes it difficult to scan long output files, as all separation is deleted.

Does anyone know how to make Ant print blank lines?

thanks

Example:

Running the following java code through ant:

System.out.println("Hello"); System.out.println(""); System.out.println("World"); 

I expect Ant to create:

 [java] Hello [java] [java] World 

But exits

 [java] Hello [java] World 
+4
source share
2 answers

I tested the following code using Ant 1.8.2 on Ubuntu Linux 12.04, as well as on Windows 7. On both operating systems, a blank line was printed, as shown in the following figure.

JavaTest.java

 /** * Java test. */ public class JavaTest { public static void main(String[] args) { System.out.println("Hello"); System.out.println(""); System.out.println("World"); } } 

Inside build.xml

 <target name="java-test" depends="compile"> <java classpath="${classes.dir}" classname="JavaTest" fork="true" failonerror="true" /> </target> 

Output

 $ ant java-test Buildfile: /home/my/project/build.xml java-test: [java] Hello [java] [java] World BUILD SUCCESSFUL Total time: 2 seconds 
0
source

Another way without compiling special classes is to use a script, for example.

 <script language="groovy"> println("Hello\n\nWorld!") </script> 
code>
0
source

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


All Articles