Return-Path: Delivered-To: apmail-ant-dev-archive@www.apache.org Received: (qmail 8533 invoked from network); 3 May 2010 20:59:44 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 May 2010 20:59:44 -0000 Received: (qmail 12548 invoked by uid 500); 3 May 2010 20:59:44 -0000 Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 12354 invoked by uid 500); 3 May 2010 20:59:43 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 12346 invoked by uid 99); 3 May 2010 20:59:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 May 2010 20:59:43 +0000 X-ASF-Spam-Status: No, hits=-0.8 required=10.0 tests=AWL,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of antoine@gmx.de designates 213.165.64.20 as permitted sender) Received: from [213.165.64.20] (HELO mail.gmx.net) (213.165.64.20) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 03 May 2010 20:59:35 +0000 Received: (qmail 17105 invoked by uid 0); 3 May 2010 20:59:08 -0000 Received: from 38.100.172.138 by www174.gmx.net with HTTP; Mon, 03 May 2010 22:59:06 +0200 (CEST) Content-Type: text/plain; charset="iso-8859-1" Date: Mon, 03 May 2010 22:59:06 +0200 From: "Antoine Levy-Lambert" In-Reply-To: Message-ID: <20100503205906.110130@gmx.net> MIME-Version: 1.0 References: Subject: Re: Fwd: loop replace mapper To: "Ant Developers List" X-Authenticated: #22961642 X-Flags: 0001 X-Mailer: WWW-Mail 6100 (Global Message Exchange) X-Priority: 3 X-Provags-ID: V01U2FsdGVkX19449RYQZ94G6TF7uaqoubzzixKUGdonWKO5CdsUm idcBzy0vVeRFck+ehcfIKcYV87haZ+WCPFtw== Content-Transfer-Encoding: 8bit X-GMX-UID: KEPqI25BZDIrFIRuJGc2+I55emhmY0EK X-FuHaFi: 0.55000000000000004 Hello Patrick, it is likely that it is too late for ant 1.8.1, unless the build of Friday does not pass the vote. The other questions are ? What is the use case for this mapper ? Is it generic enough to be added to ant ? If it interesting we would need also patches of documentation and unit tests. Regards, Antoine -------- Original-Nachricht -------- > Datum: Sat, 1 May 2010 15:31:20 +0200 > Von: Patrick Martin > An: Ant Dev > Betreff: Fwd: loop replace mapper > I guess I should have posted this mail on ant dev mailing list. > Is this request too late for ant 1.8.1 ? > > > ---------- Forwarded message ---------- > From: Patrick Martin > Date: Sat, May 1, 2010 at 3:17 PM > Subject: loop replace mapper > To: Ant User > > > Hello, > > I wrote a small mapper which loops on a string list and replaces a > token in the input file name. > it can be used (since ant 1.8.1) like this: > � � � � � � � � enablemultiplemappings="true"> > � � � � � � � � � � � � includes="**" /> > � � � � � � � � � � � � list="dir1,dir2" /> > � � � � � � � � > � � � � � � � � > � � � � � � � � � � � � enablemultiplemappings="true"> > � � � � � � � � � � � � � � � � dir="test/data/srcdir" includes="**" /> > � � � � � � � � � � � � � � � � token="@dirname@" > list="dir1,dir2" /> > � � � � � � � � � � � � > � � � � � � � > > Would this fit in the next standard ant version ? > > Here is the source code: > > public class LoopReplaceMapper implements FileNameMapper { > � � � �private String token; > � � � �private ArrayList list; > > � � � �public void setToken(String token) { > � � � � � � � �this.token = token; > � � � �} > > � � � �public String getToken() { > � � � � � � � �return token; > � � � �} > > � � � �public void setList(String _list) { > � � � � � � � �StringTokenizer st = new StringTokenizer(_list, " > � � � , "); > � � � � � � � �this.list = new > ArrayList(st.countTokens()); > � � � � � � � �while (st.hasMoreTokens()) { > � � � � � � � � � � � �list.add(st.nextToken()); > � � � � � � � �} > � � � �} > > � � � �public String getList() { > � � � � � � � �return list.toString(); > � � � �} > > � � � �public String[] mapFileName(String sourceFileName) { > � � � � � � � �String[] mappedFileNames = null; > � � � � � � � �if (sourceFileName.contains(getToken())) { > � � � � � � � � � � � �mappedFileNames = new > String[list.size()]; > � � � � � � � � � � � �int index = 0; > � � � � � � � � � � � �for (String replacement : list) { > � � � � � � � � � � � � � � � �mappedFileNames[index++] = > sourceFileName.replace(getToken(), replacement); > � � � � � � � � � � � �} > � � � � � � � �} else { > � � � � � � � � � � � �mappedFileNames = new String[1]; > � � � � � � � � � � � �mappedFileNames[0] = sourceFileName; > � � � � � � � �} > � � � � � � � �return mappedFileNames; > � � � �} > > � � � �public void setFrom(String from) { > � � � �} > > � � � �public void setTo(String to) { > � � � �} > } > > �Rgds, > > Patrick > --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org