java qr code generator library free Build listeners in Java

Maker QR Code ISO/IEC18004 in Java Build listeners

Build listeners
QR Code 2d Barcode Drawer In Java
Using Barcode printer for Java Control to generate, create QR-Code image in Java applications.
QR Decoder In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
Build listeners
Code 128A Creator In Java
Using Barcode printer for Java Control to generate, create Code 128A image in Java applications.
Data Matrix Maker In Java
Using Barcode creator for Java Control to generate, create Data Matrix ECC200 image in Java applications.
Another extension you may wish to make to your Ant environment is to create a custom build listener.
Matrix Creator In Java
Using Barcode creation for Java Control to generate, create Matrix Barcode image in Java applications.
Printing Barcode In Java
Using Barcode drawer for Java Control to generate, create Barcode image in Java applications.
Code 3 Of 9 Maker In Java
Using Barcode generation for Java Control to generate, create Code39 image in Java applications.
Encode Leitcode In Java
Using Barcode encoder for Java Control to generate, create Leitcode image in Java applications.
A listener is a component that registers for callbacks with the Ant system when interesting events occur. Such events include message logging, beginning execution of targets and tasks, and ending the build process.
Recognize QR-Code In None
Using Barcode scanner for Software Control to read, scan read, scan image in Software applications.
QR Code Creator In Java
Using Barcode generator for BIRT reports Control to generate, create QR Code image in BIRT reports applications.
Common tasks for listeners are logging messages and sending notification of build problems to the configuration manager. Let us develop a simple listener to see how this aspect of Ant works.
Data Matrix Generator In .NET
Using Barcode creator for ASP.NET Control to generate, create ECC200 image in ASP.NET applications.
Creating PDF 417 In Visual C#
Using Barcode printer for .NET framework Control to generate, create PDF 417 image in VS .NET applications.
Barcode Scanner In VS .NET
Using Barcode Control SDK for ASP.NET Control to generate, create, read, scan barcode image in ASP.NET applications.
Generate Code 128A In Java
Using Barcode generation for BIRT Control to generate, create Code 128C image in BIRT applications.
Developing the listener
PDF-417 2d Barcode Creator In None
Using Barcode printer for Microsoft Excel Control to generate, create PDF-417 2d barcode image in Excel applications.
Printing Code-128 In Objective-C
Using Barcode encoder for iPad Control to generate, create Code 128B image in iPad applications.
In this example, we develop a build listener that logs all messages produced by Ant during a build. The code for this component is shown in listing C.4. A class acting as a build listener must implement the callback methods of the interface. Our example listener is interested in two events; the messageLogged and buildFinished events.
Matrix 2D Barcode Maker In VB.NET
Using Barcode generation for VS .NET Control to generate, create 2D Barcode image in VS .NET applications.
Read DataMatrix In .NET Framework
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET applications.
Listing C.4 A build listener class
Code-128 Creation In None
Using Barcode maker for Software Control to generate, create Code 128 Code Set A image in Software applications.
Printing Barcode In None
Using Barcode drawer for Software Control to generate, create Barcode image in Software applications.
import*; import java.util.*; import*; public class BuildResultPrinter implements BuildListener {
Implements the
callback interface
private Vector buildMessages = new Vector(); public BuildResultPrinter() { } public void buildStarted(BuildEvent e) { }
Writes all logged messages to a file named
build.results public void buildFinished(BuildEvent event) { Throwable e = event.getException(); String status = (e != null) "failed" : "succeeded"; String message = "Your Ant build process " + status + "."; try { PrintStream ps = new PrintStream( new FileOutputStream("build.results") );
The Ant build tool
ps.println(message); if (buildMessages.size() > 0) { ps.println(); ps.println( "The following messages were logged by Ant:"); ps.println( "------------------------------------------"); ps.println(); for (int i = 0; i < buildMessages.size(); i++) ps.println( (String) buildMessages.get(i) ); } ps.close(); } catch (Exception ex) { ex.printStackTrace(); } Collects messages
public void messageLogged(BuildEvent event) { buildMessages.add( event.getMessage() ); } public void targetStarted(BuildEvent event) { } public void targetFinished(BuildEvent event) { } public void taskStarted(BuildEvent event) { } public void taskFinished(BuildEvent event) { } }
as they occur and caches them
Execute the build.listener task in the example build file to compile and JAR this class and place it in Ant s classpath.
Using the listener
To put our new listener to work, execute the following in your working directory:
prompt> ant listener BuildResultPrinter
You will now find a file named build.results in your working directory, containing all logging messages created by Ant as it evaluated the run target.
We have only scratched the surface of the capabilities and extensibility of Ant. We hope this brief introduction has been sufficient to pique your interest in this build tool. As a Java developer, especially in a team environment, learning about Ant and mastering it would be a valuable use of your time.
Web-based resources mentioned in this book:
Resource topic
Ant, Cactus, Log4j, Struts, Velocity Cocoon, Apache Crimson, Apache FOP , Xalan, Xerces, XSLTC Concurrent Versioning System Enhydra eXtreme Programming (XP) GMD's XQL, PDOM J2EE Blueprints design pattern section Java XML Pack, JAXB, JAXM, JAXR, JAX-RPC JDOM JUnit Mercury Interactive testing tools
Web address
http:/// (continued on next page)
Resource topic
Rational Software, Rational Unified Process (RUP)
Web address
SOAP SOAP specification, SOAP 1.1 with , Attachments specification, XBase, XDoclet, XInclude, XLink, XML Schema, XML Signature recommended standard, XPath, XQuery, XSLT This book UDDI and related technologies WebLogic Webmacro Zvon,
Books you may want to read:
Alur, Deepak, Dan Malks, and John Crupi. Core J2EE Design Patterns. New York: Prentice Hall 2001. Beck, Kent. Extreme Programming Explained. Boston: Addison-Wesley, 2000. Coulouris, George, Jean Dollimore, and Tim Kindberg. Distributed Systems Concepts and Design. London: Addison-Wesley, 2001. John Davies, Rod Johnson, Cedric Buest, Tyler Jewell, Andrew Longshaw, et al. Professional Java Server Programming J2EE 1.3 Edition. Birmingham, UK: Wrox Press Ltd., 2001. Fowler, Martin, and Kendall Scott. UML Distilled. Boston: Addison-Wesley, 2000. Gamma, Erich, Richard Helm, Ralph Johnson, and John Vlissides. Design Patterns. Boston: Addison-Wesley, 1995. Hatcher, Erik, and Steve Loughran. Java Software Development with Ant. Greenwich, CT: Manning Publications, 2002. Husted, Ted. Scaffolding: Developing Web Applications with Struts. Greenwich, CT: Manning Publications, 2002. Kay, Michael. XSLT. Birmingham, UK: Wrox Press Ltd., 2001. Kruchten, Phillippe. The Rational Unified Process: An Introduction. New York: AddisonWesley, 2000. McLaughlin, Brett. Java & XML, 2d ed. Cambridge: O Reilly and Associates, 2001. Mohr, Steven, Jonathan Pinnock, and Brian Loesgen. Professional XML. Birmingham, UK: Wrox Press Ltd., 2000. Mullender, Sape, ed. Distributed Systems. New York: Addison-Wesley, 1998.
Copyright © . All rights reserved.