Apache Ant - program exit followed by tags [java]

Stupid question, but I could not find the answer anywhere.

We are currently learning Apache Ant, and I started by creating a basic build file and a java project that prints a line of string to the console. This is what is output when I used the command

ant compile jar run

 PS C:\Users\zayd\Desktop\Apps\pbox> ant compile jar run Buildfile: C:\Users\zayd\Desktop\Apps\pbox\build.xml compile: [mkdir] Created dir: C:\Users\zayd\Desktop\Apps\pbox\build\classes [javac] C:\Users\zayd\Desktop\Apps\pbox\build.xml:9: warning: 'includeantruntime' was not set, defaulting to build.s ysclasspath=last; set to false for repeatable builds [javac] Compiling 8 source files to C:\Users\zayd\Desktop\Apps\pbox\build\classes jar: [mkdir] Created dir: C:\Users\zayd\Desktop\Apps\pbox\build\jar [jar] Building jar: C:\Users\zayd\Desktop\Apps\pbox\build\jar\Main.jar run: [java] ~We'll go down in history~ BUILD SUCCESSFUL Total time: 1 second 

Is there a way to remove the [java] tags that are printed with the program output?

+6
source share
2 answers

By default, you cannot. The output task prefix is ​​controlled by the Ant logging mechanism, not the java task itself, so there is no way to change the use of the java task to remove this output.

The only way is to write your own BuildLogger to configure build event messages, and then instruct Ant to use this custom logger instead of DefaultLogger , which uses Ant by default. See https://ant.apache.org/manual/listeners.html (the link contains a pointer to a record of your own listeners and registrars).

If you really intend to do this, and not just ask about it for curiosity, then here is a snippet taken from DefaultLogger that indicates how the assembly event message is logged with the task name:

 /** * Logs a message, if the priority is suitable. * In non-emacs mode, task level messages are prefixed by the * task name which is right-justified. * * @param event A BuildEvent containing message information. * Must not be <code>null</code>. */ public void messageLogged(BuildEvent event) { int priority = event.getPriority(); // Filter out messages based on priority if (priority <= msgOutputLevel) { StringBuffer message = new StringBuffer(); if (event.getTask() != null && !emacsMode) { // Print out the name of the task if we're in one String name = event.getTask().getTaskName(); String label = "[" + name + "] "; 
+2
source

Have you tried the -emacs command-line -emacs ?

https://ant.apache.org/manual/running.html

0
source

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


All Articles