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 25768 invoked from network); 4 Sep 2000 06:00:17 -0000 Received: from blockhead1.mincom.com (HELO blockhead.mincom.com) (203.55.175.45) by locus.apache.org with SMTP; 4 Sep 2000 06:00:17 -0000 Received: (from uucp@localhost) by blockhead.mincom.com (8.9.3/8.9.3) id QAA58205 for ; Mon, 4 Sep 2000 16:00:15 +1000 (EST) (envelope-from williamf@mincom.com) Received: from porthole.mincom.oz.au(172.17.100.2) via SMTP by blockhead.mincom.oz.au, id smtpdd58199; Mon Sep 4 16:00:10 2000 Received: from cassini.mincom.oz.au (cassini.mincom.oz.au [172.17.65.67]) by porthole.mincom.oz.au (8.9.3/8.9.3/mincom) with ESMTP id QAA32385 for ; Mon, 4 Sep 2000 16:00:09 +1000 (EST) (envelope-from williamf@mincom.com) Received: from williamf ([172.17.118.164]) by cassini.mincom.oz.au (8.9.3/8.8.2) with SMTP id QAA20195 for ; Mon, 4 Sep 2000 16:00:05 +1000 (EST) From: "William Ferguson" To: Subject: [New Task] - UpToDate Date: Mon, 4 Sep 2000 16:01:46 +1000 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0006_01C01689.6D5806F0" X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) In-Reply-To: Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300 X-Spam-Rating: locus.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------=_NextPart_000_0006_01C01689.6D5806F0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit I thought people might find this useful. It's a task that sets a property when a targetFile is more upToDate than a list of source files. William Ferguson This transmission is for the intended addressee only and is confidential information. If you have received this transmission in error, please delete it and notify the sender. The contents of this E-mail are the opinion of the writer only and are not endorsed by Mincom Limited unless expressly stated otherwise. ------=_NextPart_000_0006_01C01689.6D5806F0 Content-Type: application/octet-stream; name="UpToDate.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="UpToDate.java" /*=0A= * The Apache Software License, Version 1.1=0A= *=0A= * Copyright (c) 1999 The Apache Software Foundation. All rights=0A= * reserved.=0A= *=0A= * Redistribution and use in source and binary forms, with or without=0A= * modification, are permitted provided that the following conditions=0A= * are met:=0A= *=0A= * 1. Redistributions of source code must retain the above copyright=0A= * notice, this list of conditions and the following disclaimer.=0A= *=0A= * 2. Redistributions in binary form must reproduce the above copyright=0A= * notice, this list of conditions and the following disclaimer in=0A= * the documentation and/or other materials provided with the=0A= * distribution.=0A= *=0A= * 3. The end-user documentation included with the redistribution, if=0A= * any, must include the following acknowlegement:=0A= * "This product includes software developed by the=0A= * Apache Software Foundation (http://www.apache.org/)."=0A= * Alternately, this acknowlegement may appear in the software itself,=0A= * if and wherever such third-party acknowlegements normally appear.=0A= *=0A= * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software=0A= * Foundation" must not be used to endorse or promote products derived=0A= * from this software without prior written permission. For written=0A= * permission, please contact apache@apache.org.=0A= *=0A= * 5. Products derived from this software may not be called "Apache"=0A= * nor may "Apache" appear in their names without prior written=0A= * permission of the Apache Group.=0A= *=0A= * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED=0A= * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES=0A= * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE=0A= * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR=0A= * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=0A= * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=0A= * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF=0A= * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND=0A= * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,=0A= * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT=0A= * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF=0A= * SUCH DAMAGE.=0A= * = =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=0A= *=0A= * This software consists of voluntary contributions made by many=0A= * individuals on behalf of the Apache Software Foundation. For more=0A= * information on the Apache Software Foundation, please see=0A= * .=0A= */=0A= =0A= package org.apache.tools.ant.taskdefs;=0A= =0A= import org.apache.tools.ant.*;=0A= import java.io.*;=0A= import java.util.*;=0A= =0A= /**=0A= * Will set the given property if the specified target has a timestamp = greater=0A= * than all of the source files.=0A= *=0A= * @author William Ferguson williamf@mincom.com=0A= */=0A= =0A= public class UpToDate extends Task {=0A= =0A= private String _property;=0A= private String _targetFileName;=0A= private String _sourceFileNames;=0A= =0A= /**=0A= * The property to set if the target file is more up to date than = each of=0A= * the source files.=0A= */=0A= public void setProperty(String property) {=0A= _property =3D property;=0A= }=0A= =0A= /**=0A= * The file which must be more up to date than each of the source = files=0A= * if the property is to be set.=0A= */=0A= public void setTargetFileName(String filename) {=0A= _targetFileName =3D filename;=0A= }=0A= =0A= /**=0A= * Comma separated list of files for which the target file must have = a more=0A= * recent timestamp if the property is to be set.=0A= */=0A= public void setSourceFileNames(String filenames) {=0A= _sourceFileNames =3D filenames;=0A= }=0A= =0A= =0A= /**=0A= * Sets property to true if target file has a more recent timestamp = than=0A= * each of the source files.=0A= */=0A= public void init() throws BuildException {=0A= =0A= // get file for target file name=0A= File targetFile =3D new File(_targetFileName);=0A= if (!targetFile.exists()) return; // if not there then it can't = be up to date=0A= =0A= // get collection of source files=0A= Set sourcefiles =3D getFiles(_sourceFileNames);=0A= Iterator iterator =3D sourcefiles.iterator();=0A= =0A= while(iterator.hasNext()) {=0A= File sourceFile =3D (File) iterator.next();=0A= if (sourceFile.lastModified() > targetFile.lastModified()) = return; // sourceFile is more recent - so targtet is not up to date=0A= }=0A= =0A= this.project.setProperty(_property, "true");=0A= }=0A= =0A= /**=0A= * tokenizes filenames and returns a collection of file retrieved = from=0A= * the tokens.=0A= */=0A= private Set getFiles(String filenames) {=0A= Set files =3D new HashSet();=0A= StringTokenizer tokenizer =3D new StringTokenizer(filenames, ",");=0A= while (tokenizer.hasMoreTokens()) {=0A= File file =3D new File(tokenizer.nextToken());=0A= if (file.exists()) {=0A= files.add(file);=0A= }=0A= }=0A= return files;=0A= }=0A= }=0A= ------=_NextPart_000_0006_01C01689.6D5806F0--