Return-Path: Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 52136 invoked from network); 22 Jun 2000 16:08:54 -0000 Received: from oznet15.ozemail.com.au (203.2.192.116) by locus.apache.org with SMTP; 22 Jun 2000 16:08:54 -0000 Received: from cognetnt (1Cust244.tnt3.syd2.da.uu.net [63.12.2.244]) by oznet15.ozemail.com.au (8.9.0/8.6.12) with SMTP id CAA07083 for ; Fri, 23 Jun 2000 02:08:48 +1000 (EST) From: "Conor MacNeill" To: Subject: RE: multiple files with Replace task Date: Fri, 23 Jun 2000 02:07:37 +1000 Message-ID: <001c01bfdc63$fbf147b0$80dc1fcb@cognet.com.au> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_001D_01BFDCB7.CD9D57B0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600 Importance: Normal In-Reply-To: <20000622153103.4621.qmail@web705.mail.yahoo.com> X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_001D_01BFDCB7.CD9D57B0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Todd, Charles Tewksbury posted a task for this (which I have attached below). I'll try to have a look at committing it this weekend. Charles' posting is copied below: Conor > -----Original Message----- > From: Charles Tewksbury [mailto:tewks@adhesive.com] > Sent: Wednesday, 17 May 2000 2:32 > To: ant-dev@jakarta.apache.org > Subject: ReplaceMultiple Task > > > Greetings, > > I have included a new taskdef for replacing a string in all files in a > directory and subdirectories. It is generally based on the Replace task. > > Usage: > basedir="${some.dir}" > token="lookForTerm" > value="replaceWithTerm" > /> > > It actually extends MatchingTask vice Task and the default.properties file > would be modified by adding: > replacemultiple=org.apache.tools.ant.taskdefs.ReplaceMultiple > > Being relatively new to ANT, I'm not sure if this taskdef has already been > built and is awaiting inclusion but since I can't find one in the > repository, I am sending this out for review. > > - Charles W. Tewksbury > > > > -----Original Message----- > From: Todd McGrath [mailto:toddmcgrath@yahoo.com] > Sent: Friday, 23 June 2000 1:31 > To: ant-dev@jakarta.apache.org > Subject: multiple files with Replace task > > > Hi everybody- > > I need replace multiple strings in *multiple* .java > files, but unable to use the Replace task. It seems > as if I need to specify each individual file and > cannot work on a directory tree of files? > > Has anyone else ran into this? > > Any thoughts? > > (I don't think KeySubst task will work, because file > name needs ot remain the same) > > I'll be happy to try to write a new task for this type > of functionality, but wanted to check with the list > first. > > -Todd > > __________________________________________________ > Do You Yahoo!? > Send instant messages with Yahoo! Messenger. > http://im.yahoo.com/ > ------=_NextPart_000_001D_01BFDCB7.CD9D57B0 Content-Type: application/octet-stream; name="ReplaceMultiple.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="ReplaceMultiple.java" /* * The Apache Software License, Version 1.1 * * Copyright (c) 1999 The Apache Software Foundation. All rights=20 * reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer.=20 * * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in * the documentation and/or other materials provided with the * distribution. * * 3. The end-user documentation included with the redistribution, if * any, must include the following acknowlegement: =20 * "This product includes software developed by the=20 * Apache Software Foundation (http://www.apache.org/)." * Alternately, this acknowlegement may appear in the software = itself, * if and wherever such third-party acknowlegements normally appear. * * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software * Foundation" must not be used to endorse or promote products = derived * from this software without prior written permission. For written=20 * permission, please contact apache@apache.org. * * 5. Products derived from this software may not be called "Apache" * nor may "Apache" appear in their names without prior written * permission of the Apache Group. * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D * * This software consists of voluntary contributions made by many * individuals on behalf of the Apache Software Foundation. For more * information on the Apache Software Foundation, please see * . */ package org.apache.tools.ant.taskdefs; import org.apache.tools.ant.*; import java.io.*; import java.util.*; /** * Replaces all the occurrences of the given string token with the given * string value of the files within the directory paths. * * @author Charles Tewksbury tewks@adhesive.com */ public class ReplaceMultiple extends MatchingTask { =20 private String token =3D null; private String value =3D ""; private File baseDir =3D null; =20 /** * Do the execution. */ public void execute() throws BuildException { =20 project.log("Replacing " + token + " --> " + value); if (baseDir =3D=3D null) { throw new BuildException("basedir attribute must be set!"); } if (!baseDir.exists()) { throw new BuildException("basedir does not exist!"); } DirectoryScanner ds =3D super.getDirectoryScanner(baseDir); String[] srcs =3D ds.getIncludedFiles(); if (srcs =3D=3D null || token =3D=3D null ) { project.log("File and token must not be null"); return; =20 } =20 try { for(int i=3D0; i -1) { buffer.append(orig.substring(start, end)); buffer.append(value); start =3D end + token.length(); } =20 buffer.append(orig.substring(start)); =20 return buffer.toString(); =20 } } ------=_NextPart_000_001D_01BFDCB7.CD9D57B0--