Return-Path: Delivered-To: apmail-ant-user-archive@www.apache.org Received: (qmail 36782 invoked from network); 16 Jun 2006 14:50:59 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Jun 2006 14:50:59 -0000 Received: (qmail 20558 invoked by uid 500); 16 Jun 2006 14:50:52 -0000 Delivered-To: apmail-ant-user-archive@ant.apache.org Received: (qmail 20520 invoked by uid 500); 16 Jun 2006 14:50:52 -0000 Mailing-List: contact user-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Users List" Reply-To: "Ant Users List" Delivered-To: mailing list user@ant.apache.org Received: (qmail 20506 invoked by uid 99); 16 Jun 2006 14:50:52 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jun 2006 07:50:52 -0700 X-ASF-Spam-Status: No, hits=0.0 required=10.0 tests= X-Spam-Check-By: apache.org Received-SPF: neutral (asf.osuosl.org: local policy) Received: from [192.6.10.60] (HELO tobor.hpl.hp.com) (192.6.10.60) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Jun 2006 07:50:51 -0700 Received: from localhost (localhost [127.0.0.1]) by tobor.hpl.hp.com (Postfix) with ESMTP id B4F3E370AC for ; Fri, 16 Jun 2006 15:50:29 +0100 (BST) X-Virus-Scanned: amavisd-new at hplb.hpl.hp.com Received: from tobor.hpl.hp.com ([127.0.0.1]) by localhost (tobor.hpl.hp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id mGGaq8KUQP73 for ; Fri, 16 Jun 2006 15:50:24 +0100 (BST) Received: from kropotkin.hpl.hp.com (kropotkin.hpl.hp.com [16.25.191.14]) by tobor.hpl.hp.com (Postfix) with ESMTP id E108F370AA for ; Fri, 16 Jun 2006 15:50:23 +0100 (BST) Received: from localhost (localhost [127.0.0.1]) by kropotkin.hpl.hp.com (Postfix) with ESMTP id C62CDA462 for ; Fri, 16 Jun 2006 15:50:22 +0100 (BST) X-Virus-Scanned: amavisd-new at kropotkin.hpl.hp.com Received: from kropotkin.hpl.hp.com ([127.0.0.1]) by localhost (kropotkin.hpl.hp.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id yoshL9hIG5CK for ; Fri, 16 Jun 2006 15:50:18 +0100 (BST) Received: from timmay.hpl.hp.com (timmay.hpl.hp.com [16.25.171.20]) by kropotkin.hpl.hp.com (Postfix) with ESMTP id 091BC81BD for ; Fri, 16 Jun 2006 15:50:17 +0100 (BST) Received: from [16.25.171.182] (chamonix.hpl.hp.com [16.25.171.182]) by timmay.hpl.hp.com (8.13.2/8.13.2) with ESMTP id k5GEoC1V008035 for ; Fri, 16 Jun 2006 15:50:12 +0100 (BST) Message-ID: <4492C524.3010205@apache.org> Date: Fri, 16 Jun 2006 15:50:12 +0100 From: Steve Loughran User-Agent: Thunderbird 1.5.0.4 (X11/20060516) MIME-Version: 1.0 To: Ant Users List Subject: Re: "Recursiveness" / property already used in a "generic" build... References: <005b01c690d8$80c508d0$0c01a8c0@gilap9300> <255d8d690606160720o43f96efdj699e33c0b6c6738d@mail.gmail.com> In-Reply-To: <255d8d690606160720o43f96efdj699e33c0b6c6738d@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-HPLB-IMAP-MailScanner-Information: Please contact the Helpdesk for more information X-HPLB-IMAP-MailScanner: Found to be clean X-HPLB-IMAP-MailScanner-SpamCheck: not spam, SpamAssassin (score=0, required 5) X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Dominique Devienne wrote: > On 6/15/06, Greg Irvine wrote: >> Well, I managed to sort this out using the task and >> >> to pass only the required properties along. >> >> No more hard-coded folder lists or duplicated build files now! > > Something else I was using, that I need to make public eventually (it > may be in Bugzilla), was a custom Logger to output the build filename > after each target header, to keep track of the build progress thru the > hierarchy of sub-builds, a-la Makefile again. yes, we need this. But I couldnt easily see how to implement it. Are you going to check it in? Also, what is this about > // Return the full target banner (toString() in bugged in JDK 1.4.1) > return _buffer.substring(0); performance? > > In fact, here's the logger. Probably doesn't deal with and > multiple threads properly, but since I was using none of that, it was > good enough for me. --DD > > import java.util.Stack; > > import org.apache.tools.ant.Target; > import org.apache.tools.ant.Project; > import org.apache.tools.ant.BuildEvent; > import org.apache.tools.ant.DefaultLogger; > import org.apache.tools.ant.util.StringUtils; > > /** > * Build logger that allows to make sense of the nesting structure > * generated by the use of <ant> and <subant> in Ant build > files. > *

> * The target banner (the target name followed by a colon, all in its own > line) > * will not be printed until that target's tasks output any kind of message. > * This greatly simplifies the build output for all those targets that do > not > * execute, either because they are prevented to from their 'if' or 'unless' > * attributes, or because all their input files are up-to-date versus their > * output files. > *

> * In addition, the target banner (when output) will be postfixed with the > * project path that lead to its execution, i.e. the list of project names > * that were started using either <ant> and <subant>. Assuming > * one calls the build target of 3 different sub-builds called A, B, and C > * all called from a master build, one could get an output as follows: > *

> * Buildfile: master.xml
> *
> * build:          [@master/A]
> * Compiling 19 source file to /acme/A/classes
> *
> * build:          [@master/B]
> * Compiling 15 source file to /acme/B/classes
> *
> * build:          [@master/C]
> * Compiling 12 source file to /acme/C/classes
> *
> * BUILD SUCCESSFUL
> * Total time: 8 seconds
> * 
> *

> * Inspired from NoBannerLogger by Peter Donald. > */ > public class NoBannerSubBuildLogger > extends DefaultLogger { > > /** The cached current target name, awaiting to be possibly printed. */ > private String _targetName; > > /** The stack of nesting Ant projects. */ > private Stack _projects = new Stack(); > > /** The private buffer of this logger. */ > protected StringBuffer _buffer = new StringBuffer(128); > > /** > * Gets the target banner for a given target name. > * > * @param targetName the target name to get the banner for. > * @return the full target banner name. > */ > protected String getTargetBanner(String targetName) { > _buffer.setLength(0); > > // Target banner as usual > _buffer.append(StringUtils.LINE_SEP); > _buffer.append(targetName); > _buffer.append(':'); > > // Postfix the project path > fillToIndex(_buffer, 16, ' ', 1); > _buffer.append('['); > appendProjectPath(_buffer, '/'); > _buffer.append(']'); > > // Return the full target banner (toString() in bugged in JDK 1.4.1) > return _buffer.substring(0); > } > > /** > * Appends the current project path to a given buffer. > * > * @param buffer the string buffer to append to. > * @param separator the project path separator to use. > */ > protected void appendProjectPath(StringBuffer buffer, char separator) { > final int count = _projects.size(); > for (int i = 0; i < count; ++i) { > Project project = (Project)_projects.get(i); > buffer.append(project.getName()); > buffer.append(separator); > } > if (count > 0) { > buffer.setLength(_buffer.length()-1); > } > } > > /** > * Fills a string buffer with a given character to reach a known length. > * > * @param buffer the string buffer to fill (Cannot be > null). > * @param column the column index to fill up to. > * @param c the char to fill up with. > * @param minLength the mininum number of character to add in case the > * string buffer is already longer than column > * @return the number of characters actually added. > */ > protected static int fillToIndex(StringBuffer buffer, int column, > char c, int minLength) { > final int fillCount = Math.max(column - buffer.length(), minLength); > for (int i = 0; i < fillCount; ++i) { > buffer.append(c); > } > return fillCount; > } > > /** > * Records/caches the target name and its project just started. > * > * @param event the build event to extract the target from. > */ > public void targetStarted(BuildEvent event) { > Target target = event.getTarget(); > _targetName = target.getName(); > _projects.push(target.getProject()); > } > > /** > * Cleans up the record/cache of the target name and its project. > * > * @param event the (ignored here) build event. > */ > public void targetFinished(BuildEvent event) { > _targetName = null; > _projects.pop(); > } > > /** > * Logs a task message, possibly displaying the target and project path > * that led to its execution, if they were not displayed earlier. > * > * @param event the build event containing message information. > * Must not be null. > */ > public void messageLogged(BuildEvent event) { > if (event.getPriority() > msgOutputLevel > || null == event.getMessage() > || (_targetName != null && > "".equals(event.getMessage().trim()))) { > return; > } > > if (_targetName != null) { > out.println(getTargetBanner(_targetName)); > _targetName = null; > } > > super.messageLogged(event); > } > > } > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@ant.apache.org > For additional commands, e-mail: user-help@ant.apache.org > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@ant.apache.org For additional commands, e-mail: user-help@ant.apache.org