Control the Build Script Output

I've heard in various places that various people consider it a significant annoyance to see all the Ant output in the Output window when, for example, a build is performed:

Firstly, it's worth pointing out that you don't see ALL the Ant output. That's because ALL the Ant output includes the output produced by Ant targets that have names that start with a hyphen, although the Output window (as shown above) excludes all these targets. These are targets that can only be called by other targets, and not independently. In fact, if you were to see ALL the Ant output, the Output window above would have this content:

-pre-init
-init-private
-init-user
-init-project
-init-macrodef-property
-do-init
-post-init
-init-check
-init-macrodef-javac
-init-macrodef-junit
-init-macrodef-nbjpda
-init-debug-args
-init-macrodef-debug
-init-macrodef-java
-init-presetdef-jar
init:
deps-jar:
-pre-pre-compile
Created dir: /home/geertjan/NetBeansProjects/JavaApplication5/build/classes
-pre-compile
-compile-depend
-do-compile
Compiling 1 source file to /home/geertjan/NetBeansProjects/JavaApplication5/build/classes
-post-compile
compile:
-pre-jar
-pre-pre-jar
Created dir: /home/geertjan/NetBeansProjects/JavaApplication5/dist
-do-jar-with-manifest
-do-jar-without-manifest
-do-jar-with-mainclass
-do-jar-with-libraries
Building jar: /home/geertjan/NetBeansProjects/JavaApplication5/dist/JavaApplication5.jar
Not copying the libraries.
To run this application from the command line without Ant, try:
java -jar "/home/geertjan/NetBeansProjects/JavaApplication5/dist/JavaApplication5.jar"
-post-jar
jar:
BUILD SUCCESSFUL (total time: 0 seconds)

Secondly, to exclude EVERYTHING (i.e., ALL the targets), the org.apache.tools.ant.module.run.StandardLogger class would need to be rewritten to change this (possibly with an option in the Options window to toggle Ant output being printed/not printed).

Thirdly, however, today I came across an e-mail by Tom Wheeler to the dev@openide.netbeans.org mailing list, where he points to this FAQ that he recently wrote:

How can I override an instance in the Lookup?

I tried that exact same approach, to mask out the org.apache.tools.ant.module.run.StandardLogger. Guess what? It worked. In META-INF/Services, I have a file called org.apache.tools.ant.module.spi.AntLogger. It contains exactly this content:

org.netbeans.supersilentmode.NewLogger
#-org.apache.tools.ant.module.run.StandardLogger

Now, the standard logger will not be used. Instead, I have my own new logger, in a module called org.netbeans.supersilentmode which now provides the output, which could possibly simply be a happy little tune (or a sad one, for failed builds), as shown yesterday.

Comments:

Suppressing the standard logger is pretty extreme. More realistically you would want to insert a logger before the standard logger which looks for certain unwanted log line patterns, "consumes" the event, and emits nothing (or does something else).

Posted by Jesse Glick on January 23, 2008 at 01:38 AM PST #

Ah. Thanks. I hadn't thought of that. As with many things, the order is important. Thanks!

Posted by Geertjan on January 23, 2008 at 01:47 AM PST #

PS: It's not obvious to me how one inserts a logger before another logger. I thought drag and drop in the ui would be sufficient, but it's not possible.

Posted by Geertjan on January 23, 2008 at 02:13 AM PST #

Like anything in META-INF/services lookup, you can use #position=123 metadata to control ordering. See Lookup API (somewhere).

Posted by Jesse Glick on January 23, 2008 at 02:17 AM PST #

FYI: it is documented in the "Lookup and Service Installation" section of the <a href="http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/doc-files/api.html#service-lookup">Utilities API Javadoc</a>.

Posted by Tom Wheeler on January 23, 2008 at 09:14 AM PST #

OK, it second guessed my HTML. Take two...

FYI: it is documented in the "Lookup and Service Installation" section of the Utilities API Javadoc, which can be found here:

http://bits.netbeans.org/dev/javadoc/org-openide-util/org/openide/util/doc-files/api.html#service-lookup

Posted by Tom Wheeler on January 23, 2008 at 09:15 AM PST #

http://www.versus-odszkodowania.pl/
Odszkodowania

Posted by Odszkodowania on January 29, 2008 at 10:42 PM PST #

Cool, I am looking into the posibility of being able to minify javascript files during the build process for web apps built with netbeans, see enhancement request http://www.netbeans.org/issues/show_bug.cgi?id=134586 , I have no idea how to do this myself, the ant build script might be a good place to start looking though. Thanks for the heads up.

Posted by Neil Hathaway on June 20, 2008 at 08:50 AM PDT #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
12
13
14
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today