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.
www.OnBarcode.com
QR Decoder In Java
Using Barcode recognizer for Java Control to read, scan read, scan image in Java applications.
www.OnBarcode.com
Build listeners
Code 128A Creator In Java
Using Barcode printer for Java Control to generate, create Code 128A image in Java applications.
www.OnBarcode.com
Data Matrix Maker In Java
Using Barcode creator for Java Control to generate, create Data Matrix ECC200 image in Java applications.
www.OnBarcode.com
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.
www.OnBarcode.com
Printing Barcode In Java
Using Barcode drawer for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
DEFINITION
Code 3 Of 9 Maker In Java
Using Barcode generation for Java Control to generate, create Code39 image in Java applications.
www.OnBarcode.com
Encode Leitcode In Java
Using Barcode encoder for Java Control to generate, create Leitcode image in Java applications.
www.OnBarcode.com
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.
www.OnBarcode.com
QR Code Creator In Java
Using Barcode generator for BIRT reports Control to generate, create QR Code image in BIRT reports applications.
www.OnBarcode.com
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.
www.OnBarcode.com
Creating PDF 417 In Visual C#
Using Barcode printer for .NET framework Control to generate, create PDF 417 image in VS .NET applications.
www.OnBarcode.com
C.4.1
Barcode Scanner In VS .NET
Using Barcode Control SDK for ASP.NET Control to generate, create, read, scan barcode image in ASP.NET applications.
www.OnBarcode.com
Generate Code 128A In Java
Using Barcode generation for BIRT Control to generate, create Code 128C image in BIRT applications.
www.OnBarcode.com
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.
www.OnBarcode.com
Printing Code-128 In Objective-C
Using Barcode encoder for iPad Control to generate, create Code 128B image in iPad applications.
www.OnBarcode.com
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 org.apache.tools.ant.BuildListener 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.
www.OnBarcode.com
Read DataMatrix In .NET Framework
Using Barcode recognizer for .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
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.
www.OnBarcode.com
Printing Barcode In None
Using Barcode drawer for Software Control to generate, create Barcode image in Software applications.
www.OnBarcode.com
import java.io.*; import java.util.*; import org.apache.tools.ant.*; public class BuildResultPrinter implements BuildListener {
Implements the
BuildListener
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") );
APPENDIX C
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.
C.4.2
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.
Summary
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.
resources
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://jakarta.apache.org. http://xml.apache.org.
http://www.cvshome.org. http://www.enhydra.org http://www.extremeprogramming.org. http://xml.darmstadt.gmd.de/xql/ http://java.sun.com/j2ee/blueprints/design_patterns/ http://java.sun.com/xml.
http:///www.jdom.org http://www.junit.org http://www.mercuryinteractive.com. (continued on next page)
resources
Resource topic
Rational Software, Rational Unified Process (RUP)
Web address
http://www.rational.com
SOAP SOAP specification, SOAP 1.1 with http://www.w3.org. , Attachments specification, XBase, XDoclet, XInclude, XLink, XML Schema, XML Signature recommended standard, XPath, XQuery, XSLT This book UDDI and related technologies WebLogic Webmacro Zvon, http://www.manning.com/gabrick http://www.uddi.org http://www.bea.com http://www.webmacro.org http://www.zvon.org
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 © OnBarcode.com . All rights reserved.