From f0855dc2ad63dc096b1526c258ee77360a9f27ca Mon Sep 17 00:00:00 2001 From: No Author Date: Fri, 30 Jun 2000 22:39:45 +0000 Subject: This commit was manufactured by cvs2svn to create branch 'tomcat_32'. git-svn-id: https://svn.apache.org/repos/asf/ant/core/branches/tomcat_32@267721 13f79535-47bb-0310-9956-ffa450edef68 --- LICENSE | 48 - README | 68 - TODO | 42 - bootstrap.bat | 67 - bootstrap.sh | 31 - build.bat | 19 - build.sh | 24 - build.xml | 206 -- buildAnt | 33 - buildAnt.xml | 84 - docs/index.html | 3327 -------------------- spec/core.html | 278 -- src/bin/ant | 52 - src/bin/ant.bat | 33 - src/bin/antRun | 13 - src/etc/ant.spec | 52 - src/etc/log.xsl | 57 - src/etc/manifest | 4 - src/etc/pkginfo | 9 - src/etc/prototype | 12 - src/main/org/apache/tools/ant/BuildEvent.java | 153 - src/main/org/apache/tools/ant/BuildException.java | 155 - src/main/org/apache/tools/ant/BuildListener.java | 119 - src/main/org/apache/tools/ant/DefaultLogger.java | 111 - src/main/org/apache/tools/ant/DesirableFilter.java | 118 - .../org/apache/tools/ant/DirectoryScanner.java | 827 ----- src/main/org/apache/tools/ant/Location.java | 111 - src/main/org/apache/tools/ant/Main.java | 367 --- src/main/org/apache/tools/ant/Map.java | 62 - src/main/org/apache/tools/ant/PathTokenizer.java | 122 - src/main/org/apache/tools/ant/Project.java | 905 ------ src/main/org/apache/tools/ant/ProjectHelper.java | 523 --- src/main/org/apache/tools/ant/Target.java | 142 - src/main/org/apache/tools/ant/Task.java | 128 - src/main/org/apache/tools/ant/TaskAdapter.java | 102 - src/main/org/apache/tools/ant/XmlLogger.java | 269 -- src/main/org/apache/tools/ant/defaultManifest.mf | 1 - src/main/org/apache/tools/ant/taskdefs/Ant.java | 171 - .../org/apache/tools/ant/taskdefs/Available.java | 128 - src/main/org/apache/tools/ant/taskdefs/Chmod.java | 92 - .../org/apache/tools/ant/taskdefs/CompileTask.java | 112 - .../org/apache/tools/ant/taskdefs/Copydir.java | 137 - .../org/apache/tools/ant/taskdefs/Copyfile.java | 97 - src/main/org/apache/tools/ant/taskdefs/Cvs.java | 153 - src/main/org/apache/tools/ant/taskdefs/Delete.java | 158 - .../org/apache/tools/ant/taskdefs/Deltree.java | 122 - src/main/org/apache/tools/ant/taskdefs/Echo.java | 85 - src/main/org/apache/tools/ant/taskdefs/Exec.java | 213 -- src/main/org/apache/tools/ant/taskdefs/Expand.java | 145 - src/main/org/apache/tools/ant/taskdefs/Filter.java | 81 - .../org/apache/tools/ant/taskdefs/FixCRLF.java | 362 --- src/main/org/apache/tools/ant/taskdefs/GUnzip.java | 132 - src/main/org/apache/tools/ant/taskdefs/GZip.java | 120 - src/main/org/apache/tools/ant/taskdefs/Get.java | 157 - src/main/org/apache/tools/ant/taskdefs/Jar.java | 123 - src/main/org/apache/tools/ant/taskdefs/Java.java | 214 -- src/main/org/apache/tools/ant/taskdefs/Javac.java | 699 ---- .../tools/ant/taskdefs/JavacOutputStream.java | 125 - .../org/apache/tools/ant/taskdefs/Javadoc.java | 800 ----- src/main/org/apache/tools/ant/taskdefs/Jikes.java | 47 - .../tools/ant/taskdefs/JikesOutputParser.java | 103 - .../org/apache/tools/ant/taskdefs/KeySubst.java | 203 -- .../apache/tools/ant/taskdefs/MatchingTask.java | 310 -- src/main/org/apache/tools/ant/taskdefs/Mkdir.java | 87 - src/main/org/apache/tools/ant/taskdefs/Patch.java | 161 - .../org/apache/tools/ant/taskdefs/Property.java | 182 -- src/main/org/apache/tools/ant/taskdefs/Rename.java | 116 - .../org/apache/tools/ant/taskdefs/Replace.java | 190 -- src/main/org/apache/tools/ant/taskdefs/Rmic.java | 244 -- src/main/org/apache/tools/ant/taskdefs/Tar.java | 139 - .../org/apache/tools/ant/taskdefs/Taskdef.java | 111 - src/main/org/apache/tools/ant/taskdefs/Touch.java | 198 -- src/main/org/apache/tools/ant/taskdefs/Tstamp.java | 86 - src/main/org/apache/tools/ant/taskdefs/Untar.java | 159 - .../org/apache/tools/ant/taskdefs/XSLTLiaison.java | 70 - .../org/apache/tools/ant/taskdefs/XSLTProcess.java | 314 -- src/main/org/apache/tools/ant/taskdefs/Zip.java | 230 -- .../apache/tools/ant/taskdefs/defaults.properties | 44 - .../tools/ant/taskdefs/optional/NetRexxC.java | 657 ---- .../ant/taskdefs/optional/RenameExtensions.java | 163 - .../apache/tools/ant/taskdefs/optional/Script.java | 160 - .../tools/ant/taskdefs/optional/XalanLiaison.java | 87 - .../tools/ant/taskdefs/optional/XslpLiaison.java | 88 - src/main/org/apache/tools/ant/version.txt | 2 - src/main/org/apache/tools/tar/TarBuffer.java | 440 --- src/main/org/apache/tools/tar/TarConstants.java | 182 -- src/main/org/apache/tools/tar/TarEntry.java | 572 ---- src/main/org/apache/tools/tar/TarInputStream.java | 419 --- src/main/org/apache/tools/tar/TarOutputStream.java | 314 -- src/main/org/apache/tools/tar/TarUtils.java | 234 -- 90 files changed, 19412 deletions(-) delete mode 100644 LICENSE delete mode 100644 README delete mode 100644 TODO delete mode 100755 bootstrap.bat delete mode 100755 bootstrap.sh delete mode 100755 build.bat delete mode 100755 build.sh delete mode 100644 build.xml delete mode 100755 buildAnt delete mode 100644 buildAnt.xml delete mode 100644 docs/index.html delete mode 100644 spec/core.html delete mode 100644 src/bin/ant delete mode 100755 src/bin/ant.bat delete mode 100644 src/bin/antRun delete mode 100644 src/etc/ant.spec delete mode 100644 src/etc/log.xsl delete mode 100644 src/etc/manifest delete mode 100644 src/etc/pkginfo delete mode 100644 src/etc/prototype delete mode 100644 src/main/org/apache/tools/ant/BuildEvent.java delete mode 100644 src/main/org/apache/tools/ant/BuildException.java delete mode 100644 src/main/org/apache/tools/ant/BuildListener.java delete mode 100644 src/main/org/apache/tools/ant/DefaultLogger.java delete mode 100644 src/main/org/apache/tools/ant/DesirableFilter.java delete mode 100644 src/main/org/apache/tools/ant/DirectoryScanner.java delete mode 100644 src/main/org/apache/tools/ant/Location.java delete mode 100644 src/main/org/apache/tools/ant/Main.java delete mode 100644 src/main/org/apache/tools/ant/Map.java delete mode 100644 src/main/org/apache/tools/ant/PathTokenizer.java delete mode 100644 src/main/org/apache/tools/ant/Project.java delete mode 100644 src/main/org/apache/tools/ant/ProjectHelper.java delete mode 100644 src/main/org/apache/tools/ant/Target.java delete mode 100644 src/main/org/apache/tools/ant/Task.java delete mode 100644 src/main/org/apache/tools/ant/TaskAdapter.java delete mode 100644 src/main/org/apache/tools/ant/XmlLogger.java delete mode 100644 src/main/org/apache/tools/ant/defaultManifest.mf delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Ant.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Available.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Chmod.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/CompileTask.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Copydir.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Copyfile.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Cvs.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Delete.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Deltree.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Echo.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Exec.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Expand.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Filter.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/FixCRLF.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/GUnzip.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/GZip.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Get.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Jar.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Java.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Javac.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Javadoc.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Jikes.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/KeySubst.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/MatchingTask.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Mkdir.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Patch.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Property.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Rename.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Replace.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Rmic.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Tar.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Taskdef.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Touch.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Tstamp.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Untar.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/Zip.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/defaults.properties delete mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/Script.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java delete mode 100644 src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java delete mode 100644 src/main/org/apache/tools/ant/version.txt delete mode 100644 src/main/org/apache/tools/tar/TarBuffer.java delete mode 100644 src/main/org/apache/tools/tar/TarConstants.java delete mode 100644 src/main/org/apache/tools/tar/TarEntry.java delete mode 100644 src/main/org/apache/tools/tar/TarInputStream.java delete mode 100644 src/main/org/apache/tools/tar/TarOutputStream.java delete mode 100644 src/main/org/apache/tools/tar/TarUtils.java diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 032be1484..000000000 --- a/LICENSE +++ /dev/null @@ -1,48 +0,0 @@ -/* - * ============================================================================ - * The Apache Software License, Version 1.1 - * ============================================================================ - * - * Copyright (C) 1999 The Apache Software Foundation. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without modifica- - * tion, 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. - * - * 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 acknowledgment: "This product includes software - * developed by the Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowledgment may appear in the software itself, if - * and wherever such third-party acknowledgments normally appear. - * - * 4. The names "Ant" and "Apache Software Foundation" must not be used to - * endorse or promote products derived from this software without prior - * written permission. For written permission, please contact - * apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache", nor may - * "Apache" appear in their name, without prior written permission of the - * Apache Software Foundation. - * - * 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 (INCLU- - * DING, 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. - * - * 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 . - * - */ diff --git a/README b/README deleted file mode 100644 index 857a2e2f0..000000000 --- a/README +++ /dev/null @@ -1,68 +0,0 @@ - - A N T - - - What is it? - ----------- - - Ant is a Java based build tool. In theory it is kind of like "make" - without makes wrinkles and with the full portability of pure java code. - - - Why? - ---- - - Why another build tool when there is already make, gnumake, nmake, jam, - and others? Because all of those tools have limitations that its original - author couldn't live with when developing software across multiple platforms. - - Make-like tools are inherently shell based. They evaluate a set of - dependencies and then execute commands not unlike what you would issue on a - shell. This means that you can easily extend these tools by using or writing - any program for the OS that you are working on. However, this also means that - you limit yourself to the OS, or at least the OS type such as Unix, that you - are working on. - - Makefiles are inherently evil as well. Anybody who has worked on them for any - time has run into the dreaded tab problem. "Is my command not executing - because I have a space in front of my tab!!!" said the original author of Ant - way too many times. Tools like Jam took care of this to a great degree, but - still use yet another format to use and remember. - - Ant is different. Instead a model where it is extended with shell based - commands, it is extended using Java classes. Instead of writing shell - commands, the configuration files are XML based calling out a target tree - where various tasks get executed. Each task is run by an object which - implements a particular Task interface. - - Granted, this removes some of the expressive power that is inherent by being - able to construct a shell command such as `find . -name foo -exec rm {}` but - it gives you the ability to be cross platform. To work anywhere and - everywhere. And hey, if you really need to execute a shell command, Ant has - an exec rule that allows different commands to be executed based on the OS - that it is executing on. - - The Latest Version - ------------------ - - Details of the latest version can be found on the Apache Jakarta - Project web site . - - - Documentation - ------------- - - Documentation is available in HTML format, in the docs/ directory. - - - Licensing - --------- - - This software is licensed under the terms you may find in the file - named "LICENSE" in this directory. - - - Thanks for using Ant. - - The Apache Jakarta Project - diff --git a/TODO b/TODO deleted file mode 100644 index 70bd65fb7..000000000 --- a/TODO +++ /dev/null @@ -1,42 +0,0 @@ -TODO List: - - * write a target rule that reacts on class presence or more generally, a way - to apply environment conditions that must be met in order for a target to - be executed. This is _vital_ for highly componentized systems where - non-core parts of the software may be skipped if the required classes - are not present in the build classpath. - - * Improve error reporting on BuildException catches. Error should - state which task and which target was active at the time the - BuildException was popped. - - * Improve error reporting on XML parse. Currently if the build.xml - file is malformed we get some sort of odd SAX exception that could - be better put. - - * Provide an AbstractFileCompareTask class with prebuilt "srcfile" - and "destfile" setter methods and whose execute method calls a - "updateNeeded" method. - - * Transform task -- XSLT - - * Output logs in XML -- this would be a global option of the project - (log location, verboseness, etc) - - * Javac improvements -- support the "modern" 1.3 compiler - - * Investigate some sort of command line "execute an instance of a - task with these parameters" entry point. Maybe a - `org.apache.ant.TaskMain task org.foo.BarTask attrib1=foo - attrib2=bar` type entry point? - - * Investigate some sort of "touch" functionality. Not sure how this - could be done in a portable way -- maybe append 0 bytes to a file - as a quick hack? - - * GUI front end -- examine tasks, add task properties, etc. Also, - one button push build of a particular target. - - * Test harness. All software projects should have an automatable - test suite. Ant is no exception to this rule. - diff --git a/bootstrap.bat b/bootstrap.bat deleted file mode 100755 index 8b7b6aa57..000000000 --- a/bootstrap.bat +++ /dev/null @@ -1,67 +0,0 @@ -@echo off - -REM You will need to specify JAVA_HOME if compiling with 1.2 or later. - -set OLDJAVA=%JAVA% -set OLDJAVAC=%JAVAC% -set OLDCLASSPATH=%CLASSPATH% - -if exist ..\antrc.bat call ..\antrc.bat - -if "" == "%JAVA%" if "" == "%JAVA_HOME%" set JAVA=java -if "" == "%JAVA%" set JAVA=%JAVA_HOME%\bin\java - -if "" == "%JAVAC%" if "" == "%JAVA_HOME%" set JAVAC=javac -if "" == "%JAVAC%" set JAVAC=%JAVA_HOME%\bin\javac - -echo. -echo ... Bootstrapping Ant Distribution - -set CLASSPATH=src\main;classes;%CLASSPATH% -if exist %JAVA_HOME%\lib\tools.jar set CLASSPATH=%CLASSPATH%;%JAVA_HOME%\lib\tools.jar - -echo JAVA_HOME=%JAVA_HOME% -echo JAVA=%JAVA% -echo JAVAC=%JAVAC% -echo CLASSPATH=%CLASSPATH% - -if "%OS%" == "Windows_NT" if exist classes\nul rmdir/s/q classes -if not "%OS%" == "Windows_NT" if exist classes\nul deltree/y classes -mkdir classes - -set TOOLS=src\main\org\apache\tools - -echo. -echo ... Compiling Ant Classes - -%JAVAC% -d classes %TOOLS%\tar\*.java %TOOLS%\ant\*.java %TOOLS%\ant\taskdefs\*.java - -echo. -echo ... Copying Required Files - -copy %TOOLS%\ant\taskdefs\*.properties classes\org\apache\tools\ant\taskdefs - -echo. -echo ... Building Ant Distribution - -%JAVA% org.apache.tools.ant.Main clean main %1 %2 %3 %4 %5 - -echo. -echo ... Cleaning Up Build Directories - -%JAVA% org.apache.tools.ant.Main clean %1 %2 %3 %4 %5 - -if "%OS%" == "Windows_NT" if exist classes\nul rmdir/s/q classes -if not "%OS%" == "Windows_NT" if exist classes\nul deltree/y classes - -echo. -echo ... Done Bootstrapping Ant Distribution - -set JAVA=%OLDJAVA% -set JAVAC=%OLDJAVAC% -set CLASSPATH=%OLDCLASSPATH% -set OLDJAVA= -set OLDJAVAC= -set OLDCLASSPATH= -set TOOLS= - diff --git a/bootstrap.sh b/bootstrap.sh deleted file mode 100755 index e3fcfe97f..000000000 --- a/bootstrap.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh - -if [ -f $HOME/.antrc ] ; then - . $HOME/.antrc -fi - -SRCDIR=src/main/org/apache/tools -CLASSDIR=classes -CLASSPATH=${CLASSPATH}:${JAVA_HOME}/lib/classes.zip:${JAVA_HOME}/lib/tools.jar -CLASSPATH=${CLASSPATH}:src/main:${CLASSDIR} - -mkdir -p ${CLASSDIR} - -export CLASSPATH -echo $CLASSPATH - -javac -d ${CLASSDIR} ${SRCDIR}/tar/*.java -javac -d ${CLASSDIR} ${SRCDIR}/ant/*.java -javac -d ${CLASSDIR} ${SRCDIR}/ant/taskdefs/*.java - -cp src/main/org/apache/tools/ant/taskdefs/defaults.properties ${CLASSDIR}/org/apache/tools/ant/taskdefs - -java org.apache.tools.ant.Main clean main -java org.apache.tools.ant.Main clean - -if test ! -d bin; then mkdir bin; fi -cp src/bin/antRun bin -chmod +x bin/antRun - -rm -rf ${CLASSDIR} - diff --git a/build.bat b/build.bat deleted file mode 100755 index 4b04de917..000000000 --- a/build.bat +++ /dev/null @@ -1,19 +0,0 @@ -@echo off - -set _ANTHOME=%ANT_HOME% -if "%ANT_HOME%" == "" set ANT_HOME=. - -set LOCALCLASSPATH=%CLASSPATH% -for %%i in (%ANT_HOME%\lib\*.jar) do call lcp.bat %%i -if exist %JAVA_HOME%\lib\tools.jar call lcp.bat %JAVA_HOME%\lib\tools.jar - -echo. -echo Building with classpath: %LOCALCLASSPATH% -echo. - -java -Dant.home="%ANT_HOME%" -classpath "%LOCALCLASSPATH%" %ANT_OPTS% org.apache.tools.ant.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 - -rem clean up -set LOCALCLASSPATH= -set ANT_HOME=%_ANTHOME% -set _ANTHOME= diff --git a/build.sh b/build.sh deleted file mode 100755 index 462c2b5de..000000000 --- a/build.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -if [ "$ANT_HOME" = "" ] ; then - ANT_HOME=`pwd` -fi -export ANT_HOME - -LOCALCLASSPATH=`echo $ANT_HOME/lib/*.jar | tr ' ' ':'` - -if [ "$CLASSPATH" != "" ] ; then - LOCALCLASSPATH=$CLASSPATH:$LOCALCLASSPATH -fi - -if test -f $JAVA_HOME/lib/tools.jar ; then - LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar -fi - -echo -echo Building with classpath: $LOCALCLASSPATH -echo - -chmod 0755 $ANT_HOME/bin/antRun - -java -Dant.home=$ANT_HOME -classpath $LOCALCLASSPATH $ANT_OPTS org.apache.tools.ant.Main $* diff --git a/build.xml b/build.xml deleted file mode 100644 index 345044bf7..000000000 --- a/build.xml +++ /dev/null @@ -1,206 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/buildAnt b/buildAnt deleted file mode 100755 index 28967d37f..000000000 --- a/buildAnt +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/bash -# ----------------------------------------------------------------------------- -# buildAnt -- Build Nightly Distribution Files for ANT -# -# Goals: -# - Create nightly distribution files of Ant, including the JAXP reference -# implementation JAR files (so no extra downloads are needed), in the usual -# formats -# - Optionally, install these distribution files on the Jakarta web server -# -# Prerequisites: -# - The user under which this script runs must have done a CVS "login" -# for anonymous access to the Jakarta repositories -# - Java Development Kit, version 1.2.2, installed and configured -# (avoids compiler problems in 1.1 and 1.3 related to XML classes) -# - Ant 3.1 binary distribution installed -# - ANT_HOME points at this distribution directory (you can set it -# in ~/.antrc) -# - The "ant" script in $ANT_HOME/bin is accessible on your PATH -# - Java API for XML Parsing (JAXP) 1.0 reference implementation installed -# - JAXP_HOME points at this distribution directory (you can set it -# in ~/.antrc) -# - The "buildAnt.xml" script (from the Ant source repository) is -# in the same directory that this script is. -# - To execute the "install" target, you must be running on the Jakarta -# server, as part of group "jakarta". -# -# Author: Craig R. McClanahan -# Version: $Revision$ $Date$ -# ----------------------------------------------------------------------------- - -. ~/.antrc -ant -buildfile buildAnt.xml -Djaxp.home=$JAXP_HOME "$@" diff --git a/buildAnt.xml b/buildAnt.xml deleted file mode 100644 index f85ec6cda..000000000 --- a/buildAnt.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index b735cd9e5..000000000 --- a/docs/index.html +++ /dev/null @@ -1,3327 +0,0 @@ - - - - -Ant - - - - -

Ant User Manual

-

by

- - - -

Version 1.0.8.1 - 2000/06/28

- -
-

Table of Contents

- - -
-

Introduction

-

Ant is a Java based build tool. In theory it is kind of like make without -make's wrinkles.

-

Why?

-

Why another build tool when there is already make, gnumake, nmake, jam, and -others? Because all of those tools have limitations that its original author -couldn't live with when developing software across multiple platforms. Make like -tools are inherently shell based. They evaluate a set of dependencies and then -execute commands not unlike what you would issue on a shell. This means that you -can easily extend these tools by using or writing any program for the OS that -you are working on. However, this also means that you limit yourself to the OS, -or at least the OS type such as Unix, that you are working on.

-

Makefiles are inherently evil as well. Anybody who has worked on them for any -time has run into the dreaded tab problem. "Is my command not executing -because I have a space in front of my tab!!!" said the original author of -Ant way too many times. Tools like Jam took care of this to a great degree, but -still use yet another format to use and remember.

-

Ant is different. Instead a model where it is extended with shell based -commands, it is extended using Java classes. Instead of writing shell commands, -the configuration files are XML based calling out a target tree where various -tasks get executed. Each task is run by an object which implements a particular -Task interface.

-

Granted, this removes some of the expressive power that is inherent by being -able to construct a shell command such as `find . -name foo -exec rm {}` but it -gives you the ability to be cross platform. To work anywhere and everywhere. And -hey, if you really need to execute a shell command, Ant has an exec rule that -allows different commands to be executed based on the OS that it is executing -on.

- -
-

Getting Ant

-

Binary edition

-

The latest stable version of Ant can be downloaded from http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip. -If you like living on the edge, you can download the latest version from http://jakarta.apache.org/builds/tomcat/nightly/ant.zip.

-

Source edition

-

If you prefer the source edition, you can download Ant from http://jakarta.apache.org/builds/tomcat/release/v3.0/src/jakarta-tools.src.zip -(latest stable) or from http://jakarta.apache.org/from-cvs/jakarta-ant/ -(current). See the section Building Ant on how to -build Ant from the source code.

- -
-

System Requirements

-

- To build and use ant you must have a JAXP compilant XML parser installed and available on your classpath. -

- If you do not have a JAXP compliant XML parse installed, you may use the reference implementation - available from Sun. It is available from http://java.sun.com/xml. - Once installed make sure the "jaxp.jar" and "parser.jar" files are in your classpath. -

- You will also need the JDK installed on your system, version 1.1 or later. - -


-

Building Ant

-

Go to the directory jakarta-ant.

-

Make sure the JDK is in you path.

-

Run bootstrap.bat (Windows) or bootstrap.sh (UNIX) -to build a bootstrap version of Ant.

-

When finished, use

-
-

build.bat -Dant.dist.dir=<directory to install Ant> dist

-
-

for Windows, and

-
-

build.sh -Dant.dist.dir=<directory to install Ant> dist

-
-

for UNIX, to create a binary distribution of Ant. This distribution can be -found in the directory you specified.

-
-

Installing Ant

-

The binary distribution of Ant consists of three directories: bin, -docs and lib. Only the bin and lib -directory are crucial for running Ant. To run Ant, the following must be done:

-
    -
  • Add the bin directory to your path.
  • -
  • Set the ANT_HOME environment variable. This should be set to the directory - which contains the bin and lib directory.
  • -
  • Set the JAVA_HOME environment variable. This should be set to the - directory where the JDK is installed.
  • -
-

Windows

-

Assume Ant is installed in c:\ant\. The following sets up the -environment:

-
set ANT_HOME=c:\ant
-set JAVA_HOME=c:\jdk1.2.2
-set PATH=%PATH%;%ANT_HOME%\bin
-

Unix (bash)

-

Assume Ant is installed in /usr/local/ant. The following sets up -the environment:

-
export ANT_HOME=/usr/local/ant
-export JAVA_HOME=/usr/local/jdk-1.2.2
-export PATH=${PATH}:${ANT_HOME}/bin
-

Advanced

-

There are lots of variants that can be used to run Ant. What you need is at -least the following:

-

The classpath for Ant must contain ant.jar and any jars/classes -needed for your chosen JAXP compliant XML parser.

-

When you need JDK functionality (like a javac task, or a -rmic task), then for JDK 1.1, the classes.zip -file of the JDK must be added to the classpath; for JDK 1.2, tools.jar -must be added. The scripts supplied with ant, in the bin directory, will add -tools.jar automatically if the JAVA_HOME environment variable is set.

-

When you are executing platform specific applications (like the exec task, or the cvs task), the property ant.home -must be set to the directory containing a bin directory, which contains the antRun shell script necessary to run execs on Unix.

-
-

Running Ant

-

Running Ant is simple, when you installed it as described in the previous -section. Just type ant.

-

When nothing is specified, Ant looks for a build.xml file in the -current directory. When found, it uses that file as a buildfile. To make Ant use -another buildfile, use the commandline option -buildfile <file>, -where <file> is the buildfile you want to use.

-

You can also set properties which override properties specified in the -buildfile (see the property task). -This can be done with the -D<property>=<value> -option, where <property> is the name of the property and <value> -the value.

-

To more options are -quiet which instructs Ant to print less -information on the console when running. The option -verbose on the other -hand makes Ant print more information on the console.

-

It is also possible to specify the target that should be executed. Default -the target that is mentioned in the default attribute of the project is -used. This can be overridden by adding the target name to the end of the -commandline.

-

Commandline option summary:

-
ant [options] [target]
-Options:
--help                  print this message
--version               print the version information and exit
--quiet                 be extra quiet
--verbose               be extra verbose
--logfile <file>        use given file for log
--listener <classname>  add an instance of class as a project listener
--buildfile <file>      use given buildfile
--D<property>=<value>   use value for given property
-

Examples

-
-
ant
-
-

runs Ant using the build.xml file in the current directory, on -the default target.

-
-
ant -buildfile test.xml
-
-

runs Ant using the test.xml file in the current directory, on -the default target.

-
-
ant -buildfile test.xml dist
-
-

runs Ant using the test.xml file in the current directory, on a -target called dist.

-
-
ant -buildfile test.xml -Dbuild=build/classes dist
-
-

runs Ant using the test.xml file in the current directory, on a -target called dist. It also sets the build property to the -value build/classes.

-

Running Ant by hand

-

When you have installed Ant in the do-it-yourself way, Ant can be started -with:

-
-
java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]
-
- -

These instructions actually do exactly the same as the ant -command. The options and target are the same as when running Ant with the ant -command. This example assumes you have set up your classpath to include -

    -
  • ant.jar -
  • jars/classes for your XML parser -
  • the JDK's tools.jar -
-
-

Writing a simple buildfile

-

The buildfile is written in XML. Each buildfile contains one project.

-

Projects

-

A project has three attributes:

- - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
namethe name of the project.Yes
defaultthe default target to use when no target is supplied.Yes
basedirthe base directory from which all path calculations are - done. This attribute might be overridden by setting the "basedir" - property on forehand. When this is done, it might be ommitted in the - project tag.Yes
-

Each project defines one or more targets. A target is a set of tasks you want -to be executed. When starting Ant, you can select which target you want to have -executed. When no target is given, the project's default is used.

-

Targets

-

A target can depend on other targets. You might have a target for compiling, -for instance, and a target for creating a distributable. You can only build a -distributable when you have compiled first, so the distribute target depends on -the compile target. Ant resolves all these dependencies.

-

Ant tries to execute the targets in the depends attribute in the order -they appear (from left to right). Keep in mind that it is possible that a target -can get executed earlier when an earlier target depends on it:

-
-
<target name="A"/>
-<target name="B" depends="A"/>
-<target name="C" depends="B"/>
-<target name="D" depends="C,B,A"/>
-
-

Suppose we want to execute target D. From its depends attribute, you -might think that first target C, then B and then A is executed. Wrong! C depends -on B, and B depends on A, so first A is executed, then B, then C, and finally D.

-

A target gets executed only once. Even when more targets depend on it (see -the previous example).

-

A target has also the ability to perform its execution if a property has been -set. This allows, for example, better control on the building process depending -on the state of the system (java version, OS, command line properties, etc...). -To make target sense this property you should add the if attribute -with the name of the property that the target should react to, for example

-
-
<target name="build-module-A" if="module-A-present"/>
-
-

If no if attribute is present, the target will always be executed.

-

It is a good practice to place your property and tstamp tasks in a so called initialization target, on which -all other targets depend. Make sure that that target is always the first one in -the depends list of the other targets. In this manual, most initialization targets -have the name "init".

-

A target has the following attributes:

- - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
namethe name of the project.Yes
dependsa comma separated list of names of targets on which this - target depends.No
ifthe name of the property that must be set in order for this - target to execute.No
-

Tasks

-

A task is a piece of code that can be executed.

-

A task can have multiple attributes (or arguments if you prefer). The value -of an attribute might contain references to a property. These references will be -resolved before the task is executed.

-

Tasks have a common structure:

-
-
<name attribute1="value1" attribute2="value2" ... />
-
-

where name is the name of the task, attribute-x the attribute name, and -value-x the value of this attribute.

-

There is a set of built in tasks, but it is also very -easy to write your own.

-

Properties

-

A project can have a set of properties. These might be set in the buildfile -by the property task, or might be set outside Ant. A -property has a name and a value. Properties might be used in in the value of -task attributes. This is done by placing the property name between -"${" and "}" in the attribute value.

-

If there is a property called "builddir" with the value -"build", then this could be used in an attribute like this: "${builddir}/classes". -This is resolved as "build/classes".

-

Token Filters

-

A project can have a set of tokens that might be automatically expanded if -found when a file is copied, when the filtering-copy behavior is selected in the -tasks that support this. These might be set in the buildfile -by the filter task

-

Since this can be a very harmful behavior, the tokens in the files must -be of the form @token@ where token is the token name that is set -in the filter task. This token syntax matches the syntax of other build systems -that perform such filtering and remains sufficiently orthogonal to most -programming and scripting languages, as well with documentation systems.

-

Note: in case a token with the format @token@ if found in a file but no -filter is associated with that token, no changes take place. So, no escaping -method is present, but as long as you choose appropriate names for your tokens, -this should not cause problems.

-

Examples

-
-
<project name="foo" default="dist" basedir=".">
-  <target name="init">
-    <tstamp/>
-    <property name="build" value="build" />
-    <property name="dist"  value="dist" />
-    <filter token="version" value="1.0.3" />
-    <filter token="year" value="2000" />
-  </target>
-
-  <target name="prepare" depends="init">
-    <mkdir dir="${build}" />
-  </target>
-
-  <target name="compile" depends="prepare">
-    <javac srcdir="${src}" destdir="${build}" filtering="on"/>
-  </target>
-
-  <target name="dist" depends="compile">
-    <mkdir dir="${dist}/lib" />
-    <jar jarfile="${dist}/lib/foo${DSTAMP}.jar"
-     basedir="${build}" items="com"/>
-  </target>
-
-  <target name="clean" depends="init">
-    <deltree dir="${build}" />
-    <deltree dir="${dist}" />
-  </target>
-</project>
-
-
- -
-

Directory based tasks

-

Some tasks use directory trees for the task they perform. For instance, the Javac task which works upon a directory tree with .java files. -Sometimes it can be very useful to work on a subset of that directory tree. This -section describes how you can select a subset of such a directory tree.

-

Ant gives you two ways to create a subset, both of which can be used at the same -time:

-
    -
  • Only include files/directories that match at least one pattern of a set of - patterns
  • -
  • Exclude files/directories that match at least one pattern a set of - patterns
  • -
-

When both inclusion and exclusion are used, only files/directories that match -the include patterns, and don't match the exclude patterns are used.

-

Patterns can be specified inside the buildfile via task attributes or -nested elements and via external files. Each line of the external file -is taken as pattern that is added to the list of include or exclude -patterns.

-

Patterns

-

As described earlier, patterns are used for the inclusion and exclusion. -These patterns look very much like the patterns used in DOS and UNIX:

-

'*' matches zero or more characters, '?' matches one character.

-

Examples:

-

'*.java' matches '.java', 'x.java' and 'FooBar.java', but not 'FooBar.xml' -(does not end with '.java').

-

'?.java' matches 'x.java', 'A.java', but not '.java' or 'xyz.java' (both -don't have one character before '.java').

-

Combinations of '*'s and '?'s are allowed.

-

Matching is done per-directory. This means that first the first directory in -the pattern is matched against the first directory in the path to match. Then -the second directories are matched, and so on. E.g. when we have the pattern '/?abc/*/*.java' -and the path '/xabc/foobar/test.java', then first '?abc' is matched with 'xabc', -then '*' is matched with 'foobar' and finally '*.java' is matched with 'test.java'. -They all match so the path matches the pattern.

-

Too make things a bit more flexible, we add one extra feature, which makes it -possible to match multiple directory levels. This can be used to match a -complete directory tree, or a file anywhere in the directory tree. To do this, '**' -must be used as the name of a directory. When '**' is used as the name of a -directory in the pattern, it matches zero or more directories. For instance: -'/test/**' matches all files/directories under '/test/', such as '/test/x.java', -or '/test/foo/bar/xyz.html', but not '/xyz.xml'.

-

There is one "shorthand", if a pattern ends with '/' or '\', then '**' -is appended. E.g. "mypackage/test/" is interpreted as were it "mypackage/test/**".

-

Examples:

- - - - - - - - - - - - - - - - - -
**/CVS/*Matches all files in CVS directories, that can be located - anywhere in the directory tree. -

Matches:

-

CVS/Repository
- org/apache/CVS/Entries
- org/apache/jakarta/tools/ant/CVS/Entries

-

But not:

-

org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match)

org/apache/jakarta/**Matches all files in the org/apache/jakarta directory tree. -

Matches:

-

org/apache/jakarta/tools/ant/docs/index.html
- org/apache/jakarta/test.xml

-

But not:

-

org/apache/xyz.java ('jakarta'/' part is missing)

org/apache/**/CVS/*Matches all files in CVS directories, that are located - anywhere in the directory tree under org/apache. -

Matches:

-

org/apache/CVS/Entries
- org/apache/jakarta/tools/ant/CVS/Entries

-

But not:

-

org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match)

**/test/**Matches all files which have a directory 'test' in their - path, including 'test' as a filename.
-

When these patterns are used in inclusion and exclusion, you have a powerful -way to select just the files you want.

-

Examples

-
  <copydir src="${src}"
-           dest="${dist}"
-           includes="**/images/*"
-           excludes="**/*.gif" />
-

This copies all files in directories called "images", that are -located in the directory tree "${src}" to the destination "${dist}", -but excludes all "*.gif" files from the copy.

-

This example can also be expressed using nested elements as -

  <copydir src="${src}"
-           dest="${dist}">
-    <include name="**/images/*"/>
-    <exclude name="**/*.gif" />
-  </copydir>
-
- -

Default Excludes

-

There are a set of definitions which are excluded by default from all directory based tasks. -They are: -

        "**/*~",
-        "**/#*#",
-        "**/%*%",
-        "**/CVS",
-        "**/CVS/*",
-        "**/.cvsignore"
-
-If you do not want these default excludes applied, you may disable them with the -defaultexcludes="no" attribute.

-
-

Built in tasks

- -
-

Ant

-

Description:

-

Runs Ant on a supplied buildfile. This can be used to build subprojects.

-

When the antfile attribute is omitted, the file "build.xml" -in the supplied directory (dir attribute) is used.

-

If no target attribute is supplied, the default target of the new project is -used.

-

The properties of the current project will be available in the new project. -These properties will override the properties that are set in the new project. -(See also the properties task).

-

Parameters:

- - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
antfilethe buildfile to use.No
dirthe directory to use as a basedir for the new Ant project.Yes
targetthe target of the new Ant project that should be executed.No
outputFilename to write the ant output to. - No
-

Examples

-
-

<ant antfile="subproject/subbuild.xml" dir="subproject" - target="compile" />

-

<ant dir="subproject" />

-
-
-

Available

-

Description

-

Sets a property if a resource is available at runtime. This resource can be a -file resource, a class in classpath or a JVM system resource.

-

The value part of the properties being set is true if the resource is -present, otherwise, the property is not set.

-

Normally, this task is used to set properties that are useful to avoid target -execution depending on system parameters.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
propertythe name of the property to set.Yes
classnamethe class to look for in classpath.Yes
resourcethe resource to look for in the JVM
filethe file to look for.
-

Examples

-
  <available classname="org.whatever.Myclass" property="Myclass.present" />
-

sets the property Myclass.present to the value "true" -if the org.whatever.Myclass is found in Ant's classpath.

-
-

Chmod

-

Description

-

Changes the permissions of a file. Right now it has efect only under Unix. -The permissions are also UNIX style, like the argument for the chmod command.

-

Parameters

- - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcthe file of which the permissions must be changed.Yes
permthe new permissions.Yes
-

Examples

-
-

<chmod src="${dist}/start.sh" perm="ugo+rx" - />

-
-

makes the "start.sh" file readable and executable for anyone on a -UNIX system.

-
-

Copydir

-

Description

-

Copies a directory tree from the source to the destination.

-

It is possible to refine the set of files that are being copied. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the src directory.

-

The ignore attribute contains the names of the files/directories that -must be excluded from the copy. The names specified in the ignore -attribute are just names, they do not contain any path information! Note that -this attribute has been replaced by the excludes attribute.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcthe directory to copy.Yes
destthe directory to copy to.Yes
ignorecomma separated list of filenames/directorynames to ignore. - No files (except default excludes) are excluded when omitted. (deprecated, - use excludes instead).No
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
filteringindicates whether token filtering should take place during - the copyNo
forceoverwriteoverwrite existing files even if the destination - files are newer (default is false).No
-

Examples

-
  <copydir src="${src}/resources"
-           dest="${dist}"
-  />
-

copies the directory ${src}/resources to ${dist}.

-
  <copydir src="${src}/resources"
-           dest="${dist}"
-           includes="**/*.java"
-           excludes="**/Test.java"
-  />
-

copies the directory ${src}/resources to ${dist} -recursively. All java files are copied, except for files with the name Test.java.

-
  <copydir src="${src}/resources"
-           dest="${dist}"
-           includes="**/*.java"
-           excludes="mypackage/test/**" />
-

copies the directory ${src}/resources to ${dist} -recursively. All java files are copied, except for the files under the mypackage/test -directory.

-
-

Copyfile

-

Description

-

Copies a file from the source to the destination. The file is only copied if -the source file is newer than the destination file, or when the destination file -does not exist.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcthe filename of the file to copy.Yes
destthe filename of the file where to copy to.Yes
filteringindicates whether token filtering should take place during - the copyNo
-

Examples

-
-

<copyfile src="test.java" dest="subdir/test.java" - />

-

<copyfile src="${src}/index.html" dest="${dist}/help/index.html" - />

-
-
-

Cvs

-

Description

-

Handles packages/modules retrieved from a -CVS repository.

-

When doing automated builds, the get task should be -preferred over the checkout command, because of speed.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
commandthe CVS command to execute.No, default "checkout"
cvsRootthe CVSROOT variable.No
destthe directory where the checked out files should be placed.Yes
packagethe package/module to check out.No
tagthe tag of the package/module to check out.No
dateUse the most recent revision no later than the given dateNo
quietsupress informational messages.No, default "false"
noexecreport only, don't change any files.No, default "false"
-

Examples

-
  <cvs cvsRoot=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic"
-       package="jakarta-tools"
-       dest="${ws.dir}"
-  />
-

checks out the package/module "jakarta-tools" from the CVS -repository pointed to by the cvsRoot attribute, and stores the files in "${ws.dir}".

-
  <cvs dest="${ws.dir}" command="update" />
-

updates the package/module that has previously been checked out into -"${ws.dir}".

-
-

Delete

-

Description

-

Deletes either a single file or -all files in a specified directory and its sub-directories.

-

It is possible to refine the set of files that are being deleted. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included in the deletion process by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded from the deletion process. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the dir directory.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
fileThe file to delete.at least one of the two
dirThe directory to delete files from.
includesComma separated list of patterns of files that must be - deleted. All files are in the current directory - and any sub-directories are deleted when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludesComma separated list of patterns of files that must be - excluded from the deletion list. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesIndicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
verboseShow name of each deleted file ("true"/"false"). Default is "false" when omitted.No
-

Examples

-
  <delete file="/lib/ant.jar" />
-

deletes the file /lib/ant.jar.

-
  <delete dir="lib" />
-

deletes all files in the /lib directory.

-
  <delete dir="."
-          include="**/*.bak"
-  />
-
-

deletes all files with the extension ".bak" from the current directory -and any sub-directories.

-

Deltree

-

Description

-

Deletes a directory with all its files and subdirectories.

-

Parameters

- - - - - - - - - - - -
AttributeDescriptionRequired
dirthe directory to delete.Yes
-

Examples

-
  <deltree dir="dist" />
-

deletes the directory dist, including its files and -subdirectories.

-
  <deltree dir="${dist}" />
-

deletes the directory ${dist}, including its files and -subdirectories.

-
-

Echo

-

Description

-

Echoes a message to System.out.

-

Parameters

- - - - - - - - - - - -
AttributeDescriptionRequired
messagethe message to echo.Yes
-

Examples

-
  <echo message="Hello world" />
-
-

Exec

-

Description

-

Executes a system command. When the os attribute is specified, then -the command is only executed when Ant is run on one of the specified operating -systems.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
commandthe command to execute.Yes
dirthe directory in which the command should be executed.Yes
oslist of Operating Systems on which the command may be - executed.No
outputthe file to which the output of the command should be - redirected.Yes
-

Examples

-
-

<exec dir="${src}" command="dir" os="windows" - output="dir.txt" />

-
-
-

Expand

-

Description

-

Unzips a zipfile.

-

For JDK 1.1 "last modified time" field is set to current time instead of being -carried from zipfile.

-

Parameters

- - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srczipfile to expand.Yes
destdirectory where to store the expanded files.Yes
-

Examples

-
-

<expand src="${tomcat_src}/tools-src.zip" dest="${tools.home}" - />

-
-
-

Filter

-

Description

-

Sets a token filter for this project. Token filters are used by all tasks -that perform file copying operations through the Project commodity methods.

-

Note: the token string must not contain the separators chars (@).

-

Parameters

- - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
tokenthe token string without @Yes
valuethe string that should be put to replace the token when the - file is copiedYes
-

Examples

-
  <filter token="year" value="2000" />
-  <copydir src="${src.dir}" dest="${dest.dir}"/>
-

will copy recursively all the files from the src.dir directory into -the dest.dir directory replacing all the occurencies of the string @year@ -with 2000.

-
-

FixCRLF

-

Description

-

Adjusts a text file to local.

-

It is possible to refine the set of files that are being adjusted. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the src directory.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcDirWhere to find the files to be fixed up.Yes
destDirWhere to place the corrected files. Defaults to - srcDir (replacing the original file)No
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
crSpecifies how carriage return (CR) characters are to - be handled. Valid values for this property are: -
    -
  • add: ensure that there is a CR before every LF -
  • asis: leave CR characters alone -
  • remove: remove all CR characters -
- Default is based on the platform on which you are running this task. - For Unix platforms, the default is remove. For DOS based systems - (including Windows), the default is add. -

- Note: Unless this property is specified as "asis", extra CR characters - which do not preceed a LF will be removed. -

No
tabSpecifies how tab characters are to be handled. Valid - values for this property are: -
    -
  • add: convert sequences of spaces which span a tab stop to tabs -
  • asis: leave tab and space characters alone -
  • remove: convert tabs to spaces -
- Default for this parameter is "asis". -

- Note: Unless this property is specified as "asis", extra spaces and - tabs after the last non-whitespace character on the line will be removed. -

No
eofSpecifies how DOS end of file (control-Z) characters are - to be handled. Valid values for this property are: -
    -
  • add: ensure that there is an EOF character at the end of the file -
  • asis: leave EOF characters alone -
  • remove: remove any EOF character found at the end -
- Default is based on the platform on which you are running this task. - For Unix platforms, the default is remove. For DOS based systems - (including Windows), the default is asis. -
No
-

Examples

-
  <fixcrlf srcdir="${src}"
-       cr="remove" eof="remove"
-       includes="**/*.sh"
-  />
-

Removes carriage return and eof characters from the shell scripts. Tabs and -spaces are left as is. -

  <fixcrlf srcdir="${src}"
-       cr="add"
-       includes="**/*.bat"
-  />
-

Ensures that there are carriage return characters prior to evey line feed. -Tabs and spaces are left as is. -EOF characters are left alone if run on -DOS systems, and are removed if run on Unix systems.

-
  <fixcrlf srcdir="${src}"
-       tabs="add"
-       includes="**/Makefile"
-  />
-

Adds or removes CR characters to match local OS conventions, and -converts spaces to tabs when appropriate. EOF characters are left alone if -run on DOS systems, and are removed if run on Unix systems. -Many versions of make require tabs prior to commands.

-
  <fixcrlf srcdir="${src}"
-       tabs="remove"
-       includes="**/README*"
-  />
-

Adds or removes CR characters to match local OS conventions, and -converts all tabs to spaces. EOF characters are left alone if run on -DOS systems, and are removed if run on Unix systems. -You never know what editor a user will use to browse README's.

-
-

Get

-

Description

-

Gets a file from an URL. When the verbose option is "on", this task -displays a '.' for every 100 Kb retrieved.

-

This task should be preferred above the CVS task when -doing automated builds. CVS is significant slower than loading a compressed -archive with http/ftp.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcthe URL from which to retrieve a file.Yes
destthe file where to store the retrieved file.Yes
verboseshow verbose information ("on"/"off").No
ignoreerrorsLog errors but don't treat as fatal.No
-

Examples

-
  <get src="http://jakarta.apache.org/" dest="help/index.html" />
-

gets the index page of http://jakarta.apache.org/, and stores it in the file help/index.html.

-
-

GUnzip

-

Description

-

Expands a GZip file.

- -

If dest is a directory the name of the destination file is -the same as src (with the ".gz" extension removed if -present). If dest is ommited, the parent dir of src is -taken. The file is only expanded if the source file is newer than the -destination file, or when the destination file does not exist.

- -

Parameters

- - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcthe file to expand.Yes
destthe destination file or directory.No
-

Examples

-
-

<gunzip src="test.tar.gz"/>

-
-

expands test.tar.gz to test.tar

-
-

<gunzip src="test.tar.gz" dest="test2.tar"/>

-
-

expands test.tar.gz to test2.tar

-
-

<gunzip src="test.tar.gz" dest="subdir"/>

-
-

expands test.tar.gz to subdir/test.tar (assuming -subdir is a directory).

- -
-

GZip

-

Description

-

GZips a file.

-

Parameters

- - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcthe file to gzip.Yes
zipfilethe destination file.Yes
-

Examples

-
-

<gzip src="test.tar" zipfile="test.tar.gz" - />

-
-
-

Jar

-

Description

-

Jars a set of files.

-

The basedir attribute is the reference directory from where to jar.

-

It is possible to refine the set of files that are being jarred. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the basedir directory.

-

The includes, excludes and defaultexcludes attributes -replace the items and ignore attributes. The following explains -how the deprecated items and ignore attribute behave.

-

When "*" is used for items, all files in the basedir, and -its subdirectories, will be jarred. Otherwise all the files and directories -mentioned in the items list will jarred. When a directory is specified, then all -files within it are also jarred.

-

With the ignore attribute, you can specify files or directories to -ignore. These files will not be jarred. The items in the ignore attribute -override the items in the items attribute. The names specified in the ignore -attribute are just names, they do not contain any path information!

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
jarfilethe jar-file to create.Yes
basedirthe directory from which to jar the files.Yes
compressNot only store data but also compress them, defaults to trueNo
itemsa comma separated list of the files/directories to jar. All - files are included when omitted. (deprecated, use includes - instead).No
ignorecomma separated list of filenames/directorynames to exclude - from the jar. No files (except default excludes) are excluded when - omitted. (deprecated, use excludes instead).No
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
manifestthe manifest file to use.No
-

Examples

-
  <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" />
-

jars all files in the ${build}/classes directory in a file -called app.jar in the ${dist}/lib directory.

-
  <jar jarfile="${dist}/lib/app.jar"
-       basedir="${build}/classes"
-       excludes="**/Test.class"
-  />
-

jars all files in the ${build}/classes directory in a file -called app.jar in the ${dist}/lib directory. Files -with the name Test.class are excluded.

-
  <jar jarfile="${dist}/lib/app.jar"
-       basedir="${build}/classes"
-       includes="mypackage/test/**"
-       excludes="**/Test.class"
-  />
-

jars all files in the ${build}/classes directory in a file -called app.jar in the ${dist}/lib directory. Only -files under the directory mypackage/test are used, and files with -the name Test.class are excluded.

-

Deprecated examples

-
  <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" items="*" />
-

jars all files in the ${build}/classes directory in a file -called app.jar in the ${dist}/lib directory.

-
  <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" items="*" ignore="Test.class" />
-

jars all files in the ${build}/classes directory in a file -called app.jar in the ${dist}/lib directory. -Files/directories with the name Test.class are excluded.

-
-

Java

-

Description

-

Executes a Java class within the running (Ant) VM or forks another VM if -specified.

-

Be careful that the executed class doesn't call System.exit(), because it -will terminate the VM and thus Ant. In case this happens, it's highly suggested -that you set the fork attribute so that System.exit() stops the other VM and not -the one that is currently running Ant.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
classnamethe Java class to execute.Yes
argsthe arguments for the class that is executed.No
classpaththe classpath to use.No
forkif enabled triggers the class execution in another VM - (disabled by default)No
jvmthe command used to invoke the Java Virtual Machine, - default is 'java'. The command is resolved by java.lang.Runtime.exec(). - Ignored if fork is disabled. - No
jvmargsthe arguments to pass to the forked VM (ignored if fork is - disabled)No
-

Examples

-
  <java classname="test.Main" />
-
  <java classname="test.Main" args="-h" />
-
  <java classname="test.Main"
-        args="-h"
-        fork="yes"
-        jvmargs="-Xrunhprof:cpu=samples,file=log.txt,depth=3"
-  />
-
-

Javac

-

Description

-

Compiles a source tree within the running (Ant) VM.

-

The source and destination directory will be recursively scanned for Java -source files to compile. Only Java files that have no corresponding class file -or where the class file is older than the java file will be compiled.

-

Files in the source tree, that are no java files, are copied to the -destination directory, allowing support files to be located properly in the -classpath.

-

The directory structure of the source tree should follow the package -hierarchy.

-

It is possible to refine the set of files that are being compiled/copied. -This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the srcdir directory.

-

It is possible to use different compilers. This can be selected with the -"build.compiler" property. There are three choices:

-
    -
  • classic (the standard compiler of JDK 1.1/1.2)
  • -
  • modern (the new compiler of JDK 1.3)
  • -
  • jikes (the Jikes - compiler)
  • -
-

For JDK 1.1/1.2 is classic the default. For JDK 1.3 is modern the default.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcdirlocation of the java files.Yes
destdirlocation where to store the class files.Yes
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
classpaththe classpath to use.No
bootclasspathlocation of bootstrap class files.No
extdirslocation of installed extensions.No
debugindicates whether there should be compiled with debug - information ("on").No
optimizeindicates whether there should be compiled with - optimization ("on").No
deprecationindicates whether there should be compiled with deprecation - information ("on").No
filteringindicates whether token filtering should take placeNo
targetGenerate class files for specific VM version, e.g. "1.1" or "1.2".No
-

Examples

-
  <javac srcdir="${src}"
-         destdir="${build}"
-         classpath="xyz.jar"
-         debug="on"
-  />
-

compiles all .java files under the directory ${src}, and stores -the .class files in the directory ${build}. It also copies the non-java -files from the tree under ${src} to the tree under ${build}. -The classpath used contains xyz.jar, and debug information is on.

-
  <javac srcdir="${src}"
-         destdir="${build}"
-         includes="mypackage/p1/**,mypackage/p2/**"
-         excludes="mypackage/p1/testpackage/**"
-         classpath="xyz.jar"
-         debug="on"
-  />
-

compiles .java files under the directory ${src}, and stores the -.class files in the directory ${build}. It also copies the non-java -files from the tree under ${src} to the tree under ${build}. -The classpath used contains xyz.jar, and debug information is on. -Only files under mypackage/p1 and mypackage/p2 are -used. Files in the mypackage/p1/testpackage directory are excluded -form compilation and copy.

- -
-

Javadoc/Javadoc2

-

Description

-

Generates code documentation using the javadoc tool.

-

The source directory will be recursively scanned for Java source files to process -but only those matching the inclusion rules will be passed to the javadoc tool. This -allows wildcards to be used to choose between package names, reducing verbosity -and management costs over time. This task, however, has no notion of -"changed" files, unlike the javac task. This means -all packages will be processed each time this task is run. In general, however, -this task is used much less frequently.

-

This task works seamlessly between different javadoc versions (1.1 and 1.2), -with the obvious restriction that the 1.2 attributes will be ignored if run in a -1.1 VM.

-

NOTE: since javadoc calls System.exit(), javadoc cannot be run inside the -same VM as ant without breaking functionality. For this reason, this task -always forks the VM. This overhead is not significant since javadoc is normally a heavy -application and will be called infrequently.

-

NOTE: the packagelist attribute allows you to specify the list of packages to -document outside of the Ant file. It's a much better practice to include everything -inside the build.xml file. This option was added in order to make it easier to -migrate from regular makefiles, where you would use this option of javadoc. -The packages listed in packagelist are not checked, so the task performs even -if some packages are missing or broken. Use this option if you wish to convert from -an existing makefile. Once things are running you should then switch to the regular -notation. - -

DEPRECATION: the javadoc2 task simply points to the javadoc task and it's -there for back compatibility reasons. Since this task will be removed in future -versions, you are strongly encouraged to use javadoc -instead.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionAvailabilityRequired
sourcepathSpecify where to find source filesallYes
destdirDestination directory for output filesallYes
maxmemoryMax amount of memory to allocate to the javadoc VMallNo
sourcefilesSpace separated list of source filesallat least one of the two
packagenamesSpace separated list of package files (with terminating - wildcard)all
packageListThe name of a file containing the packages to processallNo
classpathSpecify where to find user class filesallNo
BootclasspathOverride location of class files loaded by the bootstrap - class loader1.2No
ExtdirsOverride location of installed extensions1.2No
OverviewRead overview documentation from HTML file1.2No
PublicShow only public classes and membersallNo
ProtectedShow protected/public classes and members (default)allNo
PackageShow package/protected/public classes and membersallNo
PrivateShow all classes and membersallNo
OldGenerate output using JDK 1.1 emulating doclet1.2No
VerboseOutput messages about what Javadoc is doing1.2No
LocaleLocale to be used, e.g. en_US or en_US_WIN1.2No
EncodingSource file encoding nameallNo
VersionInclude @version paragraphsallNo
UseCreate class and package usage pages1.2No
AuthorInclude @author paragraphsallNo
SplitindexSplit index into one file per letter1.2No
WindowtitleBrowser window title for the documenation (text)1.2No
DoctitleInclude title for the package index(first) page (html-code)1.2No
HeaderInclude header text for each page (html-code)1.2No
FooterInclude footer text for each page (html-code)1.2No
bottomInclude bottom text for each page (html-code)1.2No
linkCreate links to javadoc output at the given URL1.2No
linkofflineLink to docs at <url> using package list at - <url2>1.2No
groupGroup specified packages together in overview page1.2No
nodeprecatedDo not include @deprecated informationallNo
nodeprecatedlistDo not generate deprecated list1.2No
notreeDo not generate class hierarchyallNo
noindexDo not generate indexallNo
nohelpDo not generate help link1.2No
nonavbarDo not generate navigation bar1.2No
serialwarnFUTURE: Generate warning about @serial tag1.2No
helpfileFUTURE: Specifies the HTML help file to use1.2No
stylesheetfileSpecifies the CSS stylesheet to use1.2No
charsetFUTURE: Charset for cross-platform viewing of generated - documentation1.2No
docencodingOutput file encoding name1.1No
docletSpecifies the class file that starts the doclet used in generating the documentation.1.2No
docletpathSpecifies the path to the doclet class file that is specified with the -doclet option.1.2No
additionalparamLets you add additional parameters to the javadoc command line. Useful for doclets1.2No
- -

Parameters specified as subelements

-Two parameters of the Javadoc task may be specified as nested elements of the -Javadoc task element: link and group. -When present, there can be any number of each of these elements. -They perform the same role as the link, linkoffline and -group attributes. You can use either syntax (or both at once), but with the nested -elements you can easily specify multiple occurrences of the arguments. -

link

-Create link to javadoc output at the given URL -

Parameters

- - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
hrefThe URL for the external documentation you wish to link toYes
offlineTrue if this link is not available online at the time of - generating the documentationNo
packagelistLocThe location to the directory containing the package-list file for - the external documentationOnly if the offline attribute is true
- -

groups

-Separates packages on the overview page into whatever groups you specify, -one group per table. - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
titleTitle of the groupYes
packagesList of packages to include in that groupYes
- -

Example

-
  <javadoc packagenames="com.dummy.test.*"
-           sourcepath="src"
-           destdir="docs/api"
-           author="true"
-           version="true"
-           use="true"
-           windowtitle="Test API"
-           doctitle="<h1>Test</h1>"
-           bottom="<i>Copyright &#169; 2000 Dummy Corp. All Rights Reserved.</i>">
-    <group title="Group 1 Packages" packages="com.dummy.test.a*"/>
-    <group title="Group 2 Packages" packages="com.dummy.test.b*"/>
-    <link offline="true" href="http://java.sun.com/products/jdk/1.2/docs/api/" packagelistLoc="C:\tmp"/>
-    <link href="http://developer.java.sun.com/developer/products/xml/docs/api/"/>
-  </javadoc>
- -
-

KeySubst

-

Description

-

Performs keyword substitution in the source file, and writes the result to -the destination file.

-

Keys in the source file are of the form ${keyname}. The keys attribute -contains key/value pairs. When a key is found in the keys attribute, then -"${keyname}" is replaced by the corresponding value.

-

The keys attribute is of the form -"name1=value1*name2=value2*name3=value3". The '*' is called the -separator, which might we changed with the sep attribute.

-

Note: the source file and destination file may not be the same.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcthe source file.Yes
destthe destination file.Yes
septhe separator for the name/value pairs.No
keysname/value pairs for replacement.Yes
-

Examples

-
  <keysubst src="abc.txt" dest="def.txt" keys="VERSION=1.0.3*DATE=2000-01-10" />
-
-

Mkdir

-

Description

-

Creates a directory. Also non-existent parent directories are created, when -necessary.

-

Parameters

- - - - - - - - - - - -
AttributeDescriptionRequired
dirthe directory to create.Yes
-

Examples

-
<mkdir dir="${dist}" />
-

creates a directory ${dist}.

-
<mkdir dir="${dist}/lib" />
-

creates a directory ${dist}/lib.

-
-

Patch

-

Description

-

Applies a diff file to originals. -

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
dirthe directory in which the command should be executed.Yes
oslist of Operating Systems on which the command may be - executed.No
outputthe file to which the output of the patch command - should be redirected.No
patchfilethe file that includes the diff outputYes
originalfilethe file to patchNo, tries to guess it from the diff - file
backupsKeep backups of the unpatched filesNo
quietWork silently unless an error occursNo
reverseAssume patch was created with old and new files - swapped.No
ignorewhitespaceIgnore whitespace differences.No
stripStrip the smallest prefix containing num leading - slashes from filenames.No
-

Examples

-
  <patch patchfile="module.1.0-1.1.patch" />
-

applies the diff included in module.1.0-1.1.patch to the -files in base directory guessing the filename(s) from the diff output. -

  <patch patchfile="module.1.0-1.1.patch" strip="1" />
-

like above but one leading directory part will be removed. i.e. if -the diff output looked like -

---- a/mod1.0/A	Mon Jun  5 17:28:41 2000
-+++ a/mod1.1/A	Mon Jun  5 17:28:49 2000
-
-the leading a/ will be stripped. -

Property

-

Description

-

Sets a property (by name and value), or set of properties (from file or -resource) in the project.

-

When a property was set by the user, or was a property in a parent project -(that started this project with the ant task), then this -property cannot be set, and will be ignored. This means that properties set -outside the current project always override the properties of the current -project.

-

There are three ways to set properties:

-
    -
  • By supplying both the name and value attribute.
  • -
  • By setting the file attribute with the filename of the property - file to load. This property file has the format as defined by the file used - in the class java.util.Properties.
  • -
  • By setting the resource attribute with the resource name of the - property file to load. This property file has the format as defined by the - file used in the class java.util.Properties.
  • -
-

Although combinations of the three ways are possible, only one should be used -at a time. Problems might occur with the order in which properties are set, for -instance.

-

The value part of the properties being set, might contain references to other -properties. These references are resolved at the time these properties are set. -This also holds for properties loaded from a property file.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
namethe name of the property to set.Yes
valuethe value of the property.Yes
resourcethe resource name of the property file.
filethe filename of the property file .
-

Examples

-
  <property name="foo.dist" value="dist" />
-

sets the property foo.dist to the value "dist".

-
  <property file="foo.properties" />
-

reads a set of properties from a file called "foo.properties".

-
  <property resource="foo.properties" />
-

reads a set of properties from a resource called "foo.properties".

-

Note that you can reference a global properties file for all of your Ant -builds using the following: -

  <property file="${user.home}/.ant-global.properties" />
-

since the "user.home" property is defined by the Java virtual machine -to be your home directory. This technique is more appropriate for Unix than -Windows since the notion of a home directory doesn't exist on Windows. On the -JVM that I tested, the home directory on Windows is "C:\". Different JVM -implementations may use other values for the home directory on Windows. -


-

Rename

-

Description

-

Renames a given file.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srcfile to rename.Yes
destnew name of the file.Yes
replaceEnable replacing of existing file (default: on).No
-

Examples

-
  <rename src="foo.jar" dest="${name}-${version}.jar" />
-

Renames the file foo.jar to ${name}-${version}.jar (assuming name - and version being predefined properties). If a file named ${name}-${version}.jar - already exists, it will be removed prior to renameing foo.jar.

-
-

Replace

-

Description

-

Replace is a directory based task for replacing the occurrence of a given string with another string -in selected file.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
filefile for which the token should be replaced. If not present the dir attribute - must be specifiedNo
dirThe base directory to use when replacing a token in multiple files. If not present the file attribute - must be specifiedNo
tokenthe token which must be replaced.Yes
valuethe new value for the token. When omitted, an empty string - ("") is used.No
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
-

Examples

-
  <replace file="${src}/index.html" token="@@@" value="wombat" />
-

replaces occurrences of the string "@@@" with the string -"wombat", in the file ${src}/index.html.

-
-

Rmic

-

Description

-

Runs the rmic compiler for a certain class.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
basethe location to store the compiled files.Yes
classnamethe class for which to run rmic.Yes
filteringindicates whether token filtering should take placeNo
sourcebasePass the "-keepgenerated" flag to rmic and - move the generated source file to the base directory.No
stubversionSpecify the JDK version for the generated stub code. - Specify "1.1" to pass the "-v1.1" option to rmic.No
classpathThe classpath to use during compilationNo
-

Examples

-
  <rmic classname="com.xyz.FooBar" base="${build}/classes" />
-

runs the rmic compiler for the class com.xyz.FooBar. The -compiled files will be stored in the directory ${build}/classes.

-
-

Tar

-

Description

-

Creates a tar archive.

-

The basedir attribute is the reference directory from where to tar.

-

It is possible to refine the set of files that are being tarred. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the basedir directory.

-

The includes, excludes and defaultexcludes attributes -replace the items and ignore attributes. The following explains -how the deprecated items and ignore attribute behave.

-

When "*" is used for items, all files in the basedir, and -its subdirectories, will be tarred. Otherwise all the files and directories -mentioned in the items list will tarred. When a directory is specified, then all -files within it are also tarred.

-

With the ignore attribute, you can specify files or directories to -ignore. These files will not be tarred. The items in the ignore attribute -override the items in the items attribute. The names specified in the ignore -attribute are just names, they do not contain any path information!

-

Note that this task does not perform compression. You might want to use the GZip -task to come up with a .tar.gz package.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
tarfilethe tar-file to create.Yes
basedirthe directory from which to zip the files.Yes
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
-

Examples

-
  <tar tarfile="${dist}/manual.tar" basedir="htdocs/manual" />
-  <gzip zipfile="${dist}/manual.tar.gz" src="${dist}/manual.tar" />
-

tars all files in the htdocs/manual directory in a file called manual.tar -in the ${dist} directory, then applies the gzip task to compress -it.

-
  <tar tarfile="${dist}/manual.tar"
-       basedir="htdocs/manual"
-       excludes="mydocs/**, **/todo.html"
-  />
-

tars all files in the htdocs/manual directory in a file called manual.tar -in the ${dist} directory. Files in the directory mydocs, -or files with the name todo.html are excluded.

-
-

Taskdef

-

Description

-

Adds a task definition to the current project, such that this new task can be -used in the current project. Two attributes are needed, the name that identifies -this task uniquely, and the full name of the class (including the packages) that -implements this task.

-

Taskdef should be used to add your own tasks to the system. See also "Writing your own task".

-

Parameters

- - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
namethe name of the taskYes
classnamethe full class name implementing the taskYes
-

Examples

-
  <taskdef name="myjavadoc" classname="com.mydomain.JavadocTask" />
-

makes a task called myjavadoc available to Ant. The class com.mydomain.JavadocTask -implements the task.

-
-

Touch

-

Description

-

Changes the modification time of a file and possibly creates it at -the same time.

-

For JDK 1.1 only the creation of new files with a modification time -of now works, all other cases will emit a warning.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
filethe name of the fileYes
millisspecifies the new modification time of the file - in milliseconds since midnight Jan 1 1970No
datetimespecifies the new modification time of the file - in the format MM/DD/YYYY HH:MM AM_or_PM.No
-

If both millis and datetime are ommited -the current time is assumed.

-

Examples

-
  <touch file="myfile" />
-

creates myfile if it doesn't exist and changes the -modification time to the current time.

-
  <touch file="myfile" datetime="06/28/2000 2:02 pm" />
-

creates myfile if it doesn't exist and changes the -modification time to Jun, 28 2000 2:02 pm (14:02 for those used to 24 -hour times).

-
-

Tstamp

-

Description

-

Sets the DSTAMP, TSTAMP and TODAY properties in the current project. The -DSTAMP is in the "yyyymmdd" format, the TSTAMP is in the "hhmm" -format and TODAY is "month day year".

-

These properties can be used in the buildfile, for instance, to create -timestamped filenames or used to replace placeholder tags inside documents to -indicate, for example, the release date. The best place for this task is in your -initialization target.

-

Parameters

- - - - - - -
AttributeDescriptionRequired
-

Examples

-
  <tstamp/>
-
-

Style

-

Description

-

Process a set of documents via XSLT.

-

This is useful for building views of XML based documentation, -or in generating code.

-

It is possible to refine the set of files that are being copied. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the basedir directory.

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
basedirwhere to find the source xml file.Yes
destdirdirectory where to store the results.Yes
extentiondesired file extension to be used for the targets. - If not specified, the default is "html".No
stylename of the stylesheet to use.Yes
processorname of the XSLT processor to use. Permissable -values are "xslp" for the XSL:P processor, "xalan" for the Apache XML Xalan -processor, or the name of an arbitrary XSLTLiaison class. -Defaults to xslp or xalan (in that order), if one is found in your -class pathNo
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
-

Examples

-
-

-<style basedir="doc" destdir="build/doc"
-       extension="html" style="style/apache.xml"/>
-

-
-
-

Untar

-

Description

-

Untars a tarfile.

-

For JDK 1.1 "last modified time" field is set to current time instead of being -carried from tarfile.

-

Parameters

- - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
srctarfile to expand.Yes
destdirectory where to store the expanded files.Yes
-

Examples

-
-

-<gunzip src="tools.tar.gz"/>
-<untar src="tools.tar" dest="${tools.home}"/> -

-
-
-

Zip

-

Description

-

Creates a zipfile.

-

The basedir attribute is the reference directory from where to zip.

-

It is possible to refine the set of files that are being zipped. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the basedir directory.

-

The includes, excludes and defaultexcludes attributes -replace the items and ignore attributes. The following explains -how the deprecated items and ignore attribute behave.

-

When "*" is used for items, all files in the basedir, and -its subdirectories, will be zipped. Otherwise all the files and directories -mentioned in the items list will zipped. When a directory is specified, then all -files within it are also zipped.

-

With the ignore attribute, you can specify files or directories to -ignore. These files will not be zipped. The items in the ignore attribute -override the items in the items attribute. The names specified in the ignore -attribute are just names, they do not contain any path information!

-

Parameters

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
zipfilethe zip-file to create.Yes
basedirthe directory from which to zip the files.Yes
compressNot only store data but also compress them, defaults to trueNo
itemsa comma separated list of the files/directories to zip. All - files are included when omitted. (deprecated, use includes - instead).No
ignorecomma separated list of filenames/directorynames to exclude - from the zip. No files (except default excludes) are excluded when - omitted. (deprecated, use excludes instead).No
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.No
-

Examples

-
  <zip zipfile="${dist}/manual.zip"
-       basedir="htdocs/manual"
-  />
-

zips all files in the htdocs/manual directory in a file called manual.zip -in the ${dist} directory.

-
  <zip zipfile="${dist}/manual.zip"
-       basedir="htdocs/manual"
-       excludes="mydocs/**, **/todo.html"
-  />
-

zips all files in the htdocs/manual directory in a file called manual.zip -in the ${dist} directory. Files in the directory mydocs, -or files with the name todo.html are excluded.

-
  <zip zipfile="${dist}/manual.zip"
-       basedir="htdocs/manual"
-       includes="api/**/*.html"
-       excludes="**/todo.html"
-  />
-

zips all files in the htdocs/manual directory in a file called manual.zip -in the ${dist} directory. Only html files under the directory api -are zipped, and files with the name todo.html are excluded.

-

Deprecated examples

-
  <zip zipfile="${dist}/manual.zip"
-       basedir="htdocs/manual"
-       items="*"
-  />
-

zips all files in the htdocs/manual directory in a file called manual.zip -in the ${dist} directory.

-
  <zip zipfile="${dist}/manual.zip"
-       basedir="htdocs/manual"
-       items="*"
-       ignore="mydocs, todo.html"
-  />
-

zips all files in the htdocs/manual directory in a file called manual.zip -in the ${dist} directory. Files/directories with the names mydocs -and todo.html are excluded.

- -
-

Build Events

-Ant is capable of generating build events as it performs the tasks necessary to build a project. -Listeners can be attached to ant to receive these events. This capability could be used, for example, -to connect Ant to a GUI or to integrate Ant with an IDE. - -

To use build events you need to create an ant Project object. You can then call the -addBuildListener method to add your listener to the project. Your listener must implement -the org.apache.tools.antBuildListener interface. The listener will receive BuildEvents -for the following events -

    -
  • Build started -
  • Build finished -
  • Target started -
  • Target finished -
  • Task started -
  • Task finished -
  • Message logged -
- -If you wish to attach a listener from the command line you may use the -listener option. For example -
-
ant -listener org.apache.tools.ant.XmlLogger
-
-will run ant with a listener which generates an XML representaion of the build progress. This -listener is included with ant as is the default listener which generates the logging to standard -output. - - -
-

Writing your own task

-

It is very easy to write your own task:

-
    -
  1. Create a Java class that extends org.apache.tools.ant.Task.
  2. -
  3. For each attribute, write a setter method. The setter method must be a public - void method that takes one String as an argument. The - name of the method must begin with "set", followed by the - attribute name, with the first character in uppercase, and the rest in - lowercase.
  4. -
  5. Write a public void execute method, with no arguments, that - throws a BuildException. This method implements the task - itself.
  6. -
-

It is important to know that Ant first calls the setters for the attributes -it encounters for a specific task in the buildfile, before it executes is.

-

Let's write our own task, that prints a message on the System.out stream. The -task has one attribute called "message".

-
-
package com.mydomain;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-public class MyVeryOwnTask extends Task {
-  private String msg;
-
-  // The method executing the task
-  public void execute() throws BuildException {
-    System.out.println(msg);
-  }
-
-  // The setter for the "message" attribute
-  public void setMessage(String msg) {
-    this.msg = msg;
-  }
-}
-
-

It's really this simple;-)

-

Adding your task to the system is rather simple too:

-
    -
  1. Make sure the class that implements your task is in the classpath when - starting Ant.
  2. -
  3. In your initialization target, add a taskdef task. This actually adds - your task to the system.
  4. -
  5. Use your task in the rest of the buildfile.
  6. -
-

Example

-
-
<?xml version="1.0"?>
-
-<project name="OwnTaskExample" default="main" basedir=".">
-  <target name="init">
-    <taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask"/>
-  </target>
-
-  <target name="main" depends="init">
-    <mytask message="Hello World! MyVeryOwnTask works!" />
-  </target>
-</project>
-
-
-

Another way to add a task (more permanently), is to add the task name and -implementing class name to the default.properties file in the org.apache.tools.ant.taskdefs -package. Then you can use it as if it were a built in task.

-
-

Feedback

-

To provide feedback on this software, please subscribe to the Ant Development -Mail List (ant-dev-subscribe@jakarta.apache.org)

-
-

Copyright © 2000 Apache Software Foundation. All rights -Reserved.

- -

Optional tasks

- -
-

NetRexxC

-

Description:

-

Compiles a NetRexx -source tree within the running (Ant) VM.

-

The source and destination directory will be recursively scanned for -NetRexx source files to compile. Only NetRexx files that have no corresponding -class file or where the class file is older than the java file will be compiled.

-

Files in the source tree are copied to the destination directory, -allowing support files to be located properly in the classpath. The source -files are copied because the NetRexx compiler cannot produce class files in a -specific directory via parameters

-

The directory structure of the source tree should follow the package -hierarchy.

-

It is possible to refine the set of files that are being compiled/copied. -This can be done with the includes, includesfile, excludes, excludesfile and -defaultexcludes attributes. With the includes or includesfile attribute you -specify the files you want to have included by using patterns. The -exclude or excludesfile attribute is used to specify the files you want to have -excluded. This is also done with patterns. And finally with the -defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The -patterns are relative to the srcDir directory.

- -

Parameters:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
binaryWhether literals are treated as the java binary - type rather than the NetRexx typesNo
classpathThe classpath to use during compilationNo
commentsWhether comments are passed through to the - generated java sourceNo
compactWhether error messages come out in compact or - verbose formatNo
compileWhether the NetRexx compiler should compile the - generated java codeNo
consoleWhether or not messages should be displayed on the - 'console'No
crossrefWhether variable cross references are generatedNo
decimalWhether decimal arithmetic should be used for the - NetRexx codeNo
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when - omitted.No
destDirthe destination directory into which the NetRexx - source files should be copied and then compiledYes
diagWhether diagnostic information about the compile is - generatedNo
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when - omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
explicitWhether variables must be declared explicitly - before useNo
formatWhether the generated java code is formatted nicely - or left to match NetRexx line numbers for call stack debuggingNo
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
javaWhether the generated java code is producedNo
keepSets whether the generated java source file should be kept - after compilation. The generated files will have an extension of - .java.keep, not .javaNo
logoWhether the compiler text logo is displayed when - compilingNo
replaceWhether the generated .java file should be replaced - when compilingNo
savelogWhether the compiler messages will be written to - NetRexxC.log as well as to the consoleNo
sourcedirTells the NetRexx compiler to store the class files in the - same directory as the source files. The alternative is the working - directoryNo
srcDirSet the source dir to find the source Netrexx - filesYes
strictargsTells the NetRexx compiler that method calls always - need parentheses, even if no arguments are needed, e.g. - aStringVar.getBytes vs. - aStringVar.getBytes()No
strictassignTells the NetRexx compile that assignments must - match exactly on typeNo
strictcaseSpecifies whether the NetRexx compiler should be - case sensitive or notNo
strictimportWhether classes need to be imported explicitly using an - import statement. By default the NetRexx compiler will - import certain packages automaticallyNo
strictpropsWhether local properties need to be qualified - explicitly using thisNo
strictsignalWhether the compiler should force catching of - exceptions by explicitly named typesNo
symbolsWhether debug symbols should be generated into the - class fileNo
timeAsks the NetRexx compiler to print compilation - times to the consoleNo
traceTurns on or off tracing and directs the resultant - trace outputNo
utf8Tells the NetRexx compiler that the source is in UTF8No
verboseWhether lots of warnings and error messages should - be generatedYes
-

Examples

-
-

<netrexxc srcDir="/source/project" - includes="vnr/util/*" - destDir="/source/project/build" - classpath="/source/project2/proj.jar" - comments="true" - crossref="false" replace="true" - keep="true" /> -

-
-
-

RenameExtensions

-

Description:

-

Renames files in the srcDir directory ending with the -fromExtension string so that they end with the -toExtension string. Files are only replaced if -replace is true -

-

See the section on -directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The -patterns are relative to the srcDir directory.

-

Parameters:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
defaultexcludesindicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when - omitted.No
excludescomma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when - omitted.No
excludesfilethe name of a file. Each line of this file is - taken to be an exclude patternNo
fromExtentionThe string that files must end in to be renamedYes
includescomma separated list of patterns of files that must be - included. All files are included when omitted.No
includesfilethe name of a file. Each line of this file is - taken to be an include patternNo
replaceWhether the file being renamed to should be - replaced if it already existsNo
srcDirThe starting directory for files to search inYes
toExtensionThe string that renamed files will end with on - completionYes
-

Examples

-
-

<renameext srcDir="/source/project1" - includes="**" - excludes="**/samples/*" - fromExtension=".java.keep" - toExtension=".java" - replace="true" /> - -

-
- -
-

Script

-

Description:

-

Execute a script in a - BSF supported language. -

All items (tasks, targets, etc) of the running project are accessible -from the script. -

Parameters:

- - - - - - - - - - - - - - - - -
AttributeDescriptionRequired
languageThe programming language the script is written in. - Must be a supported BSF languageNo
srcThe location of the script as a file, if not inlineNo
-

Examples

-
-

None yet available

-
- - - - - diff --git a/spec/core.html b/spec/core.html deleted file mode 100644 index 882659efc..000000000 --- a/spec/core.html +++ /dev/null @@ -1,278 +0,0 @@ - - - - Ant Specification, version 0.5 - - -

Ant Specification

-

Version 0.5 (2000/04/20)

-

This document specifies the behavior of Ant. At this time, this is a - working document with no implementation. It is hoped that this specification - will lead to a simplier and more consistent implementation of Ant.

-

This document is not intended to be used as an end user manual or user - guide to Ant. To adequatly explain the concepts herein in a way appropriate to - such a use would potentially complicate this document.

-

Design Goals

-

The following are the overall design goals of Ant:

-
    -
  • Simplicity
  • -
  • Understandability
  • -
  • Extensibility
  • -
-

Simplicity

-

Ant must be simple to use. Of course, as the definition of simple varies - according to the audience of the program. For Ant, since it is a build tool - aimed at programmers, the goal is to be simple to use for a competent - programmer.

-

Understandability

-

Ant must be clearly understandible for a first time as well as a veteran - user. This means that a new user should be able to use Ant comfortably the - first time and understand how to modify a build file by looking at it. And it - should not require much experience with Ant to understand how it works and how - to configure it for particular situtations.

-

Extensibility

-

Ant must be easy to extend. The API used to extend Ant must be easy to - use and the way in which these extensions are located and used by the core - runtime should be clear.

-

Conceptual Overview

-

This is a conceptual overview of the components used by Ant. Full APIs - will be defined later.

-

Project

-

The base unit of work in Ant is the Project. A Project - is defined by an editable text file and is represented by an object of type - org.apache.ant.Project at runtime.

-

A Project is a collection of Properties and - Targets.

-

Properties

-

Properties are mutable name-value pairs that are scoped to the Project - and held in a table. Only one pair is allowed per name. It is anticipated that - this data structure would be of type java.util.Properties or a type that has approximatly - the same contract.

-

Properties can be defined in a hierarchical manner. The order of - precidence in this hiearchy is:

-
    -
  • Properties defined on the command line or via a GUI tool
  • -
  • Properties defined in the text file which defines the project.
  • -
  • Properties defined in a file in the users user.home directory
  • -
  • Properties defined in the installation directory that can be shared - by multiple users.
  • -
-

Note: The current version of Ant allows the System property list to be - consulted for a return value if the property list doesn't satisfy the requested - property name. As all Java code has access to the system property list via the - java.lang.System class, this functionality is considered to be confusing and to be - removed.

-

Note: The current version of Ant allows property substitution to be - performed in the project file. This functionality is being removed.

-

Targets

-

Targets are ordered collections of Tasks, units of work - to be performed if a Target is executed.

-

Targets can define dependancies on other Targets within the Project. If - a Target is deemed to be executed, either directly on the command line, or via - a dependancy from some other Target, then all of its dependencies must first be - executed. Circular depenancies are resolved by examination of the dependancy - stack when a Target is evaluated. If a dependancy is already on the stack of - targets to be executed, then the dependancy is considered to have been - satisfied.

-

After all dependancies of a Target have been satisfied, all of the Tasks - contained by the target are configured and executed in sequential order.

-

Tasks

-

A Task is a unit of work. When a Task is to be executed, an instance of - the class that defines the behavior of the particular task specified is - instantiated and then configured. This class implements the org.apache.ant.Task interface. - It is then executed so that it may be able to perform its function. It is - important to note that this configuration occurs just before execution of the - task, and after execution of any previous tasks, so that configuration - information that was modified by any other Task can be properly set.

-

When a Task is executed, it is provided access to the object - representing the Project it is running in allowing it to examine the Property - list of the project and access to various methods needed to operate.

-

Task Jar Layout

-

Tasks are defined within Java Archive files. The name of the JAR - determines the name under which the task is known by in the system. For - example, if a Task JAR is named mvdir.jar, the task is known to the system as - "mvdir".

-

Question: Should we say that tasks belong in a JAR file with the - .tsk extension?

-

The class within the Jar file that implements the org.apache.ant.Task interface is - specified by a manifest attribute named Ant-Task-Class in the Jar manifest. An example - manifest would look like:

-
    Manifest-Version: 1.0
-    Ant-Task-Class: org.apache.ant.task.javac.JavacTask
-

When the task is used by Ant, a class loader is created that reads - classes from the JAR file. This ensures that there is no chance of namespace - collision in the classes of various task JAR files.

-

Installation

-

When Ant is installed on a user system, it installs a directory - structure with the following form:

-
<installdir>/ant      (unix shell script)
-            /ant.bat
-            /ant.jar
-            /ant.properties
-            /tasks/[task jar files]
-            /docs/[documentation]
-            /README
-

Note: Current Jakarta practice is to name the Unix shell script with a - .sh extension. This goes against Unix conventions and is unecessary. Testing - has shown that the leaving the extension off on Unix will not interfere with - the working of the Windows batch file.

-

Note: The ant.jar file has been moved from the lib/ directory and placed - alongside the shell startup scripts (which have also been moved out of the bin/ - directory). This is because on windows platforms, the .jar file is an - executable file of sorts.

-

Ant Properties

-

The ant.properties file contains a list of all the properties that should be - set by default when ant is run. In addition there are a few special properties - that are used directly by ant. An example of these properties in use is:

-
    system.taskdir=tasks/
-    user.taskdir=anttasks/
-

The system.taskdir property sets where the system looks for Java ARchive files - containing tasks. If this property defines a relative path, then the path is - taken as relative from the installation directory.

-

The user.taskdir property defines where users can locate Java Archive files - containing tasks. If this property defines a realtive path, then the path is - taken as relative from the users home directory (as defined by the user.home - system property). Task JAR files in this directory take precendence of those in - the system directory.

-

Note: It has been suggested to add a properties file hook to the - command line to roll in props. Pending investigation.

-

User Preferences

-

In addition to the Ant installation directory, an ant.properties file can be - located in the user's home directory (as found by the system property user.home) - which can define user preferences such as the location of a user tasks - directory. Properties defined in this file take precidence over those set in - the installation's ant.properties file. Such a file could look like:

-
    user.taskdir=anttasks/
-    javac.debug=off
-

Properties starting with "system." in the user's ant.properties file are not - allowed and must cause a warning to be thrown.

-

Project Configuration

-

Ant's Project text file is structured using XML and reflects the - structure of the various components described in the Conceptual Overview.

-

A sample Project file:

-
<project name="projectname" defaulttarget="main" taskdir="tasks/">
-  <property name="javac.debug" value="on"/>
-  <target name="main">
-    <taskimpl ...>
-       ...
-    </taskimpl>
-  </target>
-</project>
-

The Project Element

-

The project element has the following required attributes:

-
    -
  • defaulttarget defining the default target to be executed if no other target - is specified when Ant is run
  • -
-

It also has the following optional allowed attributes:

-
    -
  • name defining a name for this project
  • -
  • taskdir defining a directory in which project specific tasks can be - located. Tasks in this directory take precedence over those in the either the - user taskdir or the installation taskdir.
  • -
-

The following elements are allowed as children of the project - element:

-
    -
  • property defining a property scoped to the project
  • -
  • target defining a target
  • -
-

The Property Element

-

asdf

-

The Target Element

-

asfd

-

Configuration of Tasks

-

The Task section of the configuration file is structured as such:

-
  <[taskname] [attname=value] [attname=value]...]>
-    [<[elementname] [attname=value] ...> ... </[elementname]>]
-  </[taskname]>
-

The taskname is used to find the class of the Task. Once the class has - been located and an instance of it created, all of the attributes of the Task - are reflected into the task instance using bean patterns. For example, if a - Task contains an attribute named "directory", the method named - setDirectory would be called with the attribute value cast to the appropriate - type desired by the method. (What to do if the type isn't a file or a - simple type, look for the class and see if it has a setString method?)

- -

Text blocks contained by the element are added to task using an addText - method. Place an example...

-

For each element contained in the Task definition, an addElementname - method is found on the task. The parameter type of the method defines an object - that will be loaded and instantiated. The attributes of the element are - reflected into the object using bean methods. Any text is set using the addText - method. Any elements are recursed in the same fashion.

-

Search order of tasks.... project/user/system

-

Command Line

-

The command line utility provided with Ant must support the following - allowable syntax:

-

ant projectfile [prop=value [prop=value...]] [target]

-

Internally, the command line shell scripts should call the org.apache.ant.Main class - with the following arguments:

-
java -Dant.home=installdir org.apache.ant.Main $*
-

or its equivalent on the host platform. Note that the ant installation - directory is a System property. The above syntax results in ant.home being - placed in the System property list.

-

Note: On unix, finding the directory of the script that was launched - is relatively easy. However on Windows, I'm not sure the best way of handling - this.

-

File Naming Conventions

-

File naming in a cross platform tool is tricky. For maximum portability - and understandiblity it is recommended that project files use the following - conventions:

-
    -
  • The '/' character is used as a directory seperator
  • -
  • The ':' character is used as a path seperator
  • -
  • Only relative paths are used
  • -
-

However, to allow for maximum flexibility and to allow project authors - to use conventions that make sense on their native platform, Ant allows for a - representation of file names which has the following rules:

-
    -
  • Directories are seperated by the forward slash ('/') or backwards - slash ('\') character.
  • -
  • File names starting with either of the above directory seperators are - considered to be absolute paths.
  • -
  • On systems that support multiple file roots (e.g. Windows), a file - name that starts with a single alphabetical character followed by a colon (':') - followed by a directory seperator defines an absolute path where the letter - corresponds with a directory root.
  • -
  • File names starting with any other character are considered to be - relative paths. In project files, all relative paths are resolved relative to - the directory in which the project file is located.
  • -
-

Absolute paths are not recommended for build files as they reduce the - ability to share a project between u sers or machines.

-

In situtations where a set of filenames need to be specified, such as - defining a classpath, both the colon (':') andsemicolon (';') are allowable - characters to seperate each filename. The only case that has to be - disambiguated is if a user specifies paths that contain windows style absolute - paths. In this case, the colon is not treated as a path seperator if the - following rules are met:

-
    -
  • The character two places before the colon is either of the allowable - path seperators (':' or ';') or if the colon is the second character of the - string.
  • -
  • The character immediately before the colon is a alphabetic character - in the range a-z or A-Z.
  • -
  • The character immediately after the colon is either of the allowable - directory seperators ('/' or '\').
  • -
-

Scripting Model

-

Sam, I'm leaving this to you.

-

Runtime Requirements

-

The following requirements are system requirements that Ant should have - in order to run correctly. We should not bundle in any of these into the - distribution of ant.

-
    -
  • JDK 1.1 or greater
  • -
  • A JAXP compliant parser on the classpath
  • -
-

Note: When running on JDK 1.2 or greater, the tools.jar isn't on the - classpath by default. There's a few different ways we can take care of this. - One is to put it on the classpath in the execute script (I don't like this - one). Another is to find the location of tools.jar at runtime and put it on the - classpath of class loaders that load in task.jars so that, at least in the - scope of the Tasks, the relevant classes are there.

-

-

- diff --git a/src/bin/ant b/src/bin/ant deleted file mode 100644 index ab91889d3..000000000 --- a/src/bin/ant +++ /dev/null @@ -1,52 +0,0 @@ -#! /bin/sh - -if [ -f $HOME/.antrc ] ; then - . $HOME/.antrc -fi - -if [ "$ANT_HOME" = "" ] ; then - # try to find ANT - if [ -d /opt/ant ] ; then - ANT_HOME=/opt/ant - fi - - if [ -d ${HOME}/opt/ant ] ; then - ANT_HOME=${HOME}/opt/ant - fi - - ## resolve links - $0 may be a link to ant's home - PRG=$0 - progname=`basename $0` - - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '.*/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname $PRG`/$link" - fi - done - - ANT_HOME=`dirname "$PRG"`/.. - -fi - -# Allow .antrc to specifiy flags to java cmd -if [ "$JAVACMD" = "" ] ; then - JAVACMD=java -fi - -# Use the original tools.jar if available -if [ ! "$JAVA_HOME" = "" ] ; then - CLASSPATH=${JAVA_HOME}/lib/tools.jar:$CLASSPATH - CLASSPATH=${JAVA_HOME}/lib/classes.zip:$CLASSPATH -fi - - -CLASSPATH=${ANT_HOME}/lib/xml.jar:$CLASSPATH -CLASSPATH=${ANT_HOME}/lib/ant.jar:$CLASSPATH -CLASSPATH=${ANT_HOME}/lib/moo.jar:$CLASSPATH -export CLASSPATH - -$JAVACMD -Dant.home=${ANT_HOME} org.apache.tools.ant.Main $@ diff --git a/src/bin/ant.bat b/src/bin/ant.bat deleted file mode 100755 index de92c9031..000000000 --- a/src/bin/ant.bat +++ /dev/null @@ -1,33 +0,0 @@ -@echo off -@setlocal -if "%ANT_HOME%"=="" goto checkProgFiles -goto checkJava - -:checkProgFiles -rem check for ant on system drive -if not exist "%SystemDrive%\Program Files\ant" goto checkSystemDrive - -set ANT_HOME=%SystemDrive%\Program Files\ant -goto checkJava - -:checkSystemDrive -if not exist "%SystemDrive%\ant" goto noAntHome -set ANT_HOME=%SystemDrive%\ant -goto checkJava - -:noAntHome -echo ANT_HOME is not set and ant could not be located -goto end - -:checkJava -if "%JAVACMD%" == "" set JAVACMD=java - -if "%JAVA_HOME%" == "" goto runAnt -set CLASSPATH=%JAVA_HOME%\lib\tools.jar;%CLASSPATH% - -:runAnt -set CLASSPATH=%ANT_HOME%\lib\ant.jar;%ANT_HOME%\lib\xml.jar;%CLASSPATH% -%JAVACMD% -Dant.home="%ANT_HOME%" org.apache.tools.ant.Main %1 %2 %3 %4 %5 %6 %7 %8 %9 - -:end -@endlocal diff --git a/src/bin/antRun b/src/bin/antRun deleted file mode 100644 index 4c38b1803..000000000 --- a/src/bin/antRun +++ /dev/null @@ -1,13 +0,0 @@ -#! /bin/sh - -# Args: DIR command -cd $1 -CMD=$2 -shift -shift - -if test -f $CMD.sh; then - CMD="sh $CMD.sh" -fi - -echo $CMD $@ | sh diff --git a/src/etc/ant.spec b/src/etc/ant.spec deleted file mode 100644 index 7bd0c8c2e..000000000 --- a/src/etc/ant.spec +++ /dev/null @@ -1,52 +0,0 @@ -Summary: Java build tool -Name: ant -Version: 1.0 -Release: 0 -Group: Development/Tools -Copyright: Apache - free -Provides: ant -Url: http://jakarta.apache.org - -Source: http://jakarta.apache.org/builds/nightly/ant/jakarta-tools.src.zip -Prefix: /opt - -%description -Platform-independent build tool for java. - -%prep -rm -rf ${RPM_BUILD_DIR}/jakarta-tools -unzip -x $RPM_SOURCE_DIR/jakarta-tools.src.zip - -%build -cd ${RPM_BUILD_DIR}/jakarta-tools -cd ant -sh bootstrap.sh -sh build.sh - -%install -cd ${RPM_BUILD_DIR}/jakarta-tools -cd ant -sh build.sh -Ddist.dir /opt dist - -%clean - -%post -ln -s /opt/ant/bin/ant /usr/bin - -%preun - -%files -## %defattr(-,root,root) -%dir /opt/ant -%dir /opt/ant/bin -%dir /opt/ant/lib -%dir /opt/ant/docs -/opt/ant/lib/ant.jar -/opt/ant/lib/xml.jar -/opt/ant/lib/moo.jar -%config /opt/ant/lib/build.xml -/opt/ant/bin/ant -/opt/ant/bin/antRun -/opt/ant/docs/index.html - -%changelog diff --git a/src/etc/log.xsl b/src/etc/log.xsl deleted file mode 100644 index 4b4407e3c..000000000 --- a/src/etc/log.xsl +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - - - - - - - - - - -
- - - - - - - - - -
Build FailedBuild CompleteTotal Time:
- -
- - -
- -
- -
- - - - -
-
- - - color: - - red - brown - gray - gray - - -
- - -
- -
\ No newline at end of file diff --git a/src/etc/manifest b/src/etc/manifest deleted file mode 100644 index 758bc0f0d..000000000 --- a/src/etc/manifest +++ /dev/null @@ -1,4 +0,0 @@ -Manifest-Version: 1.0 -Main-Class: org.apache.tools.ant.Main - - diff --git a/src/etc/pkginfo b/src/etc/pkginfo deleted file mode 100644 index cad292582..000000000 --- a/src/etc/pkginfo +++ /dev/null @@ -1,9 +0,0 @@ -PKG="ASFant" -NAME="Apache Ant build tool" -VERSION="1.0" -ARCH="sparc i386" -CLASSES="none" -CATEGORY="utility" -VENDOR="Apache" -EMAIL="costin@eng.sun.com" -BASEDIR=/ diff --git a/src/etc/prototype b/src/etc/prototype deleted file mode 100644 index abd374b7e..000000000 --- a/src/etc/prototype +++ /dev/null @@ -1,12 +0,0 @@ -i pkginfo -d none /opt/ant 0755 costin other -d none /opt/ant/lib 0755 costin staff -f none /opt/ant/lib/ant.jar 0644 costin staff -f none /opt/ant/lib/xml.jar 0644 costin staff -f none /opt/ant/lib/moo.jar 0644 costin staff -f none /opt/ant/lib/build.xml 0644 costin staff -d none /opt/ant/bin 0755 costin staff -f none /opt/ant/bin/ant 0755 costin staff -f none /opt/ant/bin/antRun 0755 costin staff -d none /opt/ant/docs 0755 costin staff -f none /opt/ant/docs/index.html 0644 costin staff diff --git a/src/main/org/apache/tools/ant/BuildEvent.java b/src/main/org/apache/tools/ant/BuildEvent.java deleted file mode 100644 index 4f58fee20..000000000 --- a/src/main/org/apache/tools/ant/BuildEvent.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.util.EventObject; - -public class BuildEvent extends EventObject { - private Project project; - private Target target; - private Task task; - private String message; - private int priority; - private Throwable exception; - - /** - * Constructs a new build event. Fields that are not relevant - * can be set to null, except for the project field which is - * required. - */ - public BuildEvent( - Project project, - Target target, - Task task, - String message, - int priority, - Throwable exception) { - - super(getSource(project, target, task)); - - this.project = project; - this.target = target; - this.task = task; - this.message = message; - this.priority = priority; - this.exception = exception; - } - - /** - * Returns the project that fired this event. - */ - public Project getProject() { - return project; - } - - /** - * Returns the target that fired this event. - */ - public Target getTarget() { - return target; - } - - /** - * Returns the task that fired this event. - */ - public Task getTask() { - return task; - } - - /** - * Returns the logging message. This field will only be set - * for "messageLogged" events. - * - * @see BuildListener#messageLogged(BuildEvent) - */ - public String getMessage() { - return message; - } - - /** - * Returns the priority of the logging message. This field will only - * be set for "messageLogged" events. - * - * @see BuildListener#messageLogged(BuildEvent) - */ - public int getPriority(){ - return priority; - } - - /** - * Returns the exception that was thrown, if any. This field will only - * be set for "taskFinished", "targetFinished", and "buildFinished" events. - * - * @see BuildListener#taskFinished(BuildEvent) - * @see BuildListener#targetFinished(BuildEvent) - * @see BuildListener#buildFinished(BuildEvent) - */ - public Throwable getException() { - return exception; - } - - /** - * Returns the object that fired this event. - */ - private static Object getSource(Project project, Target target, Task task) { - if (task != null) return task; - if (target != null) return target; - if (project != null) return project; - - throw new IllegalArgumentException("Project field cannot be null"); - } -} \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/BuildException.java b/src/main/org/apache/tools/ant/BuildException.java deleted file mode 100644 index ee74c0d0b..000000000 --- a/src/main/org/apache/tools/ant/BuildException.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -/** - * Signals an error condition during a build. - * - * @author James Duncan Davidson - */ - -public class BuildException extends RuntimeException { - - /** Exception that might have caused this one. */ - private Throwable cause; - - /** Location in the build file where the exception occured */ - private Location location = Location.UNKNOWN_LOCATION; - - /** - * Constructs a build exception with no descriptive information. - */ - - public BuildException() { - super(); - } - - /** - * Constructs an exception with the given descriptive message. - * @param msg Description of or information about the exception. - */ - - public BuildException(String msg) { - super(msg); - } - - /** - * Constructs an exception with the given message and exception as - * a root cause. - * @param msg Description of or information about the exception. - * @param cause Throwable that might have cause this one. - */ - - public BuildException(String msg, Throwable cause) { - super(msg); - this.cause = cause; - } - - /** - * Constructs an exception with the given message and exception as - * a root cause and a location in a file. - * @param msg Description of or information about the exception. - * @param cause Exception that might have cause this one. - * @param location Location in the project file where the error occured. - */ - - public BuildException(String msg, Throwable cause, Location location) { - this(msg, cause); - this.location = location; - } - - /** - * Constructs an exception with the given exception as a root cause. - * @param cause Exception that might have caused this one. - */ - - public BuildException(Throwable cause) { - super(cause.toString()); - this.cause = cause; - } - - /** - * Constructs an exception with the given descriptive message and a location - * in a file. - * @param msg Description of or information about the exception. - * @param location Location in the project file where the error occured. - */ - - public BuildException(String msg, Location location) { - super(msg); - this.location = location; - } - - /** - * Returns the nested exception. - */ - public Throwable getException() { - return cause; - } - - /** - * Returns the location of the error and the error message. - */ - public String toString() { - return location.toString() + getMessage(); - } - - /** - * Sets the file location where the error occured. - */ - public void setLocation(Location location) { - this.location = location; - } -} diff --git a/src/main/org/apache/tools/ant/BuildListener.java b/src/main/org/apache/tools/ant/BuildListener.java deleted file mode 100644 index a560147eb..000000000 --- a/src/main/org/apache/tools/ant/BuildListener.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.util.EventListener; - -/** - * Classes that implement this interface will be notified when - * things happend during a build. - * - * @see BuildEvent - * @see Project#addBuildListener(BuildListener) - */ -public interface BuildListener extends EventListener { - - /** - * Fired before any targets are started. - */ - public void buildStarted(BuildEvent event); - - /** - * Fired after the last target has finished. This event - * will still be thrown if an error occured during the build. - * - * @see BuildEvent#getException() - */ - public void buildFinished(BuildEvent event); - - /** - * Fired when a target is started. - * - * @see BuildEvent#getTarget() - */ - public void targetStarted(BuildEvent event); - - /** - * Fired when a target has finished. This event will - * still be thrown if an error occured during the build. - * - * @see BuildEvent#getException() - */ - public void targetFinished(BuildEvent event); - - /** - * Fired when a task is started. - * - * @see BuildEvent#getTask() - */ - public void taskStarted(BuildEvent event); - - /** - * Fired when a task has finished. This event will still - * be throw if an error occured during the build. - * - * @see BuildEvent#getException() - */ - public void taskFinished(BuildEvent event); - - /** - * Fired whenever a message is logged. - * - * @see BuildEvent#getMessage() - * @see BuildEvent#getPriority() - */ - public void messageLogged(BuildEvent event); - -} \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/DefaultLogger.java b/src/main/org/apache/tools/ant/DefaultLogger.java deleted file mode 100644 index bdcb22b1e..000000000 --- a/src/main/org/apache/tools/ant/DefaultLogger.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.io.*; - -/** - * Writes build event to a PrintStream. Currently, it - * only writes which targets are being executed, and - * any messages that get logged. - */ -public class DefaultLogger implements BuildListener { - private PrintStream out; - private int msgOutputLevel; - - /** - * Constructs a new logger which will write to the specified - * PrintStream. Messages with a priority lower (higher?) than - * msgOutputLevel will be ignored. - */ - public DefaultLogger(PrintStream out, int msgOutputLevel) { - this.out = out; - this.msgOutputLevel = msgOutputLevel; - } - - public void buildStarted(BuildEvent event) {} - public void buildFinished(BuildEvent event) {} - - public void targetStarted(BuildEvent event) { - if (msgOutputLevel <= Project.MSG_INFO) { - out.println("Executing Target: " + event.getTarget().getName()); - } - } - - public void targetFinished(BuildEvent event) {} - - public void taskStarted(BuildEvent event) {} - public void taskFinished(BuildEvent event) {} - - public void messageLogged(BuildEvent event) { - - // Filter out messages based on priority - if (event.getPriority() <= msgOutputLevel) { - - // Print out the name of the task if we're in one - if (event.getTask() != null) { - String name = event.getTask().getClass().getName(); - int pos = name.lastIndexOf("."); - if (pos != -1) { - name = name.substring(pos + 1); - } - out.print("[" + name + "] "); - } - - // Print the message - out.println(event.getMessage()); - } - } -} \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/DesirableFilter.java b/src/main/org/apache/tools/ant/DesirableFilter.java deleted file mode 100644 index 0bd564125..000000000 --- a/src/main/org/apache/tools/ant/DesirableFilter.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.io.File; -import java.io.IOException; -import java.io.FilenameFilter; - -/** - * Filters filenames to determine whether or not the file is desirable. - * - * @author Jason Hunter [jhunter@servlets.com] - * @author james@x180.com - */ - -public class DesirableFilter implements FilenameFilter { - - /** - * Test the given filename to determine whether or not it's desirable. - * This helps tasks filter temp files and files used by CVS. - */ - - public boolean accept(File dir, String name) { - - // emacs save file - if (name.endsWith("~")) { - return false; - } - - // emacs autosave file - if (name.startsWith("#") && name.endsWith("#")) { - return false; - } - - // openwindows text editor does this I think - if (name.startsWith("%") && name.endsWith("%")) { - return false; - } - - /* CVS stuff -- hopefully there won't be a case with - * an all cap file/dir named "CVS" that somebody wants - * to keep around... - */ - - if (name.equals("CVS")) { - return false; - } - - /* If we are going to ignore CVS might as well ignore - * this one as well... - */ - if (name.equals(".cvsignore")){ - return false; - } - - // default - return true; - } -} - - - - - - - diff --git a/src/main/org/apache/tools/ant/DirectoryScanner.java b/src/main/org/apache/tools/ant/DirectoryScanner.java deleted file mode 100644 index e3941f840..000000000 --- a/src/main/org/apache/tools/ant/DirectoryScanner.java +++ /dev/null @@ -1,827 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.io.*; -import java.util.*; - -/** - * Class for scanning a directory for files/directories that match a certain - * criteria. - *

- * These criteria consist of a set of include and exclude patterns. With these - * patterns, you can select which files you want to have included, and which - * files you want to have excluded. - *

- * The idea is simple. A given directory is recursively scanned for all files - * and directories. Each file/directory is matched against a set of include - * and exclude patterns. Only files/directories that match at least one - * pattern of the include pattern list, and don't match a pattern of the - * exclude pattern list will be placed in the list of files/directories found. - *

- * When no list of include patterns is supplied, "**" will be used, which - * means that everything will be matched. When no list of exclude patterns is - * supplied, an empty list is used, such that nothing will be excluded. - *

- * The pattern matching is done as follows: - * The name to be matched is split up in path segments. A path segment is the - * name of a directory or file, which is bounded by - * File.separator ('/' under UNIX, '\' under Windows). - * E.g. "abc/def/ghi/xyz.java" is split up in the segments "abc", "def", "ghi" - * and "xyz.java". - * The same is done for the pattern against which should be matched. - *

- * Then the segments of the name and the pattern will be matched against each - * other. When '**' is used for a path segment in the pattern, then it matches - * zero or more path segments of the name. - *

- * There are special case regarding the use of File.separators at - * the beginningof the pattern and the string to match:
- * When a pattern starts with a File.separator, the string - * to match must also start with a File.separator. - * When a pattern does not start with a File.separator, the - * string to match may not start with a File.separator. - * When one of these rules is not obeyed, the string will not - * match. - *

- * When a name path segment is matched against a pattern path segment, the - * following special characters can be used: - * '*' matches zero or more characters, - * '?' matches one character. - *

- * Examples: - *

- * "**\*.class" matches all .class files/dirs in a directory tree. - *

- * "test\a??.java" matches all files/dirs which start with an 'a', then two - * more characters and then ".java", in a directory called test. - *

- * "**" matches everything in a directory tree. - *

- * "**\test\**\XYZ*" matches all files/dirs that start with "XYZ" and where - * there is a parent directory called test (e.g. "abc\test\def\ghi\XYZ123"). - *

- * Example of usage: - *

- *   String[] includes = {"**\\*.class"};
- *   String[] excludes = {"modules\\*\\**"};
- *   ds.setIncludes(includes);
- *   ds.setExcludes(excludes);
- *   ds.setBasedir(new File("test"));
- *   ds.scan();
- *
- *   System.out.println("FILES:");
- *   String[] files = ds.getIncludedFiles();
- *   for (int i = 0; i < files.length;i++) {
- *     System.out.println(files[i]);
- *   }
- * 
- * This will scan a directory called test for .class files, but excludes all - * .class files in all directories under a directory called "modules" - * - * @author Arnout J. Kuiper ajkuiper@wxs.nl - */ -public class DirectoryScanner { - - /** - * Patterns that should be excluded by default. - * - * @see #addDefaultExcludes() - */ - private final static String[] DEFAULTEXCLUDES = { - "**/*~", - "**/#*#", - "**/%*%", - "**/CVS", - "**/CVS/*", - "**/.cvsignore" - }; - - /** - * The base directory which should be scanned. - */ - private File basedir; - - /** - * The patterns for the files that should be included. - */ - private String[] includes; - - /** - * The patterns for the files that should be excluded. - */ - private String[] excludes; - - /** - * The files that where found and matched at least one includes, and matched - * no excludes. - */ - private Vector filesIncluded; - - /** - * The files that where found and did not match any includes. - */ - private Vector filesNotIncluded; - - /** - * The files that where found and matched at least one includes, and also - * matched at least one excludes. - */ - private Vector filesExcluded; - - /** - * The directories that where found and matched at least one includes, and - * matched no excludes. - */ - private Vector dirsIncluded; - - /** - * The directories that where found and did not match any includes. - */ - private Vector dirsNotIncluded; - - /** - * The files that where found and matched at least one includes, and also - * matched at least one excludes. - */ - private Vector dirsExcluded; - - - - /** - * Constructor. - */ - public DirectoryScanner() { - } - - - - /** - * Matches a path against a pattern. - * - * @param pattern the (non-null) pattern to match against - * @param str the (non-null) string (path) to match - * - * @return true when the pattern matches against the string. - * false otherwise. - */ - private static boolean matchPath(String pattern, String str) { - // When str starts with a File.separator, pattern has to start with a - // File.separator. - // When pattern starts with a File.separator, str has to start with a - // File.separator. - if (str.startsWith(File.separator) != - pattern.startsWith(File.separator)) { - return false; - } - - Vector patDirs = new Vector(); - StringTokenizer st = new StringTokenizer(pattern,File.separator); - while (st.hasMoreTokens()) { - patDirs.addElement(st.nextToken()); - } - - Vector strDirs = new Vector(); - st = new StringTokenizer(str,File.separator); - while (st.hasMoreTokens()) { - strDirs.addElement(st.nextToken()); - } - - int patIdxStart = 0; - int patIdxEnd = patDirs.size()-1; - int strIdxStart = 0; - int strIdxEnd = strDirs.size()-1; - - // up to first '**' - while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { - String patDir = (String)patDirs.elementAt(patIdxStart); - if (patDir.equals("**")) { - break; - } - if (!match(patDir,(String)strDirs.elementAt(strIdxStart))) { - return false; - } - patIdxStart++; - strIdxStart++; - } - if (strIdxStart > strIdxEnd) { - // String is exhausted - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (!patDirs.elementAt(i).equals("**")) { - return false; - } - } - return true; - } else { - if (patIdxStart > patIdxEnd) { - // String not exhausted, but pattern is. Failure. - return false; - } - } - - // up to last '**' - while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) { - String patDir = (String)patDirs.elementAt(patIdxEnd); - if (patDir.equals("**")) { - break; - } - if (!match(patDir,(String)strDirs.elementAt(strIdxEnd))) { - return false; - } - patIdxEnd--; - strIdxEnd--; - } - if (strIdxStart > strIdxEnd) { - // String is exhausted - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (!patDirs.elementAt(i).equals("**")) { - return false; - } - } - return true; - } - - while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { - int patIdxTmp = -1; - for (int i = patIdxStart+1; i <= patIdxEnd; i++) { - if (patDirs.elementAt(i).equals("**")) { - patIdxTmp = i; - break; - } - } - if (patIdxTmp == patIdxStart+1) { - // '**/**' situation, so skip one - patIdxStart++; - continue; - } - // Find the pattern between padIdxStart & padIdxTmp in str between - // strIdxStart & strIdxEnd - int patLength = (patIdxTmp-patIdxStart-1); - int strLength = (strIdxEnd-strIdxStart+1); - int foundIdx = -1; -strLoop: - for (int i = 0; i <= strLength - patLength; i++) { - for (int j = 0; j < patLength; j++) { - String subPat = (String)patDirs.elementAt(patIdxStart+j+1); - String subStr = (String)strDirs.elementAt(strIdxStart+i+j); - if (!match(subPat,subStr)) { - continue strLoop; - } - } - - foundIdx = strIdxStart+i; - break; - } - - if (foundIdx == -1) { - return false; - } - - patIdxStart = patIdxTmp; - strIdxStart = foundIdx+patLength; - } - - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (!patDirs.elementAt(i).equals("**")) { - return false; - } - } - - return true; - } - - - - /** - * Matches a string against a pattern. The pattern contains two special - * characters: - * '*' which means zero or more characters, - * '?' which means one and only one character. - * - * @param pattern the (non-null) pattern to match against - * @param str the (non-null) string that must be matched against the - * pattern - * - * @return true when the string matches against the pattern, - * false otherwise. - */ - private static boolean match(String pattern, String str) { - char[] patArr = pattern.toCharArray(); - char[] strArr = str.toCharArray(); - int patIdxStart = 0; - int patIdxEnd = patArr.length-1; - int strIdxStart = 0; - int strIdxEnd = strArr.length-1; - char ch; - - boolean containsStar = false; - for (int i = 0; i < patArr.length; i++) { - if (patArr[i] == '*') { - containsStar = true; - break; - } - } - - if (!containsStar) { - // No '*'s, so we make a shortcut - if (patIdxEnd != strIdxEnd) { - return false; // Pattern and string do not have the same size - } - for (int i = 0; i <= patIdxEnd; i++) { - ch = patArr[i]; - if (ch != '?' && ch != strArr[i]) { - return false; // Character mismatch - } - } - return true; // String matches against pattern - } - - if (patIdxEnd == 0) { - return true; // Pattern contains only '*', which matches anything - } - - // Process characters before first star - while((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) { - if (ch != '?' && ch != strArr[strIdxStart]) { - return false; - } - patIdxStart++; - strIdxStart++; - } - if (strIdxStart > strIdxEnd) { - // All characters in the string are used. Check if only '*'s are - // left in the pattern. If so, we succeeded. Otherwise failure. - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (patArr[i] != '*') { - return false; - } - } - return true; - } - - // Process characters after last star - while((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) { - if (ch != '?' && ch != strArr[strIdxEnd]) { - return false; - } - patIdxEnd--; - strIdxEnd--; - } - if (strIdxStart > strIdxEnd) { - // All characters in the string are used. Check if only '*'s are - // left in the pattern. If so, we succeeded. Otherwise failure. - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (patArr[i] != '*') { - return false; - } - } - return true; - } - - // process pattern between stars. padIdxStart and patIdxEnd point - // always to a '*'. - while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) { - int patIdxTmp = -1; - for (int i = patIdxStart+1; i <= patIdxEnd; i++) { - if (patArr[i] == '*') { - patIdxTmp = i; - break; - } - } - if (patIdxTmp == patIdxStart+1) { - // Two stars next to each other, skip the first one. - patIdxStart++; - continue; - } - // Find the pattern between padIdxStart & padIdxTmp in str between - // strIdxStart & strIdxEnd - int patLength = (patIdxTmp-patIdxStart-1); - int strLength = (strIdxEnd-strIdxStart+1); - int foundIdx = -1; -strLoop: - for (int i = 0; i <= strLength - patLength; i++) { - for (int j = 0; j < patLength; j++) { - ch = patArr[patIdxStart+j+1]; - if (ch != '?' && ch != strArr[strIdxStart+i+j]) { - continue strLoop; - } - } - - foundIdx = strIdxStart+i; - break; - } - - if (foundIdx == -1) { - return false; - } - - patIdxStart = patIdxTmp; - strIdxStart = foundIdx+patLength; - } - - // All characters in the string are used. Check if only '*'s are left - // in the pattern. If so, we succeeded. Otherwise failure. - for (int i = patIdxStart; i <= patIdxEnd; i++) { - if (patArr[i] != '*') { - return false; - } - } - return true; - } - - - - /** - * Sets the basedir for scanning. This is the directory that is scanned - * recursively. All '/' and '\' characters are replaced by - * File.separatorChar. So the separator used need not match - * File.separatorChar. - * - * @param basedir the (non-null) basedir for scanning - */ - public void setBasedir(String basedir) { - setBasedir(new File(basedir.replace('/',File.separatorChar).replace('\\',File.separatorChar))); - } - - - - /** - * Sets the basedir for scanning. This is the directory that is scanned - * recursively. - * - * @param basedir the basedir for scanning - */ - public void setBasedir(File basedir) { - this.basedir = basedir; - } - - - - /** - * Gets the basedir that is used for scanning. This is the directory that - * is scanned recursively. - * - * @return the basedir that is used for scanning - */ - public File getBasedir() { - return basedir; - } - - - - /** - * Sets the set of include patterns to use. All '/' and '\' characters are - * replaced by File.separatorChar. So the separator used need - * not match File.separatorChar. - *

- * When a pattern ends with a '/' or '\', "**" is appended. - * - * @param includes list of include patterns - */ - public void setIncludes(String[] includes) { - if (includes == null) { - this.includes = null; - } else { - this.includes = new String[includes.length]; - for (int i = 0; i < includes.length; i++) { - String pattern; - pattern = includes[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); - if (pattern.endsWith(File.separator)) { - pattern += "**"; - } - this.includes[i] = pattern; - } - } - } - - - - /** - * Sets the set of exclude patterns to use. All '/' and '\' characters are - * replaced by File.separatorChar. So the separator used need - * not match File.separatorChar. - *

- * When a pattern ends with a '/' or '\', "**" is appended. - * - * @param excludes list of exclude patterns - */ - public void setExcludes(String[] excludes) { - if (excludes == null) { - this.excludes = null; - } else { - this.excludes = new String[excludes.length]; - for (int i = 0; i < excludes.length; i++) { - String pattern; - pattern = excludes[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); - if (pattern.endsWith(File.separator)) { - pattern += "**"; - } - this.excludes[i] = pattern; - } - } - } - - - - /** - * Scans the base directory for files that match at least one include - * pattern, and don't match any exclude patterns. - * - * @exception IllegalStateException when basedir was set incorrecly - */ - public void scan() { - if (basedir == null) { - throw new IllegalStateException("No basedir set"); - } - if (!basedir.exists()) { - throw new IllegalStateException("basedir does not exist"); - } - if (!basedir.isDirectory()) { - throw new IllegalStateException("basedir is not a directory"); - } - - if (includes == null) { - // No includes supplied, so set it to 'matches all' - includes = new String[1]; - includes[0] = "**"; - } - if (excludes == null) { - excludes = new String[0]; - } - - filesIncluded = new Vector(); - filesNotIncluded = new Vector(); - filesExcluded = new Vector(); - dirsIncluded = new Vector(); - dirsNotIncluded = new Vector(); - dirsExcluded = new Vector(); - - scandir(basedir,""); - } - - - - /** - * Scans the passed dir for files and directories. Found files and - * directories are placed in their respective collections, based on the - * matching of includes and excludes. When a directory is found, it is - * scanned recursively. - * - * @param dir the directory to scan - * @param vpath the path relative to the basedir (needed to prevent - * problems with an absolute path when using dir) - * - * @see #filesIncluded - * @see #filesNotIncluded - * @see #filesExcluded - * @see #dirsIncluded - * @see #dirsNotIncluded - * @see #dirsExcluded - */ - private void scandir(File dir, String vpath) { - String[] newfiles = dir.list(); - for (int i = 0; i < newfiles.length; i++) { - String name = vpath+newfiles[i]; - File file = new File(dir,newfiles[i]); - if (file.isDirectory()) { - if (isIncluded(name)) { - if (!isExcluded(name)) { - dirsIncluded.addElement(name); - } else { - dirsExcluded.addElement(name); - } - } else { - dirsNotIncluded.addElement(name); - } - scandir(file, name+File.separator); - } else if (file.isFile()) { - if (isIncluded(name)) { - if (!isExcluded(name)) { - filesIncluded.addElement(name); - } else { - filesExcluded.addElement(name); - } - } else { - filesNotIncluded.addElement(name); - } - } - } - } - - - - /** - * Tests whether a name matches against at least one include pattern. - * - * @param name the name to match - * @return true when the name matches against at least one - * include pattern, false otherwise. - */ - private boolean isIncluded(String name) { - for (int i = 0; i < includes.length; i++) { - if (matchPath(includes[i],name)) { - return true; - } - } - return false; - } - - - - /** - * Tests whether a name matches against at least one exclude pattern. - * - * @param name the name to match - * @return true when the name matches against at least one - * exclude pattern, false otherwise. - */ - private boolean isExcluded(String name) { - for (int i = 0; i < excludes.length; i++) { - if (matchPath(excludes[i],name)) { - return true; - } - } - return false; - } - - - - /** - * Get the names of the files that matched at least one of the include - * patterns, an matched none of the exclude patterns. - * The names are relative to the basedir. - * - * @return the names of the files - */ - public String[] getIncludedFiles() { - int count = filesIncluded.size(); - String[] files = new String[count]; - for (int i = 0; i < count; i++) { - files[i] = (String)filesIncluded.elementAt(i); - } - return files; - } - - - - /** - * Get the names of the files that matched at none of the include patterns. - * The names are relative to the basedir. - * - * @return the names of the files - */ - public String[] getNotIncludedFiles() { - int count = filesNotIncluded.size(); - String[] files = new String[count]; - for (int i = 0; i < count; i++) { - files[i] = (String)filesNotIncluded.elementAt(i); - } - return files; - } - - - - /** - * Get the names of the files that matched at least one of the include - * patterns, an matched also at least one of the exclude patterns. - * The names are relative to the basedir. - * - * @return the names of the files - */ - public String[] getExcludedFiles() { - int count = filesExcluded.size(); - String[] files = new String[count]; - for (int i = 0; i < count; i++) { - files[i] = (String)filesExcluded.elementAt(i); - } - return files; - } - - - - /** - * Get the names of the directories that matched at least one of the include - * patterns, an matched none of the exclude patterns. - * The names are relative to the basedir. - * - * @return the names of the directories - */ - public String[] getIncludedDirectories() { - int count = dirsIncluded.size(); - String[] directories = new String[count]; - for (int i = 0; i < count; i++) { - directories[i] = (String)dirsIncluded.elementAt(i); - } - return directories; - } - - - - /** - * Get the names of the directories that matched at none of the include - * patterns. - * The names are relative to the basedir. - * - * @return the names of the directories - */ - public String[] getNotIncludedDirectories() { - int count = dirsNotIncluded.size(); - String[] directories = new String[count]; - for (int i = 0; i < count; i++) { - directories[i] = (String)dirsNotIncluded.elementAt(i); - } - return directories; - } - - - - /** - * Get the names of the directories that matched at least one of the include - * patterns, an matched also at least one of the exclude patterns. - * The names are relative to the basedir. - * - * @return the names of the directories - */ - public String[] getExcludedDirectories() { - int count = dirsExcluded.size(); - String[] directories = new String[count]; - for (int i = 0; i < count; i++) { - directories[i] = (String)dirsExcluded.elementAt(i); - } - return directories; - } - - - - /** - * Adds the array with default exclusions to the current exclusions set. - * - */ - public void addDefaultExcludes() { - int excludesLength = excludes == null ? 0 : excludes.length; - String[] newExcludes; - newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length]; - if (excludesLength > 0) { - System.arraycopy(excludes,0,newExcludes,0,excludesLength); - } - for (int i = 0; i < DEFAULTEXCLUDES.length; i++) { - newExcludes[i+excludesLength] = DEFAULTEXCLUDES[i].replace('/',File.separatorChar).replace('\\',File.separatorChar); - } - excludes = newExcludes; - } - - - -} diff --git a/src/main/org/apache/tools/ant/Location.java b/src/main/org/apache/tools/ant/Location.java deleted file mode 100644 index dcd14a587..000000000 --- a/src/main/org/apache/tools/ant/Location.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -/** - * Stores the file name and line number in a file. - */ -public class Location { - private String fileName; - private int lineNumber; - private int columnNumber; - - public static final Location UNKNOWN_LOCATION = new Location(); - - /** - * Creates an "unknown" location. - */ - private Location() { - this(null, 0, 0); - } - - /** - * Creates a location consisting of a file name but no line number. - */ - public Location(String fileName) { - this(fileName, 0, 0); - } - - /** - * Creates a location consisting of a file name and line number. - */ - public Location(String fileName, int lineNumber, int columnNumber) { - this.fileName = fileName; - this.lineNumber = lineNumber; - this.columnNumber = columnNumber; - } - - /** - * Returns the file name, line number and a trailing space. An error - * message can be appended easily. For unknown locations, returns - * an empty string. - */ - public String toString() { - StringBuffer buf = new StringBuffer(); - - if (fileName != null) { - buf.append(fileName); - - if (lineNumber != 0) { - buf.append(":"); - buf.append(lineNumber); - } - - buf.append(": "); - } - - return buf.toString(); - } -} \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/Main.java b/src/main/org/apache/tools/ant/Main.java deleted file mode 100644 index 2eb4b1da4..000000000 --- a/src/main/org/apache/tools/ant/Main.java +++ /dev/null @@ -1,367 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.io.*; -import java.util.*; - -/** - * Command line entry point into Ant. This class is entered via the - * cannonical `public static void main` entry point and reads the - * command line arguments. It then assembles and executes an Ant - * project. - *

- * If you integrating Ant into some other tool, this is not the class - * to use as an entry point. Please see the source code of this - * class to see how it manipulates the Ant project classes. - * - * @author duncan@x180.com - */ - -public class Main { - - /** Our current message output status. Follows Project.MSG_XXX */ - private int msgOutputLevel = Project.MSG_INFO; - - /** File that we are using for configuration */ - private File buildFile = new File("build.xml"); - - /** Stream that we are using for logging */ - private PrintStream out = System.out; - - /** The build targets */ - private Vector targets = new Vector(5); - - /** Set of properties that can be used by tasks */ - private Properties definedProps = new Properties(); - - /** Names of classes to add as listeners to project */ - private Vector listeners = new Vector(5); - - /** - * Indicates if this ant should be run. - */ - private boolean readyToRun = false; - - /** - * Command line entry point. This method kicks off the building - * of a project object and executes a build using either a given - * target or the default target. - * - * @param args Command line args. - */ - public static void main(String[] args) { - new Main(args).runBuild(); - } - - protected Main(String[] args) throws BuildException { - - // cycle through given args - - for (int i = 0; i < args.length; i++) { - String arg = args[i]; - - if (arg.equals("-help") || arg.equals("help")) { - printUsage(); - return; - } else if (arg.equals("-version")) { - printVersion(); - return; - } else if (arg.equals("-quiet") || arg.equals("-q") || arg.equals("q")) { - msgOutputLevel = Project.MSG_WARN; - } else if (arg.equals("-verbose") || arg.equals("-v") || arg.equals("v")) { - msgOutputLevel = Project.MSG_VERBOSE; - } else if (arg.equals("-logfile") || arg.equals("-l") || arg.equals("l")) { - try { - File logFile = new File(args[i+1]); - i++; - out = new PrintStream(new FileOutputStream(logFile)); - System.setOut(out); - System.setErr(out); - } catch (IOException ioe) { - String msg = "Cannot write on the specified log file. " + - "Make sure the path exists and you have write permissions."; - System.out.println(msg); - return; - } catch (ArrayIndexOutOfBoundsException aioobe) { - String msg = "You must specify a log file when " + - "using the -log argument"; - System.out.println(msg); - return; - } - } else if (arg.equals("-buildfile") || arg.equals("-file") || arg.equals("-f") || arg.equals("f")) { - try { - buildFile = new File(args[i+1]); - i++; - } catch (ArrayIndexOutOfBoundsException aioobe) { - String msg = "You must specify a buildfile when " + - "using the -buildfile argument"; - System.out.println(msg); - return; - } - } else if (arg.equals("-listener")) { - try { - listeners.addElement(args[i+1]); - i++; - } catch (ArrayIndexOutOfBoundsException aioobe) { - String msg = "You must specify a classname when " + - "using the -listener argument"; - System.out.println(msg); - return; - } - } else if (arg.startsWith("-D")) { - - /* Interestingly enough, we get to here when a user - * uses -Dname=value. However, in some cases, the JDK - * goes ahead * and parses this out to args - * {"-Dname", "value"} - * so instead of parsing on "=", we just make the "-D" - * characters go away and skip one argument forward. - * - * I don't know how to predict when the JDK is going - * to help or not, so we simply look for the equals sign. - */ - - String name = arg.substring(2, arg.length()); - String value = null; - int posEq = name.indexOf("="); - if (posEq > 0) { - value = name.substring(posEq+1); - name = name.substring(0, posEq); - } else if (i < args.length) - value = args[++i]; - - definedProps.put(name, value); - } else if (arg.startsWith("-")) { - // we don't have any more args to recognize! - String msg = "Unknown arg: " + arg; - System.out.println(msg); - printUsage(); - return; - } else { - // if it's no other arg, it may be the target - targets.addElement(arg); - } - - } - - // make sure buildfile exists - - if (!buildFile.exists()) { - System.out.println("Buildfile: " + buildFile + " does not exist!"); - return; - } - - // make sure it's not a directory (this falls into the ultra - // paranoid lets check everything catagory - - if (buildFile.isDirectory()) { - System.out.println("What? Buildfile: " + buildFile + " is a dir!"); - return; - } - - readyToRun = true; - } - - /** - * Executes the build. - */ - - private void runBuild() throws BuildException { - - if (!readyToRun) { - return; - } - - // track when we started - - long startTime = System.currentTimeMillis(); - if (msgOutputLevel >= Project.MSG_INFO) { - System.out.println("Buildfile: " + buildFile); - } - - Project project = new Project(); - addBuildListeners(project); - project.fireBuildStarted(); - project.init(); - - // set user-define properties - Enumeration e = definedProps.keys(); - while (e.hasMoreElements()) { - String arg = (String)e.nextElement(); - String value = (String)definedProps.get(arg); - project.setUserProperty(arg, value); - } - - project.setUserProperty( "ant.file" , buildFile.getAbsolutePath() ); - - // first use the ProjectHelper to create the project object - // from the given build file. - try { - try { - Class.forName("javax.xml.parsers.SAXParserFactory"); - ProjectHelper.configureProject(project, buildFile); - } catch (NoClassDefFoundError ncdfe) { - throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", ncdfe); - } catch (ClassNotFoundException cnfe) { - throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", cnfe); - } catch (NullPointerException npe) { - throw new BuildException("No JAXP compliant XML parser found. See http://java.sun.com/xml for the\nreference implementation.", npe); - } - } catch (BuildException be) { - System.out.println("\nBUILD CONFIG ERROR\n"); - System.out.println(be.getMessage()); - if (be.getException() == null) { - System.out.println(be.toString()); - } else { - be.getException().printStackTrace(); - } - throw be; - } - - // make sure that we have a target to execute - if (targets.size() == 0) { - targets.addElement(project.getDefaultTarget()); - } - - // actually do some work - try { - project.executeTargets(targets); - } catch (BuildException be) { - String msg = "\nBUILD FATAL ERROR\n\n"; - System.out.println(msg + be.toString()); - if (msgOutputLevel > Project.MSG_INFO) { - be.printStackTrace(); - } - throw be; - } - - // track our stop time and let the user know how long things took. - long finishTime = System.currentTimeMillis(); - long elapsedTime = finishTime - startTime; - if (msgOutputLevel >= Project.MSG_INFO) { - System.out.println("Completed in " + (elapsedTime/1000) - + " seconds"); - } - } - - protected void addBuildListeners(Project project) { - - // Add the default listener - project.addBuildListener(createDefaultBuildListener()); - - for (int i = 0; i < listeners.size(); i++) { - String className = (String) listeners.elementAt(i); - try { - BuildListener listener = - (BuildListener) Class.forName(className).newInstance(); - project.addBuildListener(listener); - } - catch(Exception exc) { - throw new BuildException("Unable to instantiate " + className, exc); - } - } - } - - /** - * Creates the default build listener for displaying output to the screen. - */ - private BuildListener createDefaultBuildListener() { - return new DefaultLogger(out, msgOutputLevel); - } - - /** - * Prints the usage of how to use this class to System.out - */ - private static void printUsage() { - String lSep = System.getProperty("line.separator"); - StringBuffer msg = new StringBuffer(); - msg.append("ant [options] [target]" + lSep); - msg.append("Options: " + lSep); - msg.append(" -help print this message" + lSep); - msg.append(" -version print the version information and exit" + lSep); - msg.append(" -quiet be extra quiet" + lSep); - msg.append(" -verbose be extra verbose" + lSep); - msg.append(" -logfile use given file for log" + lSep); - msg.append(" -listener add an instance of class as a project listener" + lSep); - msg.append(" -buildfile use given buildfile" + lSep); - msg.append(" -D= use value for given property" + lSep); - System.out.println(msg.toString()); - } - - private static void printVersion() { - try { - Properties props = new Properties(); - InputStream in = - Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt"); - props.load(in); - in.close(); - - String lSep = System.getProperty("line.separator"); - StringBuffer msg = new StringBuffer(); - msg.append("Ant version "); - msg.append(props.getProperty("VERSION")); - msg.append(" compiled on "); - msg.append(props.getProperty("DATE")); - msg.append(lSep); - System.out.println(msg.toString()); - } catch (IOException ioe) { - System.err.println("Could not load the version information."); - System.err.println(ioe.getMessage()); - } catch (NullPointerException npe) { - System.err.println("Could not load the version information."); - } - } -} diff --git a/src/main/org/apache/tools/ant/Map.java b/src/main/org/apache/tools/ant/Map.java deleted file mode 100644 index 74907ce2a..000000000 --- a/src/main/org/apache/tools/ant/Map.java +++ /dev/null @@ -1,62 +0,0 @@ - - -package org.apache.tools.ant; -import java.util.*; -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 - * . - */ - -public interface Map { - - public Object get( Object key ); -} diff --git a/src/main/org/apache/tools/ant/PathTokenizer.java b/src/main/org/apache/tools/ant/PathTokenizer.java deleted file mode 100644 index ded0ab4d5..000000000 --- a/src/main/org/apache/tools/ant/PathTokenizer.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.util.*; -import java.io.*; - -/** - * A Path tokenizer takes a path and returns the components that make up - * that path. - * - * The path can use path separators of either ':' or ';' and file separators - * of either '/' or '\' - * - * @author Conor MacNeill (conor@ieee.org) - * - */ -public class PathTokenizer { - /** - * A tokenizer to break the string up based on the ':' or ';' separators. - */ - private StringTokenizer tokenizer; - - /** - * A String which stores any path components which have been read ahead. - */ - private String lookahead = null; - - public PathTokenizer(String path) { - tokenizer = new StringTokenizer(path, ":;", false); - } - - public boolean hasMoreTokens() { - if (lookahead != null) { - return true; - } - - return tokenizer.hasMoreTokens(); - } - - public String nextToken() throws NoSuchElementException { - String token = null; - if (lookahead != null) { - token = lookahead; - lookahead = null; - } - else { - token = tokenizer.nextToken().trim(); - } - - if (token.length() == 1 && Character.isLetter(token.charAt(0)) - && File.pathSeparator.equals(";") - && tokenizer.hasMoreTokens()) { - // we are on a dos style system so this path could be a drive - // spec. We look at the next token - String nextToken = tokenizer.nextToken().trim(); - if (nextToken.startsWith("\\") || nextToken.startsWith("/")) { - // we know we are on a DOS style platform and the next path starts with a - // slash or backslash, so we know this is a drive spec - token += ":" + nextToken; - } - else { - // store the token just read for next time - lookahead = nextToken; - } - } - - return token; - } -} - \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/Project.java b/src/main/org/apache/tools/ant/Project.java deleted file mode 100644 index a2cac7336..000000000 --- a/src/main/org/apache/tools/ant/Project.java +++ /dev/null @@ -1,905 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.io.*; -import java.util.*; -import java.text.*; - -/** - * Central representation of an Ant project. This class defines a - * Ant project with all of it's targets and tasks. It also provides - * the mechanism to kick off a build using a particular target name. - *

- * This class also encapsulates methods which allow Files to be refered - * to using abstract path names which are translated to native system - * file paths at runtime as well as defining various project properties. - * - * @author duncan@x180.com - */ - -public class Project { - - public static final int MSG_ERR = 0; - public static final int MSG_WARN = 1; - public static final int MSG_INFO = 2; - public static final int MSG_VERBOSE = 3; - - // private set of constants to represent the state - // of a DFS of the Target dependencies - private static final String VISITING = "VISITING"; - private static final String VISITED = "VISITED"; - - private static String javaVersion; - - public static final String JAVA_1_0 = "1.0"; - public static final String JAVA_1_1 = "1.1"; - public static final String JAVA_1_2 = "1.2"; - public static final String JAVA_1_3 = "1.3"; - - public static final String TOKEN_START = "@"; - public static final String TOKEN_END = "@"; - - private String name; - - private Hashtable properties = new Hashtable(); - private Hashtable userProperties = new Hashtable(); - private Hashtable references = new Hashtable(); - private String defaultTarget; - private Hashtable taskClassDefinitions = new Hashtable(); - private Hashtable targets = new Hashtable(); - private Hashtable filters = new Hashtable(); - private File baseDir; - - private Vector listeners = new Vector(); - protected Target currentTarget = null; - protected Task currentTask = null; - - public Project() { - } - - /** - * Initialise the project. - * - * This involves setting the default task definitions and loading the - * system properties. - */ - public void init() throws BuildException { - detectJavaVersion(); - - String defs = "/org/apache/tools/ant/taskdefs/defaults.properties"; - - try { - Properties props = new Properties(); - InputStream in = this.getClass().getResourceAsStream(defs); - props.load(in); - in.close(); - - Enumeration enum = props.propertyNames(); - while (enum.hasMoreElements()) { - String key = (String) enum.nextElement(); - String value = props.getProperty(key); - try { - Class taskClass = Class.forName(value); - addTaskDefinition(key, taskClass); - } catch (NoClassDefFoundError ncdfe) { - // ignore... - } catch (ClassNotFoundException cnfe) { - // ignore... - } - } - - Properties systemP = System.getProperties(); - Enumeration e = systemP.keys(); - while (e.hasMoreElements()) { - String name = (String) e.nextElement(); - String value = (String) systemP.get(name); - this.setProperty(name, value); - } - } catch (IOException ioe) { - throw new BuildException("Can't load default task list"); - } - } - - public void addBuildListener(BuildListener listener) { - listeners.addElement(listener); - } - - public void removeBuildListener(BuildListener listener) { - listeners.removeElement(listener); - } - - public Vector getBuildListeners() { - return listeners; - } - - public void log(String msg) { - log(msg, MSG_INFO); - } - - public void log(String msg, int msgLevel) { - fireMessageLogged(msg, msgLevel); - } - - public void log(String msg, String tag, int msgLevel) { - fireMessageLogged(msg, msgLevel); - } - - public void setProperty(String name, String value) { - // command line properties take precedence - if (null != userProperties.get(name)) - return; - log("Setting project property: " + name + " -> " + - value, MSG_VERBOSE); - properties.put(name, value); - } - - public void setUserProperty(String name, String value) { - log("Setting ro project property: " + name + " -> " + - value, MSG_VERBOSE); - userProperties.put(name, value); - properties.put(name, value); - } - - public String getProperty(String name) { - if (name == null) return null; - String property = (String) properties.get(name); - return property; - } - - public String getUserProperty(String name) { - if (name == null) return null; - String property = (String) userProperties.get(name); - return property; - } - - public Hashtable getProperties() { - return properties; - } - - public Hashtable getUserProperties() { - return userProperties; - } - - public void setDefaultTarget(String defaultTarget) { - this.defaultTarget = defaultTarget; - } - - // deprecated, use setDefault - public String getDefaultTarget() { - return defaultTarget; - } - - // match the attribute name - public void setDefault(String defaultTarget) { - this.defaultTarget = defaultTarget; - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void addFilter(String token, String value) { - if (token == null) return; - log("Setting token to filter: " + token + " -> " - + value, MSG_VERBOSE); - this.filters.put(token, value); - } - - public Hashtable getFilters() { - return filters; - } - - // match basedir attribute in xml - public void setBasedir(String baseD) throws BuildException { - try { - setBaseDir(new File(new File(baseD).getCanonicalPath())); - } catch (IOException ioe) { - String msg = "Can't set basedir " + baseDir + " due to " + - ioe.getMessage(); - throw new BuildException(msg); - } - } - - public void setBaseDir(File baseDir) { - this.baseDir = baseDir; - setProperty( "basedir", baseDir.getAbsolutePath()); - String msg = "Project base dir set to: " + baseDir; - log(msg, MSG_INFO); - } - - public File getBaseDir() { - if (baseDir == null) { - try { - setBasedir("."); - } catch (BuildException ex) { - ex.printStackTrace(); - } - } - return baseDir; - } - - public static String getJavaVersion() { - return javaVersion; - } - - private void detectJavaVersion() { - - // Determine the Java version by looking at available classes - // java.lang.StrictMath was introduced in JDK 1.3 - // java.lang.ThreadLocal was introduced in JDK 1.2 - // java.lang.Void was introduced in JDK 1.1 - // Count up version until a NoClassDefFoundError ends the try - - try { - javaVersion = JAVA_1_0; - Class.forName("java.lang.Void"); - javaVersion = JAVA_1_1; - Class.forName("java.lang.ThreadLocal"); - javaVersion = JAVA_1_2; - Class.forName("java.lang.StrictMath"); - javaVersion = JAVA_1_3; - } catch (ClassNotFoundException cnfe) { - // swallow as we've hit the max class version that - // we have - } - setProperty("ant.java.version", javaVersion); - - // sanity check - if (javaVersion == JAVA_1_0) { - throw new BuildException("Ant cannot work on Java 1.0"); - } - - log("Detected Java Version: " + javaVersion, MSG_VERBOSE); - - log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE); - } - - public void addTaskDefinition(String taskName, Class taskClass) { - String msg = " +User task: " + taskName + " " + taskClass.getName(); - log(msg, MSG_VERBOSE); - taskClassDefinitions.put(taskName, taskClass); - } - - /** - * This call expects to add a new Target. - * @param target is the Target to be added to the current - * Project. - * @exception BuildException if the Target already exists - * in the project. - * @see Project#addOrReplaceTarget to replace existing Targets. - */ - public void addTarget(Target target) { - String name = target.getName(); - if (targets.get(name) != null) { - throw new BuildException("Duplicate target: `"+name+"'"); - } - addOrReplaceTarget(name, target); - } - - /** - * This call expects to add a new Target. - * @param target is the Target to be added to the current - * Project. - * @param targetName is the name to use for the Target - * @exception BuildException if the Target already exists - * in the project. - * @see Project#addOrReplaceTarget to replace existing Targets. - */ - public void addTarget(String targetName, Target target) - throws BuildException { - if (targets.get(targetName) != null) { - throw new BuildException("Duplicate target: `"+targetName+"'"); - } - addOrReplaceTarget(targetName, target); - } - - /** - * @param target is the Target to be added or replaced in - * the current Project. - */ - public void addOrReplaceTarget(Target target) { - addOrReplaceTarget(target.getName(), target); - } - - /** - * @param target is the Target to be added/replaced in - * the current Project. - * @param targetName is the name to use for the Target - */ - public void addOrReplaceTarget(String targetName, Target target) { - String msg = " +Target: " + targetName; - log(msg, MSG_VERBOSE); - target.setProject(this); - targets.put(targetName, target); - } - - public Hashtable getTargets() { - return targets; - } - - public Task createTask(String taskType) throws BuildException { - Class c = (Class) taskClassDefinitions.get(taskType); - - if (c == null) - throw new BuildException("Could not create task of type: "+taskType+ - " because I can't find it in the list of task"+ - " class definitions"); - try { - Object o = c.newInstance(); - Task task = null; - if( o instanceof Task ) { - task=(Task)o; - } else { - // "Generic" Bean - use the setter pattern - // and an Adapter - TaskAdapter taskA=new TaskAdapter(); - taskA.setProxy( o ); - task=taskA; - } - task.setProject(this); - String msg = " +Task: " + taskType; - log (msg, MSG_VERBOSE); - return task; - } catch (Exception e) { - String msg = "Could not create task of type: " - + taskType + " due to " + e; - throw new BuildException(msg); - } - } - - public void executeTargets(Vector targetNames) throws BuildException { - Throwable error = null; - - try { - for (int i = 0; i < targetNames.size(); i++) { - executeTarget((String)targetNames.elementAt(i)); - } - } - catch(RuntimeException exc) { - error = exc; - throw exc; - } - finally { - fireBuildFinished(error); - } - } - - public void executeTarget(String targetName) throws BuildException { - - // sanity check ourselves, if we've been asked to build nothing - // then we should complain - - if (targetName == null) { - String msg = "No target specified"; - throw new BuildException(msg); - } - - // Sort the dependency tree, and run everything from the - // beginning until we hit our targetName. - // Sorting checks if all the targets (and dependencies) - // exist, and if there is any cycle in the dependency - // graph. - Vector sortedTargets = topoSort(targetName, targets); - - int curidx = 0; - String curtarget; - - do { - curtarget = (String) sortedTargets.elementAt(curidx++); - runTarget(curtarget, targets); - } while (!curtarget.equals(targetName)); - } - - public File resolveFile(String fileName) { - // deal with absolute files - if (fileName.startsWith("/")) return new File( fileName ); - if (fileName.startsWith(System.getProperty("file.separator"))) - return new File( fileName ); - - // Eliminate consecutive slashes after the drive spec - if (fileName.length() >= 2 && - Character.isLetter(fileName.charAt(0)) && - fileName.charAt(1) == ':') { - char[] ca = fileName.replace('/', '\\').toCharArray(); - char c; - StringBuffer sb = new StringBuffer(); - - for (int i = 0; i < ca.length; i++) { - if ((ca[i] != '\\') || - (ca[i] == '\\' && - i > 0 && - ca[i - 1] != '\\')) { - if (i == 0 && - Character.isLetter(ca[i]) && - i < ca.length - 1 && - ca[i + 1] == ':') { - c = Character.toUpperCase(ca[i]); - } else { - c = ca[i]; - } - - sb.append(c); - } - } - - return new File(sb.toString()); - } - - File file = new File(baseDir.getAbsolutePath()); - StringTokenizer tok = new StringTokenizer(fileName, "/", false); - while (tok.hasMoreTokens()) { - String part = tok.nextToken(); - if (part.equals("..")) { - file = new File(file.getParent()); - } else if (part.equals(".")) { - // Do nothing here - } else { - file = new File(file, part); - } - } - - try { - return new File(file.getCanonicalPath()); - } - catch (IOException e) { - log("IOException getting canonical path for " + file + ": " + - e.getMessage(), MSG_ERR); - return new File(file.getAbsolutePath()); - } - } - - /** - Translate a path into its native (platform specific) - path. This should be extremely fast, code is - borrowed from ECS project. -

- All it does is translate the : into ; and / into \ - if needed. In other words, it isn't perfect. - - @returns translated string or empty string if to_process is null or empty - @author Jon S. Stevens jon@clearink.com - */ - public String translatePath(String to_process) { - if ( to_process == null || to_process.length() == 0 ) return ""; - - StringBuffer bs = new StringBuffer(to_process.length() + 50); - StringCharacterIterator sci = new StringCharacterIterator(to_process); - String path = System.getProperty("path.separator"); - String file = System.getProperty("file.separator"); - String tmp = null; - for (char c = sci.first(); c != CharacterIterator.DONE; c = sci.next()) { - tmp = String.valueOf(c); - - if (tmp.equals(":")) { - // could be a DOS drive or a Unix path separator... - // if followed by a backslash, assume it is a drive - c = sci.next(); - tmp = String.valueOf(c); - bs.append( tmp.equals("\\") ? ":" : path ); - if (c == CharacterIterator.DONE) break; - } - - if (tmp.equals(":") || tmp.equals(";")) - tmp = path; - else if (tmp.equals("/") || tmp.equals ("\\")) - tmp = file; - bs.append(tmp); - } - return(bs.toString()); - } - - /** - * Convienence method to copy a file from a source to a destination. - * No filtering is performed. - * - * @throws IOException - */ - public void copyFile(String sourceFile, String destFile) throws IOException { - copyFile(new File(sourceFile), new File(destFile), false); - } - - /** - * Convienence method to copy a file from a source to a destination - * specifying if token filtering must be used. - * - * @throws IOException - */ - public void copyFile(String sourceFile, String destFile, boolean filtering) - throws IOException - { - copyFile(new File(sourceFile), new File(destFile), filtering); - } - - /** - * Convienence method to copy a file from a source to a destination. - * No filtering is performed. - * - * @throws IOException - */ - public void copyFile(File sourceFile, File destFile) throws IOException { - copyFile(sourceFile, destFile, false); - } - - /** - * Convienence method to copy a file from a source to a destination - * specifying if token filtering must be used. - * - * @throws IOException - */ - public void copyFile(File sourceFile, File destFile, boolean filtering) - throws IOException - { - - if (destFile.lastModified() < sourceFile.lastModified()) { - log("Copy: " + sourceFile.getAbsolutePath() + " > " - + destFile.getAbsolutePath(), MSG_VERBOSE); - - // ensure that parent dir of dest file exists! - // not using getParentFile method to stay 1.1 compat - File parent = new File(destFile.getParent()); - if (!parent.exists()) { - parent.mkdirs(); - } - - if (filtering) { - BufferedReader in = new BufferedReader(new FileReader(sourceFile)); - BufferedWriter out = new BufferedWriter(new FileWriter(destFile)); - - int length; - String newline = null; - String line = in.readLine(); - while (line != null) { - if (line.length() == 0) { - out.newLine(); - } else { - newline = replace(line, filters); - out.write(newline); - out.newLine(); - } - line = in.readLine(); - } - - out.close(); - in.close(); - } else { - FileInputStream in = new FileInputStream(sourceFile); - FileOutputStream out = new FileOutputStream(destFile); - - byte[] buffer = new byte[8 * 1024]; - int count = 0; - do { - out.write(buffer, 0, count); - count = in.read(buffer, 0, buffer.length); - } while (count != -1); - - in.close(); - out.close(); - } - } - } - - /** - * Does replacement on the given string using the given token table. - * - * @returns the string with the token replaced. - */ - private String replace(String s, Hashtable tokens) { - int index = s.indexOf(TOKEN_START); - - if (index > -1) { - try { - StringBuffer b = new StringBuffer(); - int i = 0; - String token = null; - String value = null; - - do { - token = s.substring(index + TOKEN_START.length(), s.indexOf(TOKEN_END, index + TOKEN_START.length() + 1)); - b.append(s.substring(i, index)); - if (tokens.containsKey(token)) { - value = (String) tokens.get(token); - log("Replacing: " + TOKEN_START + token + TOKEN_END + " -> " + value, MSG_VERBOSE); - b.append(value); - } else { - b.append(TOKEN_START); - b.append(token); - b.append(TOKEN_END); - } - i = index + TOKEN_START.length() + token.length() + TOKEN_END.length(); - } while ((index = s.indexOf(TOKEN_START, i)) > -1); - - b.append(s.substring(i)); - return b.toString(); - } catch (StringIndexOutOfBoundsException e) { - return s; - } - } else { - return s; - } - } - - /** - * returns the boolean equivalent of a string, which is considered true - * if either "on", "true", or "yes" is found, ignoring case. - */ - public static boolean toBoolean(String s) { - return (s.equalsIgnoreCase("on") || - s.equalsIgnoreCase("true") || - s.equalsIgnoreCase("yes")); - } - - // Given a string defining a target name, and a Hashtable - // containing the "name to Target" mapping, pick out the - // Target and execute it. - private final void runTarget(String target, Hashtable targets) - throws BuildException { - - currentTarget = (Target)targets.get(target); - if (currentTarget == null) { - throw new RuntimeException("Unexpected missing target `"+target+ - "' in this project."); - } - - try { - fireTargetStarted(); - currentTarget.execute(); - fireTargetFinished(null); - } - catch(RuntimeException exc) { - fireTargetFinished(exc); - throw exc; - } - finally { - currentTarget = null; - } - } - - /** - * Topologically sort a set of Targets. - * @param root is the (String) name of the root Target. The sort is - * created in such a way that the sequence of Targets uptil the root - * target is the minimum possible such sequence. - * @param targets is a Hashtable representing a "name to Target" mapping - * @return a Vector of Strings with the names of the targets in - * sorted order. - * @exception BuildException if there is a cyclic dependency among the - * Targets, or if a Target does not exist. - */ - private final Vector topoSort(String root, Hashtable targets) - throws BuildException { - Vector ret = new Vector(); - Hashtable state = new Hashtable(); - Stack visiting = new Stack(); - - // We first run a DFS based sort using the root as the starting node. - // This creates the minimum sequence of Targets to the root node. - // We then do a sort on any remaining unVISITED targets. - // This is unnecessary for doing our build, but it catches - // circular dependencies or missing Targets on the entire - // dependency tree, not just on the Targets that depend on the - // build Target. - - tsort(root, targets, state, visiting, ret); - log("Build sequence for target `"+root+"' is "+ret, MSG_VERBOSE); - for (Enumeration en=targets.keys(); en.hasMoreElements();) { - String curTarget = (String)(en.nextElement()); - String st = (String) state.get(curTarget); - if (st == null) { - tsort(curTarget, targets, state, visiting, ret); - } - else if (st == VISITING) { - throw new RuntimeException("Unexpected node in visiting state: "+curTarget); - } - } - log("Complete build sequence is "+ret, MSG_VERBOSE); - return ret; - } - - // one step in a recursive DFS traversal of the Target dependency tree. - // - The Hashtable "state" contains the state (VISITED or VISITING or null) - // of all the target names. - // - The Stack "visiting" contains a stack of target names that are - // currently on the DFS stack. (NB: the target names in "visiting" are - // exactly the target names in "state" that are in the VISITING state.) - // 1. Set the current target to the VISITING state, and push it onto - // the "visiting" stack. - // 2. Throw a BuildException if any child of the current node is - // in the VISITING state (implies there is a cycle.) It uses the - // "visiting" Stack to construct the cycle. - // 3. If any children have not been VISITED, tsort() the child. - // 4. Add the current target to the Vector "ret" after the children - // have been visited. Move the current target to the VISITED state. - // "ret" now contains the sorted sequence of Targets upto the current - // Target. - - private final void tsort(String root, Hashtable targets, - Hashtable state, Stack visiting, - Vector ret) - throws BuildException { - state.put(root, VISITING); - visiting.push(root); - - Target target = (Target)(targets.get(root)); - - // Make sure we exist - if (target == null) { - StringBuffer sb = new StringBuffer("Target `"); - sb.append(root); - sb.append("' does not exist in this project. "); - visiting.pop(); - if (!visiting.empty()) { - String parent = (String)visiting.peek(); - sb.append("It is used from target `"); - sb.append(parent); - sb.append("'."); - } - - throw new BuildException(new String(sb)); - } - - for (Enumeration en=target.getDependencies(); en.hasMoreElements();) { - String cur = (String) en.nextElement(); - String m=(String)state.get(cur); - if (m == null) { - // Not been visited - tsort(cur, targets, state, visiting, ret); - } - else if (m == VISITING) { - // Currently visiting this node, so have a cycle - throw makeCircularException(cur, visiting); - } - } - - String p = (String) visiting.pop(); - if (root != p) { - throw new RuntimeException("Unexpected internal error: expected to pop "+root+" but got "+p); - } - state.put(root, VISITED); - ret.addElement(root); - } - - private static BuildException makeCircularException(String end, Stack stk) { - StringBuffer sb = new StringBuffer("Circular dependency: "); - sb.append(end); - String c; - do { - c = (String)stk.pop(); - sb.append(" <- "); - sb.append(c); - } while(!c.equals(end)); - return new BuildException(new String(sb)); - } - - public void addReference(String name, Object value) { - references.put(name,value); - } - - public Hashtable getReferences() { - return references; - } - - protected void fireBuildStarted() { - BuildEvent event = createBuildEvent(); - for (int i = 0; i < listeners.size(); i++) { - BuildListener listener = (BuildListener) listeners.elementAt(i); - listener.buildStarted(event); - } - } - - protected void fireBuildFinished(Throwable exception) { - BuildEvent event = createBuildEvent(exception); - for (int i = 0; i < listeners.size(); i++) { - BuildListener listener = (BuildListener) listeners.elementAt(i); - listener.buildFinished(event); - } - } - - protected void fireTargetStarted() { - BuildEvent event = createBuildEvent(); - for (int i = 0; i < listeners.size(); i++) { - BuildListener listener = (BuildListener) listeners.elementAt(i); - listener.targetStarted(event); - } - } - - protected void fireTargetFinished(Throwable exception) { - BuildEvent event = createBuildEvent(exception); - for (int i = 0; i < listeners.size(); i++) { - BuildListener listener = (BuildListener) listeners.elementAt(i); - listener.targetFinished(event); - } - } - - protected void fireTaskStarted() { - BuildEvent event = createBuildEvent(); - for (int i = 0; i < listeners.size(); i++) { - BuildListener listener = (BuildListener) listeners.elementAt(i); - listener.taskStarted(event); - } - } - - protected void fireTaskFinished(Throwable exception) { - BuildEvent event = createBuildEvent(exception); - for (int i = 0; i < listeners.size(); i++) { - BuildListener listener = (BuildListener) listeners.elementAt(i); - listener.taskFinished(event); - } - } - - protected void fireMessageLogged(String message, int priority) { - BuildEvent event = createBuildEvent(message, priority); - for (int i = 0; i < listeners.size(); i++) { - BuildListener listener = (BuildListener) listeners.elementAt(i); - listener.messageLogged(event); - } - } - - public BuildEvent createBuildEvent() { - return new BuildEvent(this, currentTarget, currentTask, null, MSG_VERBOSE, null); - } - - public BuildEvent createBuildEvent(String msg, int priority) { - return new BuildEvent(this, currentTarget, currentTask, msg, priority, null); - } - - public BuildEvent createBuildEvent(Throwable exception) { - return new BuildEvent(this, currentTarget, currentTask, null, MSG_VERBOSE, exception); - } -} diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java deleted file mode 100644 index 31909892d..000000000 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ /dev/null @@ -1,523 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.beans.*; -import java.io.*; -import java.lang.reflect.*; -import java.util.*; -import org.xml.sax.*; -import org.w3c.dom.*; -import org.apache.tools.ant.taskdefs.*; -import javax.xml.parsers.*; - -/** - * Configures a Project (complete with Targets and Tasks) based on - * a XML build file. - * - * @author duncan@x180.com - */ - -public class ProjectHelper { - - private static SAXParserFactory parserFactory = null; - - private org.xml.sax.Parser parser; - private Project project; - private File buildFile; - private Locator locator; - - /** - * Configures the Project with the contents of the specified XML file. - */ - public static void configureProject(Project project, File buildFile) throws BuildException { - new ProjectHelper(project, buildFile).parse(); - } - - /** - * Constructs a new Ant parser for the specified XML file. - */ - private ProjectHelper(Project project, File buildFile) { - this.project = project; - this.buildFile = buildFile; - } - - /** - * Parses the project file. - */ - private void parse() throws BuildException { - try { - parser = getParserFactory().newSAXParser().getParser(); - parser.setDocumentHandler(new RootHandler()); - parser.parse(new InputSource(new FileReader(buildFile))); - } - catch(ParserConfigurationException exc) { - throw new BuildException("Parser has not been configured correctly", exc); - } - catch(SAXParseException exc) { - Location location = - new Location(buildFile.toString(), exc.getLineNumber(), exc.getColumnNumber()); - throw new BuildException(exc.getMessage(), exc.getException(), location); - } - catch(SAXException exc) { - throw new BuildException(exc.getMessage(), exc.getException()); - } - catch(FileNotFoundException exc) { - throw new BuildException("File \"" + buildFile.toString() + "\" not found"); - } - catch(IOException exc) { - throw new BuildException("Error reading project file", exc); - } - } - - /** - * The common superclass for all sax event handlers in Ant. Basically - * throws an exception in each method, so subclasses should override - * what they can handle. - * - * Each type of xml element (task, target, etc) in ant will - * have its own subclass of AbstractHandler. - * - * In the constructor, this class takes over the handling of sax - * events from the parent handler, and returns - * control back to the parent in the endElement method. - */ - private class AbstractHandler extends HandlerBase { - protected DocumentHandler parentHandler; - - public AbstractHandler(DocumentHandler parentHandler) { - this.parentHandler = parentHandler; - - // Start handling SAX events - parser.setDocumentHandler(this); - } - - public void startElement(String tag, AttributeList attrs) throws SAXParseException { - throw new SAXParseException("Unexpected element \"" + tag + "\"", locator); - } - - public void characters(char[] buf, int start, int end) throws SAXParseException { - String s = new String(buf, start, end).trim(); - - if (s.length() > 0) { - throw new SAXParseException("Unexpected text \"" + s + "\"", locator); - } - } - - public void endElement(String name) throws SAXException { - - // Let parent resume handling SAX events - parser.setDocumentHandler(parentHandler); - } - } - - /** - * Handler for the root element. It's only child must be the "project" element. - */ - private class RootHandler extends HandlerBase { - public void startElement(String tag, AttributeList attrs) throws SAXParseException { - if (tag.equals("project")) { - new ProjectHandler(this).init(tag, attrs); - } else { - throw new SAXParseException("Config file is not of expected XML type", locator); - } - } - - public void setDocumentLocator(Locator locator) { - ProjectHelper.this.locator = locator; - } - } - - /** - * Handler for the top level "project" element. - */ - private class ProjectHandler extends AbstractHandler { - public ProjectHandler(DocumentHandler parentHandler) { - super(parentHandler); - } - - public void init(String tag, AttributeList attrs) throws SAXParseException { - String def = null; - String name = null; - String id = null; - String baseDir = new File(buildFile.getAbsolutePath()).getParent(); - - for (int i = 0; i < attrs.getLength(); i++) { - String key = attrs.getName(i); - String value = attrs.getValue(i); - - if (key.equals("default")) { - def = value; - } else if (key.equals("name")) { - name = value; - } else if (key.equals("id")) { - id = value; - } else if (key.equals("basedir")) { - baseDir = value; - } else { - throw new SAXParseException("Unexpected attribute \"" + attrs.getName(i) + "\"", locator); - } - } - - project.setDefaultTarget(def); - - project.setName(name); - if (name != null) project.addReference(name, project); - - if (id != null) project.addReference(id, project); - - if (project.getProperty("basedir") != null) { - project.setBasedir(project.getProperty("basedir")); - } else { - project.setBasedir(baseDir); - } - - } - - public void startElement(String name, AttributeList attrs) throws SAXParseException { - if (name.equals("taskdef")) { - handleTaskdef(name, attrs); - } else if (name.equals("property")) { - handleProperty(name, attrs); - } else if (name.equals("target")) { - handleTarget(name, attrs); - } else { - throw new SAXParseException("Unexpected element \"" + name + "\"", locator); - } - } - - private void handleTaskdef(String name, AttributeList attrs) throws SAXParseException { - new TaskHandler(this, null).init(name, attrs); - } - - private void handleProperty(String name, AttributeList attrs) throws SAXParseException { - new TaskHandler(this, null).init(name, attrs); - } - - private void handleTarget(String tag, AttributeList attrs) throws SAXParseException { - new TargetHandler(this).init(tag, attrs); - } - } - - /** - * Handler for "target" elements. - */ - private class TargetHandler extends AbstractHandler { - private Target target; - - public TargetHandler(DocumentHandler parentHandler) { - super(parentHandler); - } - - public void init(String tag, AttributeList attrs) throws SAXParseException { - String name = null; - String depends = ""; - String cond = null; - String id = null; - - for (int i = 0; i < attrs.getLength(); i++) { - String key = attrs.getName(i); - String value = attrs.getValue(i); - - if (key.equals("name")) { - name = value; - } else if (key.equals("depends")) { - depends = value; - } else if (key.equals("if")) { - cond = value; - } else if (key.equals("id")) { - id = value; - } else { - throw new SAXParseException("Unexpected attribute \"" + key + "\"", locator); - } - } - - if (name == null) { - throw new SAXParseException("target element appears without a name attribute", locator); - } - - target = new Target(); - target.setName(name); - target.setCondition(cond); - project.addTarget(name, target); - - if (id != null && !id.equals("")) - project.addReference(id, target); - - // take care of dependencies - - if (depends.length() > 0) { - StringTokenizer tok = - new StringTokenizer(depends, ",", false); - while (tok.hasMoreTokens()) { - target.addDependency(tok.nextToken().trim()); - } - } - } - - public void startElement(String name, AttributeList attrs) throws SAXParseException { - new TaskHandler(this, target).init(name, attrs); - } - } - - /** - * Handler for all task elements. - */ - private class TaskHandler extends AbstractHandler { - private Target target; - private Task task; - - public TaskHandler(DocumentHandler parentHandler, Target target) { - super(parentHandler); - - this.target = target; - } - - public void init(String tag, AttributeList attrs) throws SAXParseException { - task = project.createTask(tag); - configure(task, attrs); - task.setLocation(new Location(buildFile.toString(), locator.getLineNumber(), locator.getColumnNumber())); - task.init(); - - // Top level tasks don't have associated targets - if (target != null) { - task.setTarget(target); - target.addTask(task); - } - } - - public void characters(char[] buf, int start, int end) throws SAXParseException { - String text = new String(buf, start, end).trim(); - if (text.length() == 0) return; - - try { - Method addProp = task.getClass().getMethod("addText", new Class[]{String.class}); - Object child = addProp.invoke(task, new Object[] {text}); - } catch(NoSuchMethodException exc) { - throw new SAXParseException(task.getClass() + " does not support nested text elements", locator); - } catch(InvocationTargetException exc) { - throw new SAXParseException("Error invoking \"addText\" method", locator, exc); - } catch(IllegalAccessException exc) { - throw new SAXParseException("Unable to access \"addText\" method", locator, exc); - } - } - - public void startElement(String name, AttributeList attrs) throws SAXParseException { - new NestedPropertyHandler(this, task).init(name, attrs); - } - } - - /** - * Handler for all nested properties. - */ - private class NestedPropertyHandler extends AbstractHandler { - private DocumentHandler parentHandler; - - private Object target; - private Object child; - - public NestedPropertyHandler(DocumentHandler parentHandler, Object target) { - super(parentHandler); - - this.target = target; - } - - public void init(String propType, AttributeList attrs) throws SAXParseException { - Class targetClass = target.getClass(); - - String methodName = "create" + Character.toUpperCase(propType.charAt(0)) + propType.substring(1); - - try { - Method addProp = targetClass.getMethod(methodName, new Class[]{}); - child = addProp.invoke(target, new Object[] {}); - configure(child, attrs); - } catch(NoSuchMethodException exc) { - throw new SAXParseException(targetClass + " does not support nested " + propType + " properties", locator); - } catch(InvocationTargetException exc) { - throw new SAXParseException(exc.getMessage(), locator); - } catch(IllegalAccessException exc) { - throw new SAXParseException(exc.getMessage(), locator); - } - } - - public void startElement(String name, AttributeList attrs) throws SAXParseException { - new NestedPropertyHandler(this, child).init(name, attrs); - } - } - - private void configure(Object target, AttributeList attrs) throws BuildException { - if( target instanceof TaskAdapter ) - target=((TaskAdapter)target).getProxy(); - - // XXX - // instead of doing this introspection each time around, I - // should have a helper class to keep this info around for - // each kind of class - - Hashtable propertySetters = new Hashtable(); - BeanInfo beanInfo; - try { - beanInfo = Introspector.getBeanInfo(target.getClass()); - } catch (IntrospectionException ie) { - String msg = "Can't introspect class: " + target.getClass(); - throw new BuildException(msg); - } - - PropertyDescriptor[] pda = beanInfo.getPropertyDescriptors(); - for (int i = 0; i < pda.length; i++) { - PropertyDescriptor pd = pda[i]; - String property = pd.getName(); - Method setMethod = pd.getWriteMethod(); - if (setMethod != null) { - - // make sure that there's only 1 param and that it - // takes a String object, all other setMethods need - // to get screened out - - Class[] ma =setMethod.getParameterTypes(); - if (ma.length == 1) { - Class c = ma[0]; - if (c.getName().equals("java.lang.String")) { - propertySetters.put(property, setMethod); - } - } - } - } - - for (int i = 0; i < attrs.getLength(); i++) { - // reflect these into the target - - Method setMethod = (Method)propertySetters.get(attrs.getName(i)); - if (setMethod == null) { - if (attrs.getName(i).equals("id")) { - project.addReference(attrs.getValue(i), target); - continue; - } - - String msg = "Class " + target.getClass() + - " doesn't support the \"" + attrs.getName(i) + "\" property"; - throw new BuildException(msg); - } - - String value=replaceProperties(attrs.getValue(i), project.getProperties() ); - try { - setMethod.invoke(target, new String[] {value}); - } catch (IllegalAccessException iae) { - String msg = "Error setting value for attrib: " + - attrs.getName(i); - iae.printStackTrace(); - throw new BuildException(msg); - } catch (InvocationTargetException ie) { - String msg = "Error setting value for attrib: " + - attrs.getName(i) + " in " + target.getClass().getName(); - ie.printStackTrace(); - ie.getTargetException().printStackTrace(); - throw new BuildException(msg); - } - } - } - - - /** Replace ${NAME} with the property value - */ - public static String replaceProperties( String value, Hashtable keys ) - throws BuildException - { - // XXX use Map instead of proj, it's too heavy - - // XXX need to replace this code with something better. - StringBuffer sb=new StringBuffer(); - int i=0; - int prev=0; - // assert value!=nil - int pos; - while( (pos=value.indexOf( "$", prev )) >= 0 ) { - if(pos>0) { - sb.append( value.substring( prev, pos ) ); - } - if( pos == (value.length() - 1)) { - sb.append('$'); - prev = pos + 1; - } - else if (value.charAt( pos + 1 ) != '{' ) { - sb.append( value.charAt( pos + 1 ) ); - prev=pos+2; // XXX - } else { - int endName=value.indexOf( '}', pos ); - if( endName < 0 ) { - throw new BuildException("Syntax error in prop: " + - value ); - } - String n=value.substring( pos+2, endName ); - String v=(String) keys.get( n ); - //System.out.println("N: " + n + " " + " V:" + v); - sb.append( v ); - prev=endName+1; - } - } - if( prev < value.length() ) sb.append( value.substring( prev ) ); - // System.out.println("After replace: " + sb.toString()); - // System.out.println("Before replace: " + value); - return sb.toString(); - } - - private static SAXParserFactory getParserFactory() { - if (parserFactory == null) { - parserFactory = SAXParserFactory.newInstance(); - } - - return parserFactory; - } -} diff --git a/src/main/org/apache/tools/ant/Target.java b/src/main/org/apache/tools/ant/Target.java deleted file mode 100644 index acd9b42d5..000000000 --- a/src/main/org/apache/tools/ant/Target.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.util.*; - -/** - * This class implements a target object with required parameters. - * - * @author James Davidson duncan@x180.com - */ - -public class Target { - - private String name; - private String condition = ""; - private Vector dependencies = new Vector(2); - private Vector tasks = new Vector(5); - private Project project; - - public void setProject(Project project) { - this.project = project; - } - - public Project getProject() { - return project; - } - - public void setDepends(String depS) { - if (depS.length() > 0) { - StringTokenizer tok = - new StringTokenizer(depS, ",", false); - while (tok.hasMoreTokens()) { - addDependency(tok.nextToken().trim()); - } - } - } - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void addTask(Task task) { - tasks.addElement(task); - } - - public void addDependency(String dependency) { - dependencies.addElement(dependency); - } - - public Enumeration getDependencies() { - return dependencies.elements(); - } - - public void setCondition(String property) { - this.condition = (property == null) ? "" : property; - } - - public void execute() throws BuildException { - if (("".equals(this.condition)) || (project.getProperty(this.condition) != null)) { - Enumeration enum = tasks.elements(); - while (enum.hasMoreElements()) { - Task task = (Task) enum.nextElement(); - - try { - project.currentTask = task; - project.fireTaskStarted(); - task.execute(); - project.fireTaskFinished(null); - } - catch(RuntimeException exc) { - if (exc instanceof BuildException) { - ((BuildException)exc).setLocation(task.getLocation()); - } - project.fireTaskFinished(exc); - throw exc; - } - finally { - project.currentTask = null; - } - } - } else { - project.log("Skipped because property '" + this.condition + "' not set.", this.name, Project.MSG_VERBOSE); - } - } -} diff --git a/src/main/org/apache/tools/ant/Task.java b/src/main/org/apache/tools/ant/Task.java deleted file mode 100644 index daf7fc1d2..000000000 --- a/src/main/org/apache/tools/ant/Task.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -/** - * Base class for all tasks. - */ - -public abstract class Task { - - protected Project project = null; - protected Target target = null; - protected String description=null; - protected Location location = Location.UNKNOWN_LOCATION; - - /** - * Sets the project object of this task. This method is used by - * project when a task is added to it so that the task has - * access to the functions of the project. It should not be used - * for any other purpose. - * - * @param project Project in whose scope this task belongs. - */ - void setProject(Project project) { - this.project = project; - } - - /** - * Sets the target object of this task. - * - * @param target Target in whose scope this task belongs. - */ - public void setTarget(Target target) { - this.target = target; - } - - /** Sets a description of the current action. It will be usefull in commenting - * what we are doing. - */ - public void setDescription( String desc ) { - description=desc; - } - - public String getDescription() { - return description; - } - - /** - * Called by the project to let the task initialize properly. Normally it does nothing. - * - * @throws BuildException if someting goes wrong with the build - */ - public void init() throws BuildException {} - - /** - * Called by the project to let the task do it's work. Normally it does nothing. - * - * @throws BuildException if someting goes wrong with the build - */ - public void execute() throws BuildException {}; - - /** - * Returns the file location where this task was defined. - */ - public Location getLocation() { - return location; - } - - /** - * Sets the file location where this task was defined. - */ - public void setLocation(Location location) { - this.location = location; - } -} - diff --git a/src/main/org/apache/tools/ant/TaskAdapter.java b/src/main/org/apache/tools/ant/TaskAdapter.java deleted file mode 100644 index cfb83e554..000000000 --- a/src/main/org/apache/tools/ant/TaskAdapter.java +++ /dev/null @@ -1,102 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.lang.reflect.*; -import java.util.*; - -/** - * Use introspection to "adapt" an arbitrary Bean ( not extending Task, but with similar - * patterns). - * - * @author costin@dnt.ro - */ -public class TaskAdapter extends Task { - - Object proxy; - - /** - * Do the execution. - */ - public void execute() throws BuildException { - Method executeM=null; - try { - Class c=proxy.getClass(); - executeM=c.getMethod( "execute", new Class[0] ); - if( executeM == null ) { - project.log("No execute in " + proxy.getClass(), "TaskAdapter", project.MSG_ERR); - throw new BuildException("No execute in " + proxy.getClass()); - } - executeM.invoke(proxy, null); - return; - } catch( Exception ex ) { - project.log("Error in " + proxy.getClass(), "TaskAdapter", project.MSG_ERR); - throw new BuildException( ex ); - } - - } - - /** - * Set the target object class - */ - public void setProxy(Object o) { - this.proxy = o; - } - - public Object getProxy() { - return this.proxy ; - } - -} diff --git a/src/main/org/apache/tools/ant/XmlLogger.java b/src/main/org/apache/tools/ant/XmlLogger.java deleted file mode 100644 index 4620a85f7..000000000 --- a/src/main/org/apache/tools/ant/XmlLogger.java +++ /dev/null @@ -1,269 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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; - -import java.io.*; -import javax.xml.parsers.*; -import org.w3c.dom.*; - -/** - * Generates a "log.xml" file in the current directory with - * an XML description of what happened during a build. - * - * @see Project#addBuildListener(BuildListener) - */ -public class XmlLogger implements BuildListener { - - private static final DocumentBuilder builder = getDocumentBuilder(); - - private static DocumentBuilder getDocumentBuilder() { - try { - return DocumentBuilderFactory.newInstance().newDocumentBuilder(); - } - catch(Exception exc) { - throw new ExceptionInInitializerError(exc); - } - } - - // XML constants for tag names and attribute names - private static final String BUILD_TAG = "build"; - private static final String TARGET_TAG = "target"; - private static final String TASK_TAG = "task"; - private static final String MESSAGE_TAG = "message"; - private static final String NAME_ATTR = "name"; - private static final String TIME_ATTR = "time"; - private static final String PRIORITY_ATTR = "priority"; - private static final String LOCATION_ATTR = "location"; - private static final String ERROR_ATTR = "error"; - - private Document doc; - private Element buildElement; - private Element targetElement; - private Element taskElement; - - private long buildStartTime; - private long targetStartTime; - private long taskStartTime; - - /** - * Constructs a new BuildListener that logs build events to an XML file. - */ - public XmlLogger() { - } - - public void buildStarted(BuildEvent event) { - buildStartTime = System.currentTimeMillis(); - - doc = builder.newDocument(); - buildElement = doc.createElement(BUILD_TAG); - } - - public void buildFinished(BuildEvent event) { - long totalTime = System.currentTimeMillis() - buildStartTime; - buildElement.setAttribute(TIME_ATTR, formatTime(totalTime)); - - if (event.getException() != null) { - buildElement.setAttribute(ERROR_ATTR, event.getException().toString()); - } - - try { - Writer out = new FileWriter("log.xml"); - out.write("\n\n"); - write(buildElement, out, 0); - out.flush(); - out.close(); - - } - catch(IOException exc) { - throw new BuildException("Unable to close log file", exc); - } - } - - public void targetStarted(BuildEvent event) { - targetStartTime = System.currentTimeMillis(); - targetElement = doc.createElement(TARGET_TAG); - targetElement.setAttribute(NAME_ATTR, event.getTarget().getName()); - } - - public void targetFinished(BuildEvent event) { - long totalTime = System.currentTimeMillis() - targetStartTime; - targetElement.setAttribute(TIME_ATTR, formatTime(totalTime)); - buildElement.appendChild(targetElement); - - targetElement = null; - } - - public void taskStarted(BuildEvent event) { - taskStartTime = System.currentTimeMillis(); - taskElement = doc.createElement(TASK_TAG); - - String name = event.getTask().getClass().getName(); - int pos = name.lastIndexOf("."); - if (pos != -1) { - name = name.substring(pos + 1); - } - taskElement.setAttribute(NAME_ATTR, name); - - taskElement.setAttribute(LOCATION_ATTR, event.getTask().getLocation().toString()); - } - - public void taskFinished(BuildEvent event) { - long totalTime = System.currentTimeMillis() - taskStartTime; - taskElement.setAttribute(TIME_ATTR, formatTime(totalTime)); - targetElement.appendChild(taskElement); - - taskElement = null; - } - - public void messageLogged(BuildEvent event) { - Element messageElement = doc.createElement(MESSAGE_TAG); - - String name = "debug"; - switch(event.getPriority()) { - case Project.MSG_ERR: name = "error"; break; - case Project.MSG_WARN: name = "warn"; break; - case Project.MSG_INFO: name = "info"; break; - default: name = "debug"; break; - } - messageElement.setAttribute(PRIORITY_ATTR, name); - - Text messageText = doc.createTextNode(event.getMessage()); - messageElement.appendChild(messageText); - - if (taskElement != null) { - taskElement.appendChild(messageElement); - } - else if (targetElement != null) { - targetElement.appendChild(messageElement); - } - else { - buildElement.appendChild(messageElement); - } - } - - /** - * Writes a DOM element to a file. - */ - private static void write(Element element, Writer out, int indent) throws IOException { - - // Write indent characters - for (int i = 0; i < indent; i++) { - out.write("\t"); - } - - // Write element - out.write("<"); - out.write(element.getTagName()); - - // Write attributes - NamedNodeMap attrs = element.getAttributes(); - for (int i = 0; i < attrs.getLength(); i++) { - Attr attr = (Attr) attrs.item(i); - out.write(" "); - out.write(attr.getName()); - out.write("=\""); - out.write(attr.getValue()); - out.write("\""); - } - out.write(">"); - - // Write child attributes and text - boolean hasChildren = false; - NodeList children = element.getChildNodes(); - for (int i = 0; i < children.getLength(); i++) { - Node child = children.item(i); - - if (child.getNodeType() == Node.ELEMENT_NODE) { - if (!hasChildren) { - out.write("\n"); - hasChildren = true; - } - write((Element)child, out, indent + 1); - } - - if (child.getNodeType() == Node.TEXT_NODE) { - out.write(((Text)child).getData()); - } - } - - // If we had child elements, we need to indent before we close - // the element, otherwise we're on the same line and don't need - // to indent - if (hasChildren) { - for (int i = 0; i < indent; i++) { - out.write("\t"); - } - } - - // Write element close - out.write("\n"); - } - - private static String formatTime(long millis) { - long seconds = millis / 1000; - long minutes = seconds / 60; - - - if (minutes > 0) { - return Long.toString(minutes) + " minutes " + Long.toString(seconds%60) + " seconds"; - } - else { - return Long.toString(seconds) + " seconds"; - } - - } -} \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/defaultManifest.mf b/src/main/org/apache/tools/ant/defaultManifest.mf deleted file mode 100644 index 9d885be53..000000000 --- a/src/main/org/apache/tools/ant/defaultManifest.mf +++ /dev/null @@ -1 +0,0 @@ -Manifest-Version: 1.0 diff --git a/src/main/org/apache/tools/ant/taskdefs/Ant.java b/src/main/org/apache/tools/ant/taskdefs/Ant.java deleted file mode 100644 index 7ee143031..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Ant.java +++ /dev/null @@ -1,171 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Call Ant in a sub-project - * - *

- *    
- *    
- *      
- *      
- *     
- *  
- *
- * 
- *    
- * 
- * 
- * - * - * @author costin@dnt.ro - */ -public class Ant extends Task { - - private String dir = null; - private String antFile = null; - private String target = null; - private String output = null; - - Vector properties=new Vector(); - Project p1; - - public void init() { - p1 = new Project(); - Vector listeners = project.getBuildListeners(); - for (int i = 0; i < listeners.size(); i++) { - p1.addBuildListener((BuildListener)listeners.elementAt(i)); - } - - if (output != null) { - try { - PrintStream out = new PrintStream(new FileOutputStream(output)); - p1.addBuildListener(new DefaultLogger(out, Project.MSG_INFO)); - } - catch( IOException ex ) { - project.log( "Ant: Can't set output to " + output ); - } - } - - p1.init(); - - // set user-define properties - Hashtable prop1 = project.getProperties(); - Enumeration e = prop1.keys(); - while (e.hasMoreElements()) { - String arg = (String) e.nextElement(); - String value = (String) prop1.get(arg); - p1.setProperty(arg, value); - } - } - - /** - * Do the execution. - */ - public void execute() throws BuildException { - if( dir==null) dir="."; - - p1.setBasedir(dir); - p1.setUserProperty("basedir" , dir); - - // Override with local-defined properties - Enumeration e = properties.elements(); - while (e.hasMoreElements()) { - Property p=(Property) e.nextElement(); - // System.out.println("Setting " + p.getName()+ " " + p.getValue()); - p.init(); - } - - if (antFile == null) antFile = dir + "/build.xml"; - - p1.setUserProperty( "ant.file" , antFile ); - ProjectHelper.configureProject(p1, new File(antFile)); - - if (target == null) { - target = p1.getDefaultTarget(); - } - - p1.executeTarget(target); - } - - public void setDir(String d) { - this.dir = d; - } - - public void setAntfile(String s) { - this.antFile = s; - } - - public void setTarget(String s) { - this.target = s; - } - - public void setOutput(String s) { - this.output = s; - } - - // XXX replace with createProperty!! - public Task createProperty() { - Property p=(Property)p1.createTask("property"); - p.setUserProperty(true); - properties.addElement( p ); - return p; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Available.java b/src/main/org/apache/tools/ant/taskdefs/Available.java deleted file mode 100644 index 470270d13..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Available.java +++ /dev/null @@ -1,128 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Will set the given property if the requested resource is available at runtime. - * - * @author Stefano Mazzocchi stefano@apache.org - */ - -public class Available extends Task { - - private String property; - private String classname; - private String file; - private String resource; - - public void setProperty(String property) { - this.property = property; - } - - public void setClass(String classname) { - project.log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); - this.classname = classname; - } - - public void setClassname(String classname) { - this.classname = classname; - } - - public void setFile(String filename) { - this.file = filename; - } - - public void setResource(String resource) { - this.resource = resource; - } - - public void init() throws BuildException { - if ((classname != null) && !checkClass(classname)) return; - if ((file != null) && !checkFile(file)) return; - if ((resource != null) && !checkResource(resource)) return; - - this.project.setProperty(property, "true"); - } - - private boolean checkFile(String file) { - try { - File f = new File(file); - return f.exists(); - } catch (Exception e) { - project.log(e.toString(), "available", Project.MSG_VERBOSE); - return false; - } - } - - private boolean checkResource(String resource) { - return (ClassLoader.getSystemResource(resource) != null); - } - - private boolean checkClass(String classname) { - try { - Class.forName(classname); - return true; - } catch (Throwable t) { - project.log(t.toString(), "available", Project.MSG_VERBOSE); - return false; - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Chmod.java b/src/main/org/apache/tools/ant/taskdefs/Chmod.java deleted file mode 100644 index d092b4e03..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Chmod.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * - * - * @author costin@eng.sun.com - */ - -public class Chmod extends Task { - - private File srcFile; - private String mod; - - public void setSrc(String src) { - srcFile = project.resolveFile(src); - } - - public void setPerm(String perm) { - mod=perm; - } - - public void execute() throws BuildException { - try { - // XXX if OS=unix - if (System.getProperty("path.separator").equals(":") && - !System.getProperty("os.name").startsWith("Mac")) - Runtime.getRuntime().exec("chmod " + mod + " " + srcFile ); - } catch (IOException ioe) { - // ignore, but warn - System.out.println("Error chmod" + ioe.toString() ); - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/CompileTask.java b/src/main/org/apache/tools/ant/taskdefs/CompileTask.java deleted file mode 100644 index 02bebf324..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/CompileTask.java +++ /dev/null @@ -1,112 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.util.*; - -/** - * This task will compile and load a new taskdef all in one step. - * At times, this is useful for eliminating ordering dependencies - * which otherwise would require multiple executions of Ant. - * - * @author Sam Ruby rubys@us.ibm.com - */ - -public class CompileTask extends Javac { - - protected Vector taskList = new Vector(); - - /** - * add a new task entry on the task list - */ - public Taskdef createTaskdef() { - Taskdef task = new Taskdef(); - taskList.addElement(task); - return task; - } - - /** - * do all the real work in init - */ - public void init() { - - // create all the include entries from the task defs - for (Enumeration e=taskList.elements(); e.hasMoreElements(); ) { - Taskdef task = (Taskdef)e.nextElement(); - String source = task.getClassname().replace('.','/') + ".java"; - MatchingTask.NameEntry include = super.createInclude(); - include.setName("**/" + source); - } - - // execute Javac - super.init(); - super.execute(); - - // now define all the new tasks - for (Enumeration e=taskList.elements(); e.hasMoreElements(); ) { - Taskdef task = (Taskdef)e.nextElement(); - task.init(); - } - - } - - /** - * have execute do nothing - */ - public void execute() { - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Copydir.java b/src/main/org/apache/tools/ant/taskdefs/Copydir.java deleted file mode 100644 index ea8511754..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Copydir.java +++ /dev/null @@ -1,137 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Copies a directory. - * - * @author James Davidson duncan@x180.com - */ - -public class Copydir extends MatchingTask { - - private File srcDir; - private File destDir; - private boolean filtering = false; - private boolean forceOverwrite = false; - private Hashtable filecopyList = new Hashtable(); - - public void setSrc(String src) { - srcDir = project.resolveFile(src); - } - - public void setDest(String dest) { - destDir = project.resolveFile(dest); - } - - public void setFiltering(String filter) { - filtering = Project.toBoolean(filter); - } - - public void setForceoverwrite(String force) { - forceOverwrite = Project.toBoolean(force); - } - - public void execute() throws BuildException { - if (srcDir == null) { - throw new BuildException("srcdir attribute must be set!", - location); - } - - if (!srcDir.exists()) { - throw new BuildException("srcdir "+srcDir.toString() - +" does not exist!", location); - } - - DirectoryScanner ds = super.getDirectoryScanner(srcDir); - - String[] files = ds.getIncludedFiles(); - scanDir(srcDir, destDir, files); - if (filecopyList.size() > 0) { - project.log("Copying " + filecopyList.size() + " files to " - + destDir.getAbsolutePath()); - Enumeration enum = filecopyList.keys(); - while (enum.hasMoreElements()) { - String fromFile = (String) enum.nextElement(); - String toFile = (String) filecopyList.get(fromFile); - try { - project.copyFile(fromFile, toFile, filtering); - } catch (IOException ioe) { - String msg = "Failed to copy " + fromFile + " to " + toFile - + " due to " + ioe.getMessage(); - throw new BuildException(msg, ioe, location); - } - } - } - } - - private void scanDir(File from, File to, String[] files) { - for (int i = 0; i < files.length; i++) { - String filename = files[i]; - File srcFile = new File(from, filename); - File destFile = new File(to, filename); - if (forceOverwrite || - (srcFile.lastModified() > destFile.lastModified())) { - filecopyList.put(srcFile.getAbsolutePath(), - destFile.getAbsolutePath()); - } - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Copyfile.java b/src/main/org/apache/tools/ant/taskdefs/Copyfile.java deleted file mode 100644 index 0a8efc783..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Copyfile.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Copies a file. - * - * @author duncan@x180.com - */ - -public class Copyfile extends Task { - - private File srcFile; - private File destFile; - private boolean filtering = false; - - public void setSrc(String src) { - srcFile = project.resolveFile(src); - } - - public void setDest(String dest) { - destFile = project.resolveFile(dest); - } - - public void setFiltering(String filter) { - filtering = Project.toBoolean(filter); - } - - public void execute() throws BuildException { - if (srcFile.lastModified() > destFile.lastModified()) { - try { - project.copyFile(srcFile, destFile, filtering); - } catch (IOException ioe) { - String msg = "Error copying file: " + srcFile.getAbsolutePath() - + " due to " + ioe.getMessage(); - throw new BuildException(msg); - } - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Cvs.java b/src/main/org/apache/tools/ant/taskdefs/Cvs.java deleted file mode 100644 index a5a94b508..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Cvs.java +++ /dev/null @@ -1,153 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * - * - * @author costin@dnt.ro - * @author stefano@apache.org - */ - -public class Cvs extends Exec { - - private String cvsRoot; - private String pack; - private String tag; - private String date; - private String command = "checkout"; - private boolean quiet = false; - private boolean noexec = false; - - public void execute() throws BuildException { - - // XXX: we should use JCVS (www.ice.com/JCVS) instead of command line - // execution so that we don't rely on having native CVS stuff around (SM) - - StringBuffer sb=new StringBuffer(); - sb.append(" cvs "); - if (cvsRoot != null) { - sb.append("-d ").append(cvsRoot).append(" "); - } - - sb.append(noexec ? "-n " : "") - .append(quiet ? "-q " : "") - .append(command).append(" "); - - if (tag!=null) - sb.append("-r ").append(tag).append(" "); - - if (date!=null) - sb.append("-D ").append(date).append(" "); - - if (pack != null) { - sb.append(pack); - } - - run(sb.toString()); - } - - public void setCvsRoot(String root) { - // Check if not real cvsroot => set it to null - if (root != null) { - if (root.trim().equals("")) - root = null; - } - - this.cvsRoot = root; - } - - public void setDest(String dest) { - setDir(dest); - } - - public void setPackage(String p) { - this.pack = p; - } - - public void setTag(String p) { - // Check if not real tag => set it to null - if (p != null) { - if (p.trim().equals("")) - p = null; - } - - this.tag = p; - } - - - public void setDate(String p) { - if( p != null && p.trim().length()==0 ) - p = null; - this.date = p; - } - - public void setCommand(String c) { - this.command = c; - } - - public void setQuiet(String q) { - quiet = Project.toBoolean(q); - } - - public void setNoexec(String ne) { - noexec = Project.toBoolean(ne); - } -} - - diff --git a/src/main/org/apache/tools/ant/taskdefs/Delete.java b/src/main/org/apache/tools/ant/taskdefs/Delete.java deleted file mode 100644 index 3f484a28b..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Delete.java +++ /dev/null @@ -1,158 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Deletes a single file or a set of files defined by a pattern. - * - * @author stefano@apache.org - * @author Tom Dimock tad1@cornell.edu - */ -public class Delete extends MatchingTask { - - private File delDir = null; - private int verbosity = project.MSG_VERBOSE; - private File f = null; - - /** - * Set the name of a single file to be removed. - * - * @param file the file to be deleted - */ - public void setFile(String file) { - f = project.resolveFile(file); - } - - /** - * Set the directory from which files are to be deleted - * - * @param dir the directory path. - */ - public void setDir(String dir) { - delDir = project.resolveFile(dir); - } - - /** - * Used to force listing of all names of deleted files. - * - * @param verbose "true" or "on" - */ - public void setVerbose(String verbose) { - - if ("true".equalsIgnoreCase(verbose.trim()) || "on".equalsIgnoreCase(verbose.trim())) { - this.verbosity = project.MSG_INFO; - } - else { - this.verbosity = project.MSG_VERBOSE; - } - } - - /** - * Make it so. Delete the file(s). - * - * @throws BuildException - */ - public void execute() throws BuildException { - - if (f == null && delDir == null) { - throw new BuildException(" or attribute must be set!"); - } - - // old functionality must still work - if (f != null) { - if (f.exists()) { - if (f.isDirectory()) { - project - .log("Directory: " + f.getAbsolutePath() - + " cannot be removed with delete. Use Deltree instead."); - } - else { - project.log("Deleting: " + f.getAbsolutePath()); - if (!f.delete()) { - throw new BuildException("Unable to delete file " + f.getAbsolutePath()); - } - } - } - } - - // now we'll do the fancy pattern-driven deletes - if (delDir == null) { - return; - } - if (!delDir.exists()) { - throw new BuildException("dir does not exist!"); - } - DirectoryScanner ds = super.getDirectoryScanner(delDir); - String[] files = ds.getIncludedFiles(); - - if (files.length > 0) { - project.log("Deleting " + files.length + " files from " + delDir.getAbsolutePath()); - for (int i = 0; i < files.length; i++) { - File f = new File(delDir, files[i]); - - if (f.exists()) { - project.log("Deleting: " + f.getAbsolutePath(), verbosity); - if (!f.delete()) { - throw new BuildException("Unable to delete " + f.getAbsolutePath()); - } - } - } - } - } -} - diff --git a/src/main/org/apache/tools/ant/taskdefs/Deltree.java b/src/main/org/apache/tools/ant/taskdefs/Deltree.java deleted file mode 100644 index a0a355100..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Deltree.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * - * - * @author duncan@x180.com - */ - -public class Deltree extends Task { - - private File dir; - - public void setDir(String dirName) { - dir = project.resolveFile(dirName); - } - - public void execute() throws BuildException { - project.log("Deleting: " + dir.getAbsolutePath()); - - if (dir.exists()) { - if (!dir.isDirectory()) { - if (!dir.delete()) { - throw new BuildException("Unable to delete file " + dir.getAbsolutePath()); - } - return; - // String msg = "Given dir: " + dir.getAbsolutePath() + - // " is not a dir"; - // throw new BuildException(msg); - } - try { - removeDir(dir); - } catch (IOException ioe) { - String msg = "Unable to delete " + dir.getAbsolutePath(); - throw new BuildException(msg); - } - } - } - - private void removeDir(File dir) throws IOException { - - // check to make sure that the given dir isn't a symlink - // the comparison of absolute path and canonical path - // catches this - - // if (dir.getCanonicalPath().equals(dir.getAbsolutePath())) { - // (costin) It will not work if /home/costin is symlink to /da0/home/costin ( taz - // for example ) - String[] list = dir.list(); - for (int i = 0; i < list.length; i++) { - String s = list[i]; - File f = new File(dir, s); - if (f.isDirectory()) { - removeDir(f); - } else { - if (!f.delete()) { - throw new BuildException("Unable to delete file " + f.getAbsolutePath()); - } - } - } - if (!dir.delete()) { - throw new BuildException("Unable to delete directory " + dir.getAbsolutePath()); - } - } -} - diff --git a/src/main/org/apache/tools/ant/taskdefs/Echo.java b/src/main/org/apache/tools/ant/taskdefs/Echo.java deleted file mode 100644 index 6f64b4630..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Echo.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.net.*; -/** - * Echo - * - * @author costin@dnt.ro - */ -public class Echo extends Task { - private String message; // required - - /** - * Does the work. - * - * @exception BuildException if someting goes wrong with the build - */ - public void execute() throws BuildException { - System.out.println(message); - } - - /** - * Sets the message variable. - * - * @param msg Sets the value for the message variable. - */ - public void setMessage(String msg) { - this.message = msg; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Exec.java b/src/main/org/apache/tools/ant/taskdefs/Exec.java deleted file mode 100644 index c0fef65fa..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Exec.java +++ /dev/null @@ -1,213 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Executes a given command if the os platform is appropriate. - * - * @author duncan@x180.com - * @author rubys@us.ibm.com - */ - -public class Exec extends Task { - private String os; - private String out; - private File dir; - private String command; - - private static final int BUFFER_SIZE = 512; - - public void execute() throws BuildException { - run(command); - } - - protected int run(String command) throws BuildException { - - int err = -1; // assume the worst - - // test if os match - String myos = System.getProperty("os.name"); - project.log("Myos = " + myos, Project.MSG_VERBOSE); - if ((os != null) && (os.indexOf(myos) < 0)){ - // this command will be executed only on the specified OS - project.log("Not found in " + os, Project.MSG_VERBOSE); - return 0; - } - - // default directory to the project's base directory - if (dir == null) dir = project.getBaseDir(); - - if (myos.toLowerCase().indexOf("windows") >= 0) { - if (!dir.equals(project.resolveFile("."))) - command = "cmd /c cd " + dir + " && " + command; - } else { - String ant = project.getProperty("ant.home"); - if (ant == null) throw new BuildException("Property 'ant.home' not found", location); - String antRun = project.resolveFile(ant + "/bin/antRun").toString(); - - command = antRun + " " + dir + " " + command; - } - - try { - // show the command - project.log(command, "exec", Project.MSG_VERBOSE); - - // exec command on system runtime - Process proc = Runtime.getRuntime().exec(command); - - PrintWriter fos=null; - if( out!=null ) { - fos=new PrintWriter( new FileWriter( out ) ); - project.log("Output redirected to " + out, Project.MSG_VERBOSE); - } - - // copy input and error to the output stream - StreamPumper inputPumper = - new StreamPumper(proc.getInputStream(), "exec", project, fos); - StreamPumper errorPumper = - new StreamPumper(proc.getErrorStream(), "error", project, fos); - - // starts pumping away the generated output/error - inputPumper.start(); - errorPumper.start(); - - // Wait for everything to finish - proc.waitFor(); - inputPumper.join(); - errorPumper.join(); - proc.destroy(); - - // close the output file if required - if (fos != null) fos.close(); - - // check its exit value - err = proc.exitValue(); - if (err != 0) { - project.log("Result: " + err, "exec", Project.MSG_ERR); - } - } catch (IOException ioe) { - throw new BuildException("Error exec: " + command, ioe, location); - } catch (InterruptedException ex) {} - - return err; - } - - public void setDir(String d) { - this.dir = project.resolveFile(d); - } - - public void setOs(String os) { - this.os = os; - } - - public void setCommand(String command) { - this.command = command; - } - - public void setOutput(String out) { - this.out = out; - } - - // Inner class for continually pumping the input stream during - // Process's runtime. - class StreamPumper extends Thread { - private BufferedReader din; - private String name; - private boolean endOfStream = false; - private int SLEEP_TIME = 5; - private Project project; - private PrintWriter fos; - - public StreamPumper(InputStream is, String name, Project project, PrintWriter fos) { - this.din = new BufferedReader(new InputStreamReader(is)); - this.name = name; - this.project = project; - this.fos = fos; - } - - public void pumpStream() - throws IOException - { - byte[] buf = new byte[BUFFER_SIZE]; - if (!endOfStream) { - String line = din.readLine(); - - if (line != null) { - if (fos == null) - project.log(line, name, Project.MSG_INFO); - else - fos.println(line); - } else { - endOfStream = true; - } - } - } - - public void run() { - try { - try { - while (!endOfStream) { - pumpStream(); - sleep(SLEEP_TIME); - } - } catch (InterruptedException ie) {} - din.close(); - } catch (IOException ioe) {} - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Expand.java b/src/main/org/apache/tools/ant/taskdefs/Expand.java deleted file mode 100644 index 57a8eaa07..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Expand.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.zip.*; -/** - * Unzip a file. - * - * @author costin@dnt.ro - * @author Stefan Bodewig stefan.bodewig@megabit.net - */ -public class Expand extends Task { - private String dest; // req - private String source; // req - - /** - * Do the work. - * - * @exception BuildException Thrown in unrecoverable error. - */ - // XXX move it to util or tools - public void execute() throws BuildException { - Touch touch = (Touch) project.createTask("touch"); - touch.setTarget(target); - - try { - File srcF=project.resolveFile(source); - File dir=project.resolveFile(dest); - - project.log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); - // code from WarExpand - ZipInputStream zis = new ZipInputStream(new FileInputStream(srcF)); - ZipEntry ze = null; - - while ((ze = zis.getNextEntry()) != null) { - try { - File f = new File(dir, project.translatePath(ze.getName())); - project.log("expand-file " + ze.getName() , "expand", Project.MSG_VERBOSE ); - // create intermediary directories - sometimes zip don't add them - File dirF=new File(f.getParent()); - dirF.mkdirs(); - - if (ze.isDirectory()) { - f.mkdirs(); - } else { - byte[] buffer = new byte[1024]; - int length = 0; - FileOutputStream fos = new FileOutputStream(f); - - while ((length = zis.read(buffer)) >= 0) { - fos.write(buffer, 0, length); - } - - fos.close(); - } - - if (project.getJavaVersion() != Project.JAVA_1_1) { - touch.setFile(f.getAbsolutePath()); - touch.setMillis(ze.getTime()); - touch.touch(); - } - - } catch( FileNotFoundException ex ) { - System.out.println("FileNotFoundException: " + ze.getName() ); - } - } - project.log("", Project.MSG_VERBOSE ); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - - /** - * Set the destination directory. File will be unzipped into the - * destination directory. - * - * @param d Path to the directory. - */ - public void setDest(String d) { - this.dest=d; - } - - /** - * Set the path to zip-file. - * - * @param s Path to zip-file. - */ - public void setSrc(String s) { - this.source = s; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Filter.java b/src/main/org/apache/tools/ant/taskdefs/Filter.java deleted file mode 100644 index 35e4847f6..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Filter.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * This task set a token filter that is used by the file copy methods - * of the project to do token substitution. - * - * @author Stefano Mazzocchi stefano@apache.org - */ -public class Filter extends Task { - - private String token; - private String value; - - public void setToken(String token) { - this.token = token; - } - - public void setValue(String value) { - this.value = value; - } - - public void init() throws BuildException { - project.addFilter(token, value); - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java b/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java deleted file mode 100644 index b305b6c3a..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java +++ /dev/null @@ -1,362 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; -import java.text.*; - -/** - * Task to convert text source files to local OS formatting conventions, as - * well as repair text files damaged by misconfigured or misguided editors or - * file transfer programs. - *

- * This task can take the following arguments: - *

    - *
  • srcdir - *
  • destdir - *
  • include - *
  • exclude - *
  • cr - *
  • tab - *
  • eof - *
- * Of these arguments, only sourcedir is required. - *

- * When this task executes, it will scan the srcdir based on the include - * and exclude properties. - *

- * Warning: do not run on binary or carefully formatted files. - * this may sound obvious, but if you don't specify asis, presume that - * your files are going to be modified. If you want tabs to be fixed, - * whitespace characters may be added or removed as necessary. Similarly, - * for CR's - in fact cr="add" can result in cr characters being removed. - * (to handle cases where other programs have converted CRLF into CRCRLF). - * - * @author Sam Ruby rubys@us.ibm.com - */ - -public class FixCRLF extends MatchingTask { - - private int addcr; // cr: -1 => remove, 0 => asis, +1 => add - private int addtab; // tab: -1 => remove, 0 => asis, +1 => add - private int ctrlz; // eof: -1 => remove, 0 => asis, +1 => add - - private File srcDir; - private File destDir = null; - - /** - * Defaults the properties based on the system type. - *

  • Unix: cr="remove" tab="asis" eof="remove" - *
  • DOS: cr="add" tab="asis" eof="asis"
- */ - public FixCRLF() { - if (System.getProperty("path.separator").equals(":")) { - addcr = -1; // remove - ctrlz = -1; // remove - } else { - addcr = +1; // add - ctrlz = 0; // asis - } - } - - /** - * Set the source dir to find the source text files. - * - * @param srcDirName name of the source directory. - */ - public void setSrcdir(String srcDirName) { - srcDir = project.resolveFile(srcDirName); - } - - /** - * Set the destination where the fixed files should be placed. - * Default is to replace the original file. - * - * @param destDirName name of the destination directory. - */ - public void setDestdir(String destDirName) { - destDir = project.resolveFile(destDirName); - } - - /** - * Specify how carriage return (CR) charaters are to be handled - * - * @param option valid values: - *
    - *
  • add: ensure that there is a CR before every LF - *
  • asis: leave CR characters alone - *
  • remove: remove all CR characters - *
- */ - public void setCr(String option) { - if (option.equals("remove")) { - addcr = -1; - } else if (option.equals("asis")) { - addcr = 0; - } else if (option.equals("add")) { - addcr = +1; - } else { - throw new BuildException("Invalid option: " + option ); - } - } - - /** - * Specify how tab charaters are to be handled - * - * @param option valid values: - *
    - *
  • add: convert sequences of spaces which span a tab stop to tabs - *
  • asis: leave tab and space characters alone - *
  • remove: convert tabs to spaces - *
- */ - public void setTab(String option) { - if (option.equals("remove")) { - addtab = -1; - } else if (option.equals("asis")) { - addtab = 0; - } else if (option.equals("add")) { - addtab = +1; - } else { - throw new BuildException("Invalid option: " + option ); - } - } - - /** - * Specify how DOS EOF (control-z) charaters are to be handled - * - * @param option valid values: - *
    - *
  • add: ensure that there is an eof at the end of the file - *
  • asis: leave eof characters alone - *
  • remove: remove any eof character found at the end - *
- */ - public void setEof(String option) { - if (option.equals("remove")) { - ctrlz = -1; - } else if (option.equals("asis")) { - ctrlz = 0; - } else if (option.equals("add")) { - ctrlz = +1; - } else { - throw new BuildException("Invalid option: " + option ); - } - } - - /** - * Executes the task. - */ - public void execute() throws BuildException { - // first off, make sure that we've got a srcdir and destdir - - if (srcDir == null) { - throw new BuildException("srcdir attribute must be set!"); - } - if (!srcDir.exists()) { - throw new BuildException("srcdir does not exist!"); - } - if (!srcDir.isDirectory()) { - throw new BuildException("srcdir is not a directory!"); - } - if (destDir != null) { - if (!destDir.exists()) { - throw new BuildException("destdir does not exist!"); - } - if (!destDir.isDirectory()) { - throw new BuildException("destdir is not a directory!"); - } - } - - // log options used - project.log("options:" + - " cr=" + (addcr==-1 ? "add" : addcr==0 ? "asis" : "remove") + - " tab=" + (addtab==-1 ? "add" : addtab==0 ? "asis" : "remove") + - " eof=" + (ctrlz==-1 ? "add" : ctrlz==0 ? "asis" : "remove"), - "fixcrlf", project.MSG_VERBOSE); - - DirectoryScanner ds = super.getDirectoryScanner(srcDir); - String[] files = ds.getIncludedFiles(); - - for (int i = 0; i < files.length; i++) { - File srcFile = new File(srcDir, files[i]); - - // read the contents of the file - int count = (int)srcFile.length(); - byte indata[] = new byte[count]; - try { - FileInputStream inStream = new FileInputStream(srcFile); - inStream.read(indata); - inStream.close(); - } catch (IOException e) { - throw new BuildException(e); - } - - // count the number of cr, lf, and tab characters - int cr = 0; - int lf = 0; - int tab = 0; - - for (int k=0; k0) && (indata[count-1] == 0x1A)); - - // log stats (before fixes) - project.log(srcFile + ": size=" + count + " cr=" + cr + - " lf=" + lf + " tab=" + tab + " eof=" + eof, - "fixcrlf", project.MSG_VERBOSE); - - // determine the output buffer size (slightly pessimisticly) - int outsize = count; - if (addcr != 0) outsize-=cr; - if (addcr == +1) outsize+=lf; - if (addtab == -1) outsize+=tab*7; - if (ctrlz == +1) outsize+=1; - - // copy the data - byte outdata[] = new byte[outsize]; - int o = 0; // output offset - int line = o; // beginning of line - int col = 0; // desired column - - for (int k=0; k0 && o+12 && outdata[o-1]==0x0A && outdata[o-2]==0x1A) o--; - if (o>1 && outdata[o-1]==0x1A) o--; - } - - // output the data - try { - File destFile = srcFile; - if (destDir != null) destFile = new File(destDir, files[i]); - FileOutputStream outStream = new FileOutputStream(destFile); - outStream.write(outdata,0,o); - outStream.close(); - } catch (IOException e) { - throw new BuildException(e); - } - - } /* end for */ - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java b/src/main/org/apache/tools/ant/taskdefs/GUnzip.java deleted file mode 100644 index df7c0cd56..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/GUnzip.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.zip.*; - -/** - * Expands a file that has been compressed with the GZIP - * algorightm. Normally used to compress non-compressed archives such - * as TAR files. - * - * @author Stefan Bodewig stefan.bodewig@megabit.net - */ - -public class GUnzip extends Task { - - private File source; - private File dest; - - public void setSrc(String src) { - source = project.resolveFile(src); - } - - public void setDest(String dest) { - this.dest = project.resolveFile(dest); - } - - public void execute() throws BuildException { - if (source == null) { - throw new BuildException("No source specified"); - } - - if (!source.exists()) { - throw new BuildException("source doesn't exist"); - } - - if (source.isDirectory()) { - throw new BuildException("Cannot expand a directory"); - } - - if (dest == null) { - dest = new File(source.getParent()); - } - - if (dest.isDirectory()) { - String sourceName = source.getName(); - int len = sourceName.length(); - if (len > 3 - && ".gz".equalsIgnoreCase(sourceName.substring(len-3))) { - dest = new File(dest, sourceName.substring(0, len-3)); - } else { - dest = new File(dest, sourceName); - } - } - - if (source.lastModified() > dest.lastModified()) { - project.log("Expanding "+ source.getAbsolutePath() + " to " - + dest.getAbsolutePath()); - - try { - FileOutputStream out = new FileOutputStream(dest); - GZIPInputStream zIn = new GZIPInputStream(new FileInputStream(source)); - byte[] buffer = new byte[8 * 1024]; - int count = 0; - do { - out.write(buffer, 0, count); - count = zIn.read(buffer, 0, buffer.length); - } while (count != -1); - zIn.close(); - out.close(); - } catch (IOException ioe) { - String msg = "Problem expanding gzip " + ioe.getMessage(); - throw new BuildException(msg, ioe); - } - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/GZip.java b/src/main/org/apache/tools/ant/taskdefs/GZip.java deleted file mode 100644 index b1f9b06d9..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/GZip.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.zip.*; - -/** - * Compresses a file with the GZIP algorightm. Normally used to compress - * non-compressed archives such as TAR files. - * - * @author James Davidson duncan@x180.com - * @author Jon S. Stevens jon@clearink.com - */ - -public class GZip extends Task { - - private File zipFile; - private File source; - - public void setZipfile(String zipFilename) { - zipFile = project.resolveFile(zipFilename); - } - - public void setSrc(String src) { - source = project.resolveFile(src); - } - - public void execute() throws BuildException { - project.log("Building gzip: " + zipFile.getAbsolutePath()); - - try { - GZIPOutputStream zOut = new GZIPOutputStream(new FileOutputStream(zipFile)); - - if (source.isDirectory()) { - project.log ("Cannot Gzip a directory!"); - } else { - zipFile(source, zOut); - } - // close up - zOut.close(); - } catch (IOException ioe) { - String msg = "Problem creating gzip " + ioe.getMessage(); - throw new BuildException(msg); - } - } - - private void zipFile(InputStream in, GZIPOutputStream zOut) - throws IOException - { - byte[] buffer = new byte[8 * 1024]; - int count = 0; - do { - zOut.write(buffer, 0, count); - count = in.read(buffer, 0, buffer.length); - } while (count != -1); - } - - private void zipFile(File file, GZIPOutputStream zOut) - throws IOException - { - FileInputStream fIn = new FileInputStream(file); - zipFile(fIn, zOut); - fIn.close(); - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Get.java b/src/main/org/apache/tools/ant/taskdefs/Get.java deleted file mode 100644 index 43c282596..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Get.java +++ /dev/null @@ -1,157 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.net.*; -/** - * Get a particular source. - * - * @author costin@dnt.ro - */ -public class Get extends Task { - private String source; // required - private String dest; // required - private String verbose = ""; - String ignoreErrors=null; - - /** - * Does the work. - * - * @exception BuildException Thrown in unrecovrable error. - */ - public void execute() throws BuildException { - try { - URL url = null; - try { - url = new URL(source); - } catch (MalformedURLException e) { - throw new BuildException(e.toString()); - } - - project.log("Getting: " + source); - - File destF=new File(dest); - FileOutputStream fos = new FileOutputStream(destF); - - InputStream is=null; - for( int i=0; i< 3 ; i++ ) { - try { - is = url.openStream(); - break; - } catch( IOException ex ) { - project.log( "Error opening connection " + ex ); - } - } - if( is==null ) { - project.log( "Can't get " + source + " to " + dest); - if( ignoreErrors != null ) return; - throw new BuildException( "Can't get " + source + " to " + dest); - } - - byte[] buffer = new byte[100 * 1024]; - int length; - - while ((length = is.read(buffer)) >= 0) { - fos.write(buffer, 0, length); - if ("true".equals(verbose)) System.out.print("."); - } - if( "true".equals(verbose)) System.out.println(); - fos.close(); - is.close(); - } catch (IOException ioe) { - project.log("Error getting " + source + " to " + dest ); - if( ignoreErrors != null ) return; - throw new BuildException(ioe.toString()); - } - } - - /** - * Set the URL. - * - * @param d URL for the file. - */ - public void setSrc(String d) { - this.source=d; - } - - /** - * Where to copy the source file. - * - * @param dest Path to file. - */ - public void setDest(String dest) { - this.dest = dest; - } - - /** - * Be verbose, if set to "true". - * - * @param v if "true" then be verbose - */ - public void setVerbose(String v) { - verbose = v; - } - - /** - * Don't stop if get fails if set to "true". - * - * @param v if "true" then be verbose - */ - public void setIgnoreErrors(String v) { - ignoreErrors = v; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java deleted file mode 100644 index 37a30402b..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Jar.java +++ /dev/null @@ -1,123 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.zip.*; - -/** - * Creates a JAR archive. - * - * @author James Davidson duncan@x180.com - */ - -public class Jar extends Zip { - - private File manifest; - - public void setJarfile(String jarFilename) { - super.setZipfile(jarFilename); - super.archiveType = "jar"; - } - - public void setManifest(String manifestFilename) { - manifest = project.resolveFile(manifestFilename); - } - - protected void initZipOutputStream(ZipOutputStream zOut) - throws IOException, BuildException - { - // add manifest first - if (manifest != null) { - super.zipDir(new File(manifest.getParent()), zOut, "META-INF/"); - super.zipFile(manifest, zOut, "META-INF/MANIFEST.MF"); - } else { - /* - * We don't store directories at all and this one will cause a lot - * of problems with STORED Zip-Mode. - * - * That's why i've removed it -- Stefan Bodewig - */ - // ZipEntry ze = new ZipEntry("META-INF/"); - // zOut.putNextEntry(ze); - String s = "/org/apache/tools/ant/defaultManifest.mf"; - InputStream in = this.getClass().getResourceAsStream(s); - if ( in == null ) - throw new BuildException ( "Could not find: " + s ); - zipFile(in, zOut, "META-INF/MANIFEST.MF", System.currentTimeMillis()); - } - } - - protected void zipDir(File dir, ZipOutputStream zOut, String vPath) - throws IOException - { - // First add directory to zip entry - if(!vPath.equals("META-INF/")) { - // we already added a META-INF - super.zipDir(dir, zOut, vPath); - } - } - - protected void zipFile(File file, ZipOutputStream zOut, String vPath) - throws IOException - { - // We already added a META-INF/MANIFEST.MF - if (!vPath.equals("META-INF/MANIFEST.MF")) { - super.zipFile(file, zOut, vPath); - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Java.java b/src/main/org/apache/tools/ant/taskdefs/Java.java deleted file mode 100644 index 4bdcaeba2..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Java.java +++ /dev/null @@ -1,214 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.lang.reflect.*; -import java.util.*; - -/** - * This task acts as a loader for java applications but allows to use the same JVM - * for the called application thus resulting in much faster operation. - * - * @author Stefano Mazzocchi stefano@apache.org - */ -public class Java extends Exec { - - private String classname = null; - private String args = null; - private String jvmargs = null; - private String classpath = null; - private boolean fork = false; - - /** - * Do the execution. - */ - public void execute() throws BuildException { - - project.log("Calling " + classname, "java", project.MSG_VERBOSE); - - if (classname == null) { - throw new BuildException("Classname must not be null."); - } - - if (fork) { - StringBuffer b = new StringBuffer(); - b.append("java "); - if (classpath != null) { - b.append("-classpath "); - b.append(classpath); - b.append(" "); - } - if (jvmargs != null) { - b.append(jvmargs); - b.append(" "); - } - b.append(classname); - if (args != null) { - b.append(" "); - b.append(args); - } - - run(b.toString()); - } else { - Vector argList = tokenize(args); - if (jvmargs != null) project.log("JVM args and classpath ignored when same JVM is used.", "java", project.MSG_VERBOSE); - project.log("Java args: " + argList.toString(), "java", project.MSG_VERBOSE); - run(classname, argList); - } - } - - /** - * Set the classpath to be used for this compilation. - */ - public void setClasspath(String s) { - this.classpath = project.translatePath(s); - } - - /** - * Set the source file (deprecated). - */ - public void setClass(String s) { - project.log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); - this.classname = s; - } - - /** - * Set the source file. - */ - public void setClassname(String s) { - this.classname = s; - } - - /** - * Set the destination file. - */ - public void setArgs(String s) { - this.args = s; - } - - /** - * Set the forking flag. - */ - public void setFork(String s) { - this.fork = Project.toBoolean(s); - } - - /** - * Set the jvm arguments. - */ - public void setJvmargs(String s) { - this.jvmargs = s; - } - - /** - * Executes the given classname with the given arguments as it - * was a command line application. - */ - protected void run(String classname, Vector args) throws BuildException { - try { - Class[] param = { Class.forName("[Ljava.lang.String;") }; - Class c = Class.forName(classname); - Method main = c.getMethod("main", param); - Object[] a = { array(args) }; - main.invoke(null, a); - } catch (NullPointerException e) { - throw new BuildException("Could not find main() method in " + classname); - } catch (ClassNotFoundException e) { - throw new BuildException("Could not find " + classname + ". Make sure you have it in your classpath"); - } catch (InvocationTargetException e) { - Throwable t = e.getTargetException(); - if (!(t instanceof SecurityException)) { - throw new BuildException(t.toString()); - } - // else ignore because the security exception is thrown - // if the invoked application tried to call System.exit() - } catch (Exception e) { - throw new BuildException(e.toString()); - } - } - - /** - * Transforms an argument string into a vector of strings. - */ - protected Vector tokenize(String args) { - Vector v = new Vector(); - if (args == null) return v; - - StringTokenizer t = new StringTokenizer(args, " "); - - while (t.hasMoreTokens()) { - v.addElement(t.nextToken()); - } - - return v; - } - - /** - * Transforms a vector of strings into an array. - */ - protected String[] array(Vector v) { - String[] s = new String[v.size()]; - Enumeration e = v.elements(); - - for (int i = 0; e.hasMoreElements(); i++) { - s[i] = (String) e.nextElement(); - } - - return s; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java deleted file mode 100644 index 0b63a4535..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ /dev/null @@ -1,699 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.lang.reflect.Method; -import java.io.*; -import java.util.*; - -/** - * Task to compile Java source files. This task can take the following - * arguments: - *
    - *
  • sourcedir - *
  • destdir - *
  • deprecation - *
  • classpath - *
  • bootclasspath - *
  • extdirs - *
  • optimize - *
  • debug - *
  • target - *
- * Of these arguments, the sourcedir and destdir are required. - *

- * When this task executes, it will recursively scan the sourcedir and - * destdir looking for Java source files to compile. This task makes its - * compile decision based on timestamp. Any other file in the - * sourcedir will be copied to the destdir allowing support files to be - * located properly in the classpath. - * - * @author James Davidson duncan@x180.com - * @author Robin Green greenrd@hotmail.com - */ - -public class Javac extends MatchingTask { - - /** - * Integer returned by the "Modern" jdk1.3 compiler to indicate success. - */ - private static final int - MODERN_COMPILER_SUCCESS = 0; - - private File srcDir; - private File destDir; - private String compileClasspath; - private boolean debug = false; - private boolean optimize = false; - private boolean deprecation = false; - private boolean filtering = false; - private String target; - private String bootclasspath; - private String extdirs; - - protected Vector compileList = new Vector(); - protected Hashtable filecopyList = new Hashtable(); - - /** - * Set the source dir to find the source Java files. - */ - public void setSrcdir(String srcDirName) { - srcDir = project.resolveFile(srcDirName); - } - - /** - * Set the destination directory into which the Java source - * files should be compiled. - */ - public void setDestdir(String destDirName) { - destDir = project.resolveFile(destDirName); - } - - /** - * Set the classpath to be used for this compilation. - */ - public void setClasspath(String classpath) { - compileClasspath = project.translatePath(classpath); - } - - /** - * Sets the bootclasspath that will be used to compile the classes - * against. - */ - public void setBootclasspath(String bootclasspath) { - this.bootclasspath = project.translatePath(bootclasspath); - } - - /** - * Sets the extension directories that will be used during the - * compilation. - */ - public void setExtdirs(String extdirs) { - this.extdirs = project.translatePath(extdirs); - } - - /** - * Set the deprecation flag. - */ - public void setDeprecation(String deprecationString) { - this.deprecation = Project.toBoolean(deprecationString); - } - - /** - * Set the debug flag. - */ - public void setDebug(String debugString) { - this.debug = Project.toBoolean(debugString); - } - - /** - * Set the optimize flag. - */ - public void setOptimize(String optimizeString) { - this.optimize = Project.toBoolean(optimizeString); - } - - /** - * Sets the target VM that the classes will be compiled for. Valid - * strings are "1.1", "1.2", and "1.3". - */ - public void setTarget(String target) { - this.target = target; - } - - /** - * Set the filtering flag. - */ - public void setFiltering(String filter) { - filtering = Project.toBoolean(filter); - } - - /** - * Executes the task. - */ - public void execute() throws BuildException { - // first off, make sure that we've got a srcdir and destdir - - if (srcDir == null) { - throw new BuildException("srcdir attribute must be set!"); - } - if (!srcDir.exists()) { - throw new BuildException("srcdir does not exist!"); - } - if (destDir == null) { - throw new BuildException("destdir attribute must be set!"); - } - - // scan source and dest dirs to build up both copy lists and - // compile lists - - DirectoryScanner ds = this.getDirectoryScanner(srcDir); - - String[] files = ds.getIncludedFiles(); - - scanDir(srcDir, destDir, files); - - // compile the source files - - String compiler = project.getProperty("build.compiler"); - if (compiler == null) { - if (Project.getJavaVersion().startsWith("1.3")) { - compiler = "modern"; - } else { - compiler = "classic"; - } - } - - if (compileList.size() > 0) { - project.log("Compiling " + compileList.size() + - " source files to " + destDir); - - if (compiler.equalsIgnoreCase("classic")) { - doClassicCompile(); - } else if (compiler.equalsIgnoreCase("modern")) { - doModernCompile(); - } else if (compiler.equalsIgnoreCase("jikes")) { - doJikesCompile(); - } else { - String msg = "Don't know how to use compiler " + compiler; - throw new BuildException(msg); - } - } - - // copy the support files - - if (filecopyList.size() > 0) { - project.log("The implicit copying of support files by javac has been deprecated. " + - "Use the copydir task to copy support files explicitly.", - Project.MSG_WARN); - - project.log("Copying " + filecopyList.size() + - " support files to " + destDir.getAbsolutePath()); - Enumeration enum = filecopyList.keys(); - while (enum.hasMoreElements()) { - String fromFile = (String) enum.nextElement(); - String toFile = (String) filecopyList.get(fromFile); - try { - project.copyFile(fromFile, toFile, filtering); - } catch (IOException ioe) { - String msg = "Failed to copy " + fromFile + " to " + toFile - + " due to " + ioe.getMessage(); - throw new BuildException(msg); - } - } - } - } - - /** - * Scans the directory looking for source files to be compiled and - * support files to be copied. The results are returned in the - * class variables compileList and filecopyList. - */ - - protected void scanDir(File srcDir, File destDir, String files[]) { - - compileList.removeAllElements(); - filecopyList.clear(); - - long now = (new Date()).getTime(); - - for (int i = 0; i < files.length; i++) { - File srcFile = new File(srcDir, files[i]); - if (files[i].endsWith(".java")) { - File classFile = new File(destDir, files[i].substring(0, - files[i].indexOf(".java")) + ".class"); - - if (srcFile.lastModified() > now) { - project.log("Warning: file modified in the future: " + - files[i], project.MSG_WARN); - } - - if (srcFile.lastModified() > classFile.lastModified()) { - compileList.addElement(srcFile.getAbsolutePath()); - } - } else { - File destFile = new File(destDir, files[i]); - if (srcFile.lastModified() > destFile.lastModified()) { - filecopyList.put(srcFile.getAbsolutePath(), - destFile.getAbsolutePath()); - } - } - } - } - - /** - * Builds the compilation classpath. - */ - - // XXX - // we need a way to not use the current classpath. - - private String getCompileClasspath() { - StringBuffer classpath = new StringBuffer(); - - // add dest dir to classpath so that previously compiled and - // untouched classes are on classpath - - //classpath.append(sourceDir.getAbsolutePath()); - //classpath.append(File.pathSeparator); - classpath.append(destDir.getAbsolutePath()); - - // add our classpath to the mix - - if (compileClasspath != null) { - addExistingToClasspath(classpath,compileClasspath); - } - - // add the system classpath - - addExistingToClasspath(classpath,System.getProperty("java.class.path")); - return classpath.toString(); - } - - - /** - * Takes a classpath-like string, and adds each element of - * this string to a new classpath, if the components exist. - * Components that don't exist, aren't added. - * We do this, because jikes issues warnings for non-existant - * files/dirs in his classpath, and these warnings are pretty - * annoying. - * @param target - target classpath - * @param source - source classpath - * to get file objects. - */ - private void addExistingToClasspath(StringBuffer target,String source) { - StringTokenizer tok = new StringTokenizer(source, - System.getProperty("path.separator"), false); - while (tok.hasMoreTokens()) { - File f = project.resolveFile(tok.nextToken()); - - if (f.exists()) { - target.append(File.pathSeparator); - target.append(f.getAbsolutePath()); - } else { - project.log("Dropping from classpath: "+ - f.getAbsolutePath(),project.MSG_VERBOSE); - } - } - - } - - /** - * Peforms a copmile using the classic compiler that shipped with - * JDK 1.1 and 1.2. - */ - - private void doClassicCompile() throws BuildException { - project.log("Using classic compiler", project.MSG_VERBOSE); - String classpath = getCompileClasspath(); - Vector argList = new Vector(); - - if (deprecation == true) - argList.addElement("-deprecation"); - - argList.addElement("-d"); - argList.addElement(destDir.getAbsolutePath()); - argList.addElement("-classpath"); - // Just add "sourcepath" to classpath ( for JDK1.1 ) - if (Project.getJavaVersion().startsWith("1.1")) { - argList.addElement(classpath + File.pathSeparator + - srcDir.getAbsolutePath()); - } else { - argList.addElement(classpath); - argList.addElement("-sourcepath"); - argList.addElement(srcDir.getAbsolutePath()); - if (target != null) { - argList.addElement("-target"); - argList.addElement(target); - } - } - if (debug) { - argList.addElement("-g"); - } - if (optimize) { - argList.addElement("-O"); - } - if (bootclasspath != null) { - argList.addElement("-bootclasspath"); - argList.addElement(bootclasspath); - } - if (extdirs != null) { - argList.addElement("-extdirs"); - argList.addElement(extdirs); - } - - project.log("Compilation args: " + argList.toString(), - project.MSG_VERBOSE); - - String[] args = new String[argList.size() + compileList.size()]; - int counter = 0; - - for (int i = 0; i < argList.size(); i++) { - args[i] = (String)argList.elementAt(i); - counter++; - } - - // XXX - // should be using system independent line feed! - - StringBuffer niceSourceList = new StringBuffer("Files to be compiled:" - + "\r\n"); - - Enumeration enum = compileList.elements(); - while (enum.hasMoreElements()) { - args[counter] = (String)enum.nextElement(); - niceSourceList.append(" " + args[counter] + "\r\n"); - counter++; - } - - project.log(niceSourceList.toString(), project.MSG_VERBOSE); - - // XXX - // provide the compiler a different message sink - namely our own - - ByteArrayOutputStream out = new ByteArrayOutputStream(); - sun.tools.javac.Main compiler = new sun.tools.javac.Main(out, "javac"); - - if (compiler.compile(args)) { - String output = out.toString().trim(); - if (output.length() > 0) { - project.log(output, Project.MSG_WARN); - } - } - else { - project.log(out.toString().trim(), Project.MSG_ERR); - - throw new BuildException("Compile failed"); - } - } - - /** - * Performs a compile using the newer compiler that ships with JDK 1.3 - */ - - private void doModernCompile() throws BuildException { - project.log("Using modern compiler", project.MSG_VERBOSE); - String classpath = getCompileClasspath(); - Vector argList = new Vector(); - - if (deprecation == true) - argList.addElement("-deprecation"); - - argList.addElement("-d"); - argList.addElement(destDir.getAbsolutePath()); - argList.addElement("-classpath"); - argList.addElement(classpath); - argList.addElement("-sourcepath"); - argList.addElement(srcDir.getAbsolutePath()); - if (target != null) { - argList.addElement("-target"); - argList.addElement(target); - } - if (debug) { - argList.addElement("-g"); - } - if (optimize) { - argList.addElement("-O"); - } - if (bootclasspath != null) { - argList.addElement("-bootclasspath"); - argList.addElement(bootclasspath); - } - if (extdirs != null) { - argList.addElement("-extdirs"); - argList.addElement(extdirs); - } - - project.log("Compilation args: " + argList.toString(), - project.MSG_VERBOSE); - - String[] args = new String[argList.size() + compileList.size()]; - int counter = 0; - - for (int i = 0; i < argList.size(); i++) { - args[i] = (String)argList.elementAt(i); - counter++; - } - - // XXX - // should be using system independent line feed! - - StringBuffer niceSourceList = new StringBuffer("Files to be compiled:" - + "\r\n"); - - Enumeration enum = compileList.elements(); - while (enum.hasMoreElements()) { - args[counter] = (String)enum.nextElement(); - niceSourceList.append(" " + args[counter] + "\r\n"); - counter++; - } - - project.log(niceSourceList.toString(), project.MSG_VERBOSE); - - // This won't build under JDK1.2.2 because the new compiler - // doesn't exist there. - //com.sun.tools.javac.Main compiler = new com.sun.tools.javac.Main(); - //if (compiler.compile(args) != 0) { - - // Use reflection to be able to build on all JDKs >= 1.1: - try { - Class c = Class.forName ("com.sun.tools.javac.Main"); - Object compiler = c.newInstance (); - Method compile = c.getMethod ("compile", - new Class [] {(new String [] {}).getClass ()}); - int result = ((Integer) compile.invoke - (compiler, new Object [] {args})) .intValue (); - if (result != MODERN_COMPILER_SUCCESS) { - String msg = - "Compile failed, messages should have been provided."; - throw new BuildException(msg); - } - } catch (Exception ex) { - throw new BuildException (ex); - } - - } - - /** - * Performs a compile using the Jikes compiler from IBM.. - * Mostly of this code is identical to doClassicCompile() - * However, it does not support all options like - * bootclasspath, extdirs, deprecation and so on, because - * there is no option in jikes and I don't understand - * what they should do. - * - * It has been successfully tested with jikes 1.10 - * - * @author skanthak@muehlheim.de - */ - - private void doJikesCompile() throws BuildException { - project.log("Using jikes compiler",project.MSG_VERBOSE); - - StringBuffer classpath = new StringBuffer(); - classpath.append(getCompileClasspath()); - - // Jikes doesn't support an extension dir (-extdir) - // so we'll emulate it for compatibility and convenience. - addExtdirsToClasspath(classpath); - - // Jikes has no option for source-path so we - // will add it to classpath. - classpath.append(File.pathSeparator); - classpath.append(srcDir.getAbsolutePath()); - - Vector argList = new Vector(); - - if (deprecation == true) - argList.addElement("-deprecation"); - - // We want all output on stdout to make - // parsing easier - argList.addElement("-Xstdout"); - - argList.addElement("-d"); - argList.addElement(destDir.getAbsolutePath()); - argList.addElement("-classpath"); - argList.addElement(classpath.toString()); - - if (debug) { - argList.addElement("-g"); - } - if (optimize) { - argList.addElement("-O"); - } - - /** - * XXX - * Perhaps we shouldn't use properties for these - * two options (emacs mode and warnings), - * but include it in the javac directive? - */ - - /** - * Jikes has the nice feature to print error - * messages in a form readable by emacs, so - * that emcas can directly set the cursor - * to the place, where the error occured. - */ - boolean emacsMode = false; - String emacsProperty = project.getProperty("build.compiler.emacs"); - if (emacsProperty != null && - (emacsProperty.equalsIgnoreCase("on") || - emacsProperty.equalsIgnoreCase("true")) - ) { - emacsMode = true; - } - - /** - * Jikes issues more warnings that javac, for - * example, when you have files in your classpath - * that don't exist. As this is often the case, these - * warning can be pretty annoying. - */ - boolean warnings = true; - String warningsProperty = project.getProperty("build.compiler.warnings"); - if (warningsProperty != null && - (warningsProperty.equalsIgnoreCase("off") || - warningsProperty.equalsIgnoreCase("false")) - ) { - warnings = false; - } - - if (emacsMode) - argList.addElement("+E"); - - if (!warnings) - argList.addElement("-nowarn"); - - project.log("Compilation args: " + argList.toString(), - project.MSG_VERBOSE); - - String[] args = new String[argList.size() + compileList.size()]; - int counter = 0; - - for (int i = 0; i < argList.size(); i++) { - args[i] = (String)argList.elementAt(i); - counter++; - } - - // XXX - // should be using system independent line feed! - - StringBuffer niceSourceList = new StringBuffer("Files to be compiled:" - + "\r\n"); - - Enumeration enum = compileList.elements(); - while (enum.hasMoreElements()) { - args[counter] = (String)enum.nextElement(); - niceSourceList.append(" " + args[counter] + "\r\n"); - counter++; - } - - project.log(niceSourceList.toString(), project.MSG_VERBOSE); - - // XXX - // provide the compiler a different message sink - namely our own - - JikesOutputParser jop = new JikesOutputParser(project,emacsMode); - - Jikes compiler = new Jikes(jop,"jikes"); - compiler.compile(args); - if (jop.getErrorFlag()) { - String msg = "Compile failed, messages should have been provided."; - throw new BuildException(msg); - } - } - - class JarFilenameFilter implements FilenameFilter { - public boolean accept(File dir,String name) { - return name.endsWith(".jar"); - } - } - - /** - * Emulation of extdirs feature in java >= 1.2. - * This method adds all jar archives in the given - * directories (but not in sub-directories!) to the classpath, - * so that you don't have to specify them all one by one. - * @param classpath - stringbuffer to append jar files to - */ - private void addExtdirsToClasspath(StringBuffer classpath) { - // FIXME - // Should we scan files recursively? How does - // javac handle this? - - if (extdirs != null) { - StringTokenizer tok = new StringTokenizer(extdirs, - File.pathSeparator, - false); - while (tok.hasMoreTokens()) { - File dir = project.resolveFile(tok.nextToken()); - String[] files = dir.list(new JarFilenameFilter()); - for (int i=0 ; i < files.length ; i++) { - File f = new File(dir,files[i]); - if (f.exists() && f.isFile()) { - classpath.append(File.pathSeparator); - classpath.append(f.getAbsolutePath()); - } - } - } - } - } -} - diff --git a/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java b/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java deleted file mode 100644 index 5fdd11e01..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Serves as an output stream to Javac. This let's us print messages - * out to the project and detect whether or not Javac had an error - * while compiling. - * - * @author James Duncan Davidson (duncan@x180.com) - */ - -class JavacOutputStream extends OutputStream { - - private Project project; - private StringBuffer line; - private boolean errorFlag = false; - - /** - * Constructs a new JavacOutputStream with the given project - * as the output source for messages. - */ - - JavacOutputStream(Project project) { - this.project = project; - line = new StringBuffer(); - } - - /** - * Write a character to the output stream. This method looks - * to make sure that there isn't an error being reported and - * will flush each line of input out to the project's log stream. - */ - - public void write(int c) throws IOException { - char cc = (char)c; - if (cc == '\r' || cc == '\n') { - // line feed - if (line.length() > 0) { - processLine(); - } - } else { - line.append(cc); - } - } - - /** - * Processes a line of input and determines if an error occured. - */ - - private void processLine() { - String s = line.toString(); - if (s.indexOf("error") > -1) { - errorFlag = true; - } - project.log(s); - line = new StringBuffer(); - } - - /** - * Returns the error status of the compile. If no errors occured, - * this method will return false, else this method will return true. - */ - - boolean getErrorFlag() { - return errorFlag; - } -} - diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java deleted file mode 100644 index 27fc1c792..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ /dev/null @@ -1,800 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * This Task makes it easy to generate javadocs for a collection of source code. - * - * Current known limitations are: - * - multiple source path breaks operation - * - patterns must be of the form "xxx.*", every other pattern doesn't work. - * - the java comment-stripper reader is horribly slow - * - there is no control on arguments sanity since they are left - * to the javadoc implementation. - * - argument J in javadoc1 is not supported (what is that for anyway?) - * - * Note: This task is run on another VM because stupid Javadoc calls - * System.exit() that would break Ant functionality. - * - * @author Jon S. Stevens jon@clearink.com - * @author Stefano Mazzocchi stefano@apache.org - * @author Patrick Chanezon chanezon@netscape.com - */ - -public class Javadoc extends Exec { - - private String maxmemory = null; - private String sourcePath = null; - private String additionalParam = null; - private File destDir = null; - private File overviewFile = null; - private String sourceFiles = null; - private String packageNames = null; - private boolean pub = false; - private boolean prot = false; - private boolean pack = false; - private boolean priv = false; - private boolean author = true; - private boolean version = true; - private String doclet = null; - private File docletpath = null; - private boolean old = false; - private String classpath = null; - private String bootclasspath = null; - private String extdirs = null; - private boolean verbose = false; - private String locale = null; - private String encoding = null; - private boolean use = false; - private boolean splitindex = false; - private String windowtitle = null; - private String doctitle = null; - private String header = null; - private String footer = null; - private String bottom = null; - private String linkoffline = null; - private String link = null; - private String group = null; - private boolean nodeprecated = false; - private boolean nodeprecatedlist = false; - private boolean notree = false; - private boolean noindex = false; - private boolean nohelp = false; - private boolean nonavbar = false; - private File stylesheetfile = null; - private File helpfile = null; - private String docencoding = null; - private Vector compileList = new Vector(10); - private String packageList = null; - private Vector links = new Vector(2); - private Vector groups = new Vector(2); - - public void setMaxmemory(String src){ - maxmemory = src; - } - - public void setadditionalParam(String src){ - additionalParam = src; - } - - public void setSourcepath(String src) { - sourcePath = project.translatePath(src); - } - public void setDestdir(String src) { - destDir = project.resolveFile(src); - } - public void setSourcefiles(String src) { - sourceFiles = src; - } - public void setPackagenames(String src) { - packageNames = src; - } - public void setOverview(String src) { - overviewFile = project.resolveFile(src); - } - public void setPublic(String src) { - pub = Project.toBoolean(src); - } - public void setProtected(String src) { - prot = Project.toBoolean(src); - } - public void setPackage(String src) { - pack = Project.toBoolean(src); - } - public void setPrivate(String src) { - priv = Project.toBoolean(src); - } - public void setDoclet(String src) { - doclet = src; - } - public void setDocletPath(String src) { - docletpath = project.resolveFile(src); - } - public void setOld(String src) { - old = Project.toBoolean(src); - } - public void setClasspath(String src) { - classpath = project.translatePath(src); - } - public void setBootclasspath(String src) { - bootclasspath = project.translatePath(src); - } - public void setExtdirs(String src) { - extdirs = src; - } - public void setVerbose(String src) { - verbose = Project.toBoolean(src); - } - public void setLocale(String src) { - locale = src; - } - public void setEncoding(String src) { - encoding = src; - } - public void setVersion(String src) { - version = Project.toBoolean(src); - } - public void setUse(String src) { - use = Project.toBoolean(src); - } - public void setAuthor(String src) { - author = Project.toBoolean(src); - } - public void setSplitindex(String src) { - splitindex = Project.toBoolean(src); - } - public void setWindowtitle(String src) { - windowtitle = src; - } - public void setDoctitle(String src) { - doctitle = src; - } - public void setHeader(String src) { - header = src; - } - public void setFooter(String src) { - footer = src; - } - public void setBottom(String src) { - bottom = src; - } - public void setLinkoffline(String src) { - linkoffline = src; - } - public void setGroup(String src) { - group = src; - } - public void setLink(String src) { - link = src; - } - public void setNodeprecated(String src) { - nodeprecated = Project.toBoolean(src); - } - public void setNodeprecatedlist(String src) { - nodeprecatedlist = Project.toBoolean(src); - } - public void setNotree(String src) { - notree = Project.toBoolean(src); - } - public void setNoindex(String src) { - noindex = Project.toBoolean(src); - } - public void setNohelp(String src) { - nohelp = Project.toBoolean(src); - } - public void setNonavbar(String src) { - nonavbar = Project.toBoolean(src); - } - public void setStylesheetfile(String src) { - stylesheetfile = project.resolveFile(src); - } - public void setDocencoding(String src) { - docencoding = src; - } - public void setPackageList(String src) { - packageList = src; - } - - public LinkArgument createLink() { - LinkArgument la = new LinkArgument(); - links.addElement(la); - return la; - } - - public class LinkArgument { - private String href; - private boolean offline = false; - private String packagelistLoc; - - public LinkArgument() { - } - - public void setHref(String hr) { - href = hr; - } - - public String getHref() { - return href; - } - - public void setPackagelistLoc(String src) { - packagelistLoc = src; - } - - public String getPackagelistLoc() { - return packagelistLoc; - } - - public void setOffline(String offline) { - this.offline = Project.toBoolean(offline); - } - - public boolean isLinkOffline() { - return offline; - } - } - - public GroupArgument createGroup() { - GroupArgument ga = new GroupArgument(); - groups.addElement(ga); - return ga; - } - - public class GroupArgument { - private String title; - private String packages; - - public GroupArgument() { - } - - public void setTitle(String src) { - title = src; - } - - public String getTitle() { - return title; - } - - public void setPackages(String src) { - packages = src; - } - - public String getPackages() { - return packages; - } - } - - public void execute() throws BuildException { - if (sourcePath == null && destDir == null ) { - String msg = "sourcePath and destDir attributes must be set!"; - throw new BuildException(msg); - } - - boolean javadoc1 = (Project.getJavaVersion() == Project.JAVA_1_1); - - project.log("Generating Javadoc", project.MSG_INFO); - - Vector argList = new Vector(); - -// ------------------------------------------------ general javadoc arguments - if (classpath == null) - classpath = System.getProperty("java.class.path"); - - - if(maxmemory != null){ - if(javadoc1){ - argList.addElement("-J-mx" + maxmemory); - } - else{ - argList.addElement("-J-Xmx" + maxmemory); - } - } - - if ( (!javadoc1) || (sourcePath == null) ) { - argList.addElement("-classpath"); - argList.addElement(classpath); - if (sourcePath != null) { - argList.addElement("-sourcepath"); - argList.addElement(sourcePath); - } - } else { - argList.addElement("-classpath"); - argList.addElement(sourcePath + - System.getProperty("path.separator") + classpath); - } - - if (destDir != null) { - argList.addElement("-d"); - argList.addElement(destDir.getAbsolutePath()); - } - if (version) - argList.addElement ("-version"); - if (nodeprecated) - argList.addElement ("-nodeprecated"); - if (author) - argList.addElement ("-author"); - if (noindex) - argList.addElement ("-noindex"); - if (notree) - argList.addElement ("-notree"); - if (pub) - argList.addElement ("-public"); - if (prot) - argList.addElement ("-protected"); - if (pack) - argList.addElement ("-package"); - if (priv) - argList.addElement ("-private"); - if (encoding != null) { - argList.addElement("-encoding"); - argList.addElement(encoding); - } - if (docencoding != null) { - argList.addElement("-docencoding"); - argList.addElement(docencoding); - } - -// --------------------------------- javadoc2 arguments for default doclet - -// XXX: how do we handle a custom doclet? - - if (!javadoc1) { - if (overviewFile != null) { - argList.addElement("-overview"); - argList.addElement(overviewFile.getAbsolutePath()); - } - if (old) - argList.addElement("-1.1"); - if (verbose) - argList.addElement("-verbose"); - if (use) - argList.addElement("-use"); - if (splitindex) - argList.addElement("-splitindex"); - if (nodeprecatedlist) - argList.addElement("-nodeprecatedlist"); - if (nohelp) - argList.addElement("-nohelp"); - if (nonavbar) - argList.addElement("-nonavbar"); - if (doclet != null) { - argList.addElement("-doclet"); - argList.addElement(doclet); - } - if (bootclasspath != null) { - argList.addElement("-bootclasspath"); - argList.addElement(bootclasspath); - } - if (extdirs != null) { - argList.addElement("-extdirs"); - argList.addElement(extdirs); - } - if (locale != null) { - argList.addElement("-locale"); - argList.addElement(locale); - } - if (encoding != null) { - argList.addElement("-encoding"); - argList.addElement(encoding); - } - if (windowtitle != null) { - argList.addElement("-windowtitle"); - argList.addElement(windowtitle); - } - if (doctitle != null) { - argList.addElement("-doctitle"); - argList.addElement(doctitle); - } - if (header != null) { - argList.addElement("-header"); - argList.addElement(header); - } - if (footer != null) { - argList.addElement("-footer"); - argList.addElement(footer); - } - if (bottom != null) { - argList.addElement("-bottom"); - argList.addElement(bottom); - } - - // add the single link arguments - if (link != null) { - argList.addElement("-link"); - argList.addElement(link); - } - - // add the links arguments - if (links.size() != 0) { - for (Enumeration e = links.elements(); e.hasMoreElements(); ) { - LinkArgument la = (LinkArgument)e.nextElement(); - - if (la.getHref() == null) { - throw new BuildException("Links must provide the RUL to the external class documentation."); - } - - if (la.isLinkOffline()) { - String packageListLocation = la.getPackagelistLoc(); - if (packageListLocation == null) { - throw new BuildException("The package list location for link " + la.getHref() + - " must be provided because the link is offline"); - } - argList.addElement("-linkoffline"); - argList.addElement(la.getHref()); - argList.addElement(packageListLocation); - } - else { - argList.addElement("-link"); - argList.addElement(la.getHref()); - } - } - } - - // add the single linkoffline arguments - if (linkoffline != null) { - argList.addElement("-linkoffline"); - argList.addElement(linkoffline); - } - - // add the single group arguments - // Javadoc 1.2 rules: - // Multiple -group args allowed. - // Each arg includes 3 strings: -group [name] [packagelist]. - // Elements in [packagelist] are colon-delimited. - // An element in [packagelist] may end with the * wildcard. - - // Ant javadoc task rules for group attribute: - // Args are comma-delimited. - // Each arg is 2 space-delimited strings. - // E.g., group="XSLT_Packages org.apache.xalan.xslt*,XPath_Packages orgapache.xalan.xpath*" - if (group != null) { - StringTokenizer tok = new StringTokenizer(group, ",", false); - while (tok.hasMoreTokens()) { - String grp = tok.nextToken().trim(); - int space = grp.indexOf(" "); - if (space > 0){ - String name = grp.substring(0, space); - String pkgList = grp.substring(space + 1); - argList.addElement("-group"); - argList.addElement(name); - argList.addElement(pkgList); - } - } - } - - // add the group arguments - if (groups.size() != 0) { - for (Enumeration e = groups.elements(); e.hasMoreElements(); ) { - GroupArgument ga = (GroupArgument)e.nextElement(); - String title = ga.getTitle(); - String packages = ga.getPackages(); - if (title == null || packages == null) { - throw new BuildException("The title and packages must be specified for group elements."); - } - argList.addElement("-group"); - argList.addElement(title); - argList.addElement(packages); - } - } - - if (stylesheetfile != null) { - argList.addElement("-stylesheetfile"); - argList.addElement(stylesheetfile.getAbsolutePath()); - } - if (helpfile != null) { - argList.addElement("-helpfile"); - argList.addElement(helpfile.getAbsolutePath()); - } - if (additionalParam != null) { - argList.addElement(additionalParam); - } - } - - if ((packageNames != null) && (packageNames.length() > 0)) { - Vector packages = new Vector(); - StringTokenizer tok = new StringTokenizer(packageNames, ",", false); - while (tok.hasMoreTokens()) { - String name = tok.nextToken().trim(); - if (name.endsWith(".*")) { - packages.addElement(name); - } else { - argList.addElement(name); - } - } - if (packages.size() > 0) { - evaluatePackages(sourcePath, packages, argList); - } - } - - if ((sourceFiles != null) && (sourceFiles.length() > 0)) { - StringTokenizer tok = new StringTokenizer(sourceFiles, ",", false); - while (tok.hasMoreTokens()) { - argList.addElement(tok.nextToken().trim()); - } - } - - if (packageList != null) { - argList.addElement("@" + packageList); - } - project.log("Javadoc args: " + argList.toString(), "javadoc", project.MSG_VERBOSE); - - project.log("Javadoc execution", project.MSG_INFO); - - StringBuffer b = new StringBuffer(); - b.append("javadoc "); - - Enumeration e = argList.elements(); - while (e.hasMoreElements()) { - String arg = (String) e.nextElement(); - if (!arg.startsWith("-")) { - b.append("\""); - b.append(arg); - b.append("\""); - } else { - b.append(arg); - } - if (e.hasMoreElements()) b.append(" "); - } - - run(b.toString()); - } - - /** - * Given a source path, a list of package patterns, fill the given list - * with the packages found in that path subdirs matching one of the given - * patterns. - */ - private void evaluatePackages(String sourcePath, Vector packages, Vector argList) { - project.log("Parsing source files for packages", project.MSG_INFO); - project.log("Source path = " + sourcePath, project.MSG_VERBOSE); - project.log("Packages = " + packages, project.MSG_VERBOSE); - - Vector addedPackages = new Vector(); - PathTokenizer tokenizer = new PathTokenizer(sourcePath); - while (tokenizer.hasMoreTokens()) { - File source = new File(project.translatePath(tokenizer.nextToken())); - - Hashtable map = mapClasses(source); - - Enumeration e = map.keys(); - while (e.hasMoreElements()) { - String pack = (String) e.nextElement(); - for (int i = 0; i < packages.size(); i++) { - if (matches(pack, (String) packages.elementAt(i))) { - if (!addedPackages.contains(pack)) { - argList.addElement(pack); - addedPackages.addElement(pack); - } - break; - } - } - } - } - } - - /** - * Implements the pattern matching. For now it's only able to - * guarantee that "aaa.bbb.ccc" matches "aaa.*" and "aaa.bbb.*" - * FIXME: this code needs much improvement. - */ - private boolean matches(String string, String pattern) { - return string.startsWith(pattern.substring(0, pattern.length() - 2)); - } - - /** - * Returns an hashtable of packages linked to the last parsed - * file in that package. This map is use to return a list of unique - * packages as map keys. - */ - private Hashtable mapClasses(File path) { - Hashtable map = new Hashtable(); - - Vector files = new Vector(); - getFiles(path, files); - - Enumeration e = files.elements(); - while (e.hasMoreElements()) { - File file = (File) e.nextElement(); - String packageName = getPackageName(file); - if (packageName != null) map.put(packageName, file); - } - - return map; - } - - /** - * Fills the given vector with files under the given path filtered - * by the given file filter. - */ - private void getFiles(File path, Vector list) { - if (!path.exists()) { - throw new BuildException("Path " + path + " does not exist."); - } - - String[] files = path.list(); - String cwd = path.getPath() + System.getProperty("file.separator"); - - if (files != null) { - int count = 0; - for (int i = 0; i < files.length; i++) { - File file = new File(cwd + files[i]); - if (file.isDirectory()) { - getFiles(file, list); - } else if (files[i].endsWith(".java")) { - count++; - list.addElement(file); - } - } - if (count > 0) { - project.log("found " + count + " source files in " + path, "javadoc", project.MSG_VERBOSE); - } - } else { - throw new BuildException("Error occurred during " + path + " evaluation."); - } - } - - /** - * Return the package name of the given java source file. - * This method performs valid java parsing to figure out the package. - */ - private String getPackageName(File file) { - String name = null; - - try { - // do not remove the double buffered reader, this is a _major_ speed up in this special case! - BufferedReader reader = new BufferedReader(new JavaReader(new BufferedReader(new FileReader(file)))); - String line; - while (true) { - line = reader.readLine(); - if (line == null) { - project.log("Could not evaluate package for " + file, "javadoc", project.MSG_WARN); - return null; - } - if (line.trim().startsWith("package ")) { - name = line.substring(8, line.indexOf(";")).trim(); - break; - } - } - reader.close(); - } catch (Exception e) { - project.log("Exception " + e + " parsing " + file, "javadoc", project.MSG_WARN); - return null; - } - - project.log(file + " --> " + name, "javadoc", project.MSG_VERBOSE); - - return name; - } - - /** - * This is a java comment and string stripper reader that filters - * these lexical tokens out for purposes of simple Java parsing. - * (if you have more complex Java parsing needs, use a real lexer). - * Since this class heavily relies on the single char read function, - * you are reccomended to make it work on top of a buffered reader. - */ - class JavaReader extends FilterReader { - - public JavaReader(Reader in) { - super(in); - } - - public int read() throws IOException { - int c = in.read(); - if (c == '/') { - c = in.read(); - if (c == '/') { - while (c != '\n' && c != -1) c = in.read(); - } else if (c == '*') { - while (c != -1) { - c = in.read(); - if (c == '*') { - c = in.read(); - if (c == '/') { - c = read(); - break; - } - } - } - } - } - if (c == '"') { - while (c != -1) { - c = in.read(); - if (c == '\\') { - c = in.read(); - } else if (c == '"') { - c = read(); - break; - } - } - } - if (c == '\'') { - c = in.read(); - if (c == '\\') c = in.read(); - c = in.read(); - c = read(); - } - return c; - } - - public int read(char cbuf[], int off, int len) throws IOException { - for (int i = 0; i < len; i++) { - int c = read(); - if (c == -1) { - if (i == 0) { - return -1; - } else { - return i; - } - } - cbuf[off + i] = (char) c; - } - return len; - } - - public long skip(long n) throws IOException { - for (long i = 0; i < n; i++) { - if (in.read() == -1) return i; - } - return n; - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Jikes.java b/src/main/org/apache/tools/ant/taskdefs/Jikes.java deleted file mode 100644 index b543d8b6c..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Jikes.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.tools.ant.taskdefs; - -import java.io.*; - -/** - * Encapsulates a Jikes compiler, by - * directly executing an external process. - * @author skanthak@muehlheim.de - */ -public class Jikes { - protected JikesOutputParser jop; - protected String command; - - /** - * Constructs a new Jikes obect. - * @param jop - Parser to send jike's output to - * @param command - name of jikes executeable - */ - protected Jikes(JikesOutputParser jop,String command) { - super(); - this.jop = jop; - this.command = command; - } - - /** - * Do the compile with the specified arguments. - * @param args - arguments to pass to process on command line - */ - protected void compile(String[] args) { - String[] commandArray = new String[args.length+1]; - commandArray[0] = command; - System.arraycopy(args,0,commandArray,1,args.length); - - // We assume, that everything jikes writes goes to - // standard output, not to standard error. The option - // -Xstdout that is given to Jikes in Javac.doJikesCompile() - // should guarantee this. At least I hope so. :) - try { - Process jikes = Runtime.getRuntime().exec(commandArray); - BufferedReader reader = new BufferedReader(new InputStreamReader(jikes.getInputStream())); - jop.parseOutput(reader); - } catch (IOException e) { - // Where could we log this to? We don't have an instance - // of project. Perhaps we should add one to our constructor? - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java b/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java deleted file mode 100644 index 69d6f4d97..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.*; - -import java.io.*; - -/** - * Parses output from jikes and - * passes errors and warnings - * into the right logging channels of Project. - * - * TODO: - * Parsing could be much better - * @author skanthak@muehlheim.de - */ -public class JikesOutputParser { - protected Project project; - protected boolean errorFlag = false; // no errors so far - protected int errors,warnings; - protected boolean error = false; - protected boolean emacsMode; - - /** - * Construct a new Parser object - * @param project - project in whichs context we are called - */ - protected JikesOutputParser(Project project, boolean emacsMode) { - super(); - this.project = project; - this.emacsMode = emacsMode; - } - - /** - * Parse the output of a jikes compiler - * @param reader - Reader used to read jikes's output - */ - protected void parseOutput(BufferedReader reader) throws IOException { - if (emacsMode) - parseEmacsOutput(reader); - else - parseStandardOutput(reader); - } - - private void parseStandardOutput(BufferedReader reader) throws IOException { - String line; - String lower; - // We assume, that every output, jike does, stands for an error/warning - // XXX - // Is this correct? - - // TODO: - // A warning line, that shows code, which contains a variable - // error will cause some trouble. The parser should definitely - // be much better. - - while ((line = reader.readLine()) != null) { - lower = line.toLowerCase(); - if (line.trim().equals("")) - continue; - if (lower.indexOf("error") != -1) - setError(true); - else if (lower.indexOf("warning") != -1) - setError(false); - else { - // If we don't know the type of the line - // and we are in emacs mode, it will be - // an error, because in this mode, jikes won't - // always print "error", but sometimes other - // keywords like "Syntax". We should look for - // all those keywords. - if (emacsMode) - setError(true); - } - log(line); - } - } - - private void parseEmacsOutput(BufferedReader reader) throws IOException { - // This may change, if we add advanced parsing capabilities. - parseStandardOutput(reader); - } - - private void setError(boolean err) { - error = err; - if(error) - errorFlag = true; - } - - private void log(String line) { - if (!emacsMode) { - project.log("", (error ? Project.MSG_ERR : Project.MSG_WARN)); - } - project.log(line, (error ? Project.MSG_ERR : Project.MSG_WARN)); - } - - /** - * Indicate if there were errors during the compile - * @return if errors ocured - */ - protected boolean getErrorFlag() { - return errorFlag; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java b/src/main/org/apache/tools/ant/taskdefs/KeySubst.java deleted file mode 100644 index cf98dec77..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/KeySubst.java +++ /dev/null @@ -1,203 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Keyword substitution. Input file is written to output file. - * Do not make input file same as output file. - * Keywords in input files look like this: @foo@. See the docs for the - * setKeys method to understand how to do the substitutions. - * - * @author Jon S. Stevens jon@clearink.com - */ -public class KeySubst extends Task { - private File source = null; - private File dest = null; - private String sep = "*"; - private Hashtable replacements = new Hashtable(); - - /** - Do the execution. - */ - public void execute() throws BuildException { - project.log("!! KeySubst is deprecated. Use Filter + CopyDir instead. !!"); - project.log("Performing Substitions"); - if ( source == null || dest == null ) { - project.log("Source and destinations must not be null"); - return; - } - BufferedReader br = null; - BufferedWriter bw = null; - try { - br = new BufferedReader(new FileReader(source)); - dest.delete(); - bw = new BufferedWriter(new FileWriter(dest)); - - String line = null; - String newline = null; - int length; - line = br.readLine(); - while (line != null) { - if ( line.length() == 0 ) { - bw.newLine(); - } else { - newline = KeySubst.replace ( line, replacements ); - bw.write ( newline ); - bw.newLine(); - } - line = br.readLine(); - } - bw.flush(); - bw.close(); - br.close(); - } catch (IOException ioe) { - ioe.printStackTrace(); - } - } - /** - Set the source file. - */ - public void setSrc(String s) { - this.source=project.resolveFile(s); - } - - /** - Set the destination file. - */ - public void setDest(String dest) { - this.dest = project.resolveFile(dest); - } - - /** - Sets the seperator between name=value arguments - in setKeys(). By default it is "*". - */ - public void setSep(String sep) { - this.sep = sep; - } - /** - Format string is like this: -

- name=value*name2=value -

- Names are case sensitive. -

- Use the setSep() method to change the * to something else - if you need to use * as a name or value. - */ - public void setKeys(String keys) { - if (keys != null && keys.length() > 0) { - StringTokenizer tok = - new StringTokenizer(keys, this.sep, false); - while (tok.hasMoreTokens()) { - String token = tok.nextToken().trim(); - StringTokenizer itok = - new StringTokenizer(token, "=", false); - - String name = itok.nextToken(); - String value = itok.nextToken(); -// project.log ( "Name: " + name ); -// project.log ( "Value: " + value ); - replacements.put ( name, value ); - } - } - } - - - public static void main(String[] args) - { - try{ - Hashtable hash = new Hashtable(); - hash.put ( "VERSION", "1.0.3" ); - hash.put ( "b", "ffff" ); - System.out.println ( KeySubst.replace ( "$f ${VERSION} f ${b} jj $", hash ) ); - }catch ( Exception e) - { - e.printStackTrace(); - } - } - - /** - Does replacement on text using the hashtable of keys. - - @returns the string with the replacements in it. - */ - public static String replace ( String origString, Hashtable keys ) - throws BuildException - { - StringBuffer finalString=new StringBuffer(); - int index=0; - int i = 0; - String key = null; - while ((index = origString.indexOf("${", i)) > -1) { - key = origString.substring(index + 2, origString.indexOf("}", index+3)); - finalString.append (origString.substring(i, index)); - if ( keys.containsKey ( key ) ) { - finalString.append (keys.get(key)); - } else { - finalString.append ( "${" ); - finalString.append ( key ); - finalString.append ( "}" ); - } - i = index + 3 + key.length(); - } - finalString.append (origString.substring(i)); - return finalString.toString(); - } -} \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java b/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java deleted file mode 100644 index 0be2f7261..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java +++ /dev/null @@ -1,310 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * This is an abstract task that should be used by all those tasks that - * require to include or exclude files based on pattern matching. - * - * @author Arnout J. Kuiper ajkuiper@wxs.nl - * @author Stefano Mazzocchi stefano@apache.org - * @author Sam Ruby rubys@us.ibm.com - * @author Jon S. Stevens jon@clearink.com - */ - -public abstract class MatchingTask extends Task { - - protected Vector includeList = new Vector(); - protected Vector excludeList = new Vector(); - protected boolean useDefaultExcludes = true; - - /** - * provide access to properties from within the inner class - */ - protected String getProperty(String name) { - return project.getProperty(name); - } - - /** - * inner class to hold a name on list. "If" and "Unless" attributes - * may be used to invalidate the entry based on the existence of a - * property (typically set thru the use of the Available task). - */ - public class NameEntry { - private boolean valid = true; - private String name; - - public String getName() { return valid ? name : null; } - public void setName(String name) { this.name = name; } - - public void setIf(String name) { - if (getProperty(name) == null) valid = false; - } - - public void setUnless(String name) { - if (getProperty(name) != null) valid = false; - } - } - - /** - * add a name entry on the include list - */ - public NameEntry createInclude() { - return addPatternToList(includeList); - } - - /** - * add a name entry on the exclude list - */ - public NameEntry createExclude() { - return addPatternToList(excludeList); - } - - /** - * Sets the set of include patterns. Patterns may be separated by a comma - * or a space. - * - * @param includes the string containing the include patterns - */ - public void setIncludes(String includes) { - if (includes != null && includes.length() > 0) { - createInclude().setName(includes); - } - } - - /** - * Set this to be the items in the base directory that you want to be - * included. You can also specify "*" for the items (ie: items="*") - * and it will include all the items in the base directory. - * - * @param itemString the string containing the files to include. - */ - public void setItems(String itemString) { - project.log("The items attribute is deprecated. " + - "Please use the includes attribute.", - Project.MSG_WARN); - if (itemString == null || itemString.equals("*") - || itemString.equals(".")) { - createInclude().setName("**"); - } else { - StringTokenizer tok = new StringTokenizer(itemString, ", "); - while (tok.hasMoreTokens()) { - String pattern = tok.nextToken().trim(); - if (pattern.length() > 0) { - createInclude().setName(pattern+"/**"); - } - } - } - } - - /** - * Sets the set of exclude patterns. Patterns may be separated by a comma - * or a space. - * - * @param excludes the string containing the exclude patterns - */ - public void setExcludes(String excludes) { - if (excludes != null && excludes.length() > 0) { - createExclude().setName(excludes); - } - } - - /** - * List of filenames and directory names to not include. They should be - * either , or " " (space) separated. The ignored files will be logged. - * - * @param ignoreString the string containing the files to ignore. - */ - public void setIgnore(String ignoreString) { - project.log("The ignore attribute is deprecated." + - "Please use the excludes attribute.", - Project.MSG_WARN); - if (ignoreString != null && ignoreString.length() > 0) { - Vector tmpExcludes = new Vector(); - StringTokenizer tok = new StringTokenizer(ignoreString, ", ", false); - while (tok.hasMoreTokens()) { - createExclude().setName("**/"+tok.nextToken().trim()+"/**"); - } - } - } - - /** - * Sets whether default exclusions should be used or not. - * - * @param useDefaultExcludes "true"|"on"|"yes" when default exclusions - * should be used, "false"|"off"|"no" when they - * shouldn't be used. - */ - public void setDefaultexcludes(String useDefaultExcludes) { - this.useDefaultExcludes = Project.toBoolean(useDefaultExcludes); - } - - /** - * Convert a vector of NameEntry elements into an array of Strings. - */ - private String[] makeArray(Vector list) { - if (list.size() == 0) return null; - - Vector tmpNames = new Vector(); - for (Enumeration e = list.elements() ; e.hasMoreElements() ;) { - String includes = ((NameEntry)e.nextElement()).getName(); - if (includes == null) continue; - StringTokenizer tok = new StringTokenizer(includes, ", ", false); - while (tok.hasMoreTokens()) { - String pattern = tok.nextToken().trim(); - if (pattern.length() > 0) { - tmpNames.addElement(pattern); - } - } - } - - String result[] = new String[tmpNames.size()]; - for (int i = 0; i < tmpNames.size(); i++) { - result[i] = (String)tmpNames.elementAt(i); - } - - return result; - } - - /** - * Returns the directory scanner needed to access the files to process. - */ - protected DirectoryScanner getDirectoryScanner(File baseDir) { - DirectoryScanner ds = new DirectoryScanner(); - ds.setBasedir(baseDir); - ds.setIncludes(makeArray(includeList)); - ds.setExcludes(makeArray(excludeList)); - if (useDefaultExcludes) ds.addDefaultExcludes(); - ds.scan(); - return ds; - } - - /** - * add a name entry to the given list - */ - private NameEntry addPatternToList(Vector list) { - NameEntry result = new NameEntry(); - list.addElement(result); - return result; - } - - /** - * Reads path matching patterns from a file and adds them to the - * includes or excludes list (as appropriate). - */ - private void readPatterns(File patternfile, Vector patternlist) { - - try { - // Get a FileReader - BufferedReader patternReader = - new BufferedReader(new FileReader(patternfile)); - - // Create one NameEntry in the appropriate pattern list for each - // line in the file. - String line = patternReader.readLine(); - while (line != null) { - if (line.length() > 0) { - addPatternToList(patternlist).setName(line); - } - line = patternReader.readLine(); - } - } catch(IOException ioe) { - project.log("An error occured while reading from pattern file: " - + patternfile, Project.MSG_ERR); - } - } - - /** - * Sets the name of the file containing the includes patterns. - * - * @param includesfile A string containing the filename to fetch - * the include patterns from. - */ - public void setIncludesfile(String includesfile) { - if (includesfile != null && includesfile.length() > 0) { - File incl = project.resolveFile(includesfile); - if (!incl.exists()) { - project.log("Includesfile "+includesfile+" not found.", - Project.MSG_ERR); - } else { - readPatterns(incl, includeList); - } - } - } - - /** - * Sets the name of the file containing the includes patterns. - * - * @param excludesfile A string containing the filename to fetch - * the include patterns from. - */ - public void setExcludesfile(String excludesfile) { - if (excludesfile != null && excludesfile.length() > 0) { - File excl = project.resolveFile(excludesfile); - if (!excl.exists()) { - project.log("Excludesfile "+excludesfile+" not found.", - Project.MSG_ERR); - } else { - readPatterns(excl, excludeList); - } - } - } - -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Mkdir.java b/src/main/org/apache/tools/ant/taskdefs/Mkdir.java deleted file mode 100644 index e133098c1..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Mkdir.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.File; - - -/** - * Creates a given directory. - * - * @author duncan@x180.com - */ - -public class Mkdir extends Task { - - private String dirName; - - public void execute() throws BuildException { - File dir = project.resolveFile(dirName); - if (!dir.exists()) { - boolean result = dir.mkdirs(); - if (result == false) { - String msg = "Directory " + dirName + " creation was not " + - "succesful for an unknown reason"; - throw new BuildException(msg); - } - project.log("Created dir: " + dir.getAbsolutePath()); - } - } - - public void setDir(String dirName) { - this.dirName = dirName; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Patch.java b/src/main/org/apache/tools/ant/taskdefs/Patch.java deleted file mode 100644 index 3b1eab045..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Patch.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 2000 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.File; - -/** - * Task as a layer on top of patch. Patch applies a diff file to an original. - * - * @author Stefan Bodewig stefan.bodewig@megabit.net - */ -public class Patch extends Exec { - - private File originalFile; - private File patchFile; - private boolean backup = false; - private boolean ignoreWhitespace = false; - private int strip = -1; - private boolean quiet = false; - private boolean reverse = false; - - /** - * The file to patch. - */ - public void setOriginalfile(String file) { - originalFile = project.resolveFile(file); - } - - /** - * The file containing the diff output. - */ - public void setPatchfile(String file) { - patchFile = project.resolveFile(file); - } - - /** - * Shall patch write backups. - */ - public void setBackups(String backups) { - backup = Project.toBoolean(backups); - } - - /** - * Ignore whitespace differences. - */ - public void setIgnorewhitespace(String ignore) { - ignoreWhitespace = Project.toBoolean(ignore); - } - - /** - * Strip the smallest prefix containing num leading slashes - * from filenames. - * - *

patch's -p option. - */ - public void setStrip(String num) { - strip = Integer.parseInt(num); - } - - /** - * Work silently unless an error occurs. - */ - public void setQuiet(String q) { - quiet = Project.toBoolean(q); - } - - /** - * Assume patch was created with old and new files swapped. - */ - public void setReverse(String r) { - reverse = Project.toBoolean(r); - } - - public void execute() throws BuildException { - if (patchFile == null) { - throw new BuildException("patchfile argument is required"); - } - - StringBuffer command = new StringBuffer("patch -i "+patchFile+" "); - - if (backup) { - command.append("-b "); - } - - if (ignoreWhitespace) { - command.append("-l "); - } - - if (strip >= 0) { - command.append("-p"+strip+" "); - } - - if (quiet) { - command.append("-s "); - } - - if (reverse) { - command.append("-R "); - } - - if (originalFile != null) { - command.append(originalFile); - } - - run(command.toString()); - } - -}// Patch diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java deleted file mode 100644 index 6bcfe03ed..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Property.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Will set a Project property. Used to be a hack in ProjectHelper - * Will not override values set by the command line or parent projects. - * - * @author costin@dnt.ro - * @author Sam Ruby - */ -public class Property extends Task { - - String name; - String value; - String file; - String resource; - - boolean userProperty=false; // set read-only properties - - public void setName(String name) { - this.name = name; - } - - public String getName() { - return name; - } - - public void setValue(String value) { - this.value = value; - } - - public String getValue() { - return value; - } - - public void setFile(String file) { - this.file = file; - } - - public void setResource(String resource) { - this.resource = resource; - } - - public void init() throws BuildException { - try { - if ((name != null) && (value != null)) { - if( userProperty ) - if (project.getUserProperty(name) == null) { - project.setUserProperty(name, value); - } else { - project.log("Override ignored for " + name, - project.MSG_VERBOSE); - } - else - if (project.getProperty(name) == null) { - project.setProperty(name, value); - } else { - project.log("Override ignored for " + name, - project.MSG_VERBOSE); - } - } - - if (file != null) loadFile(file); - - if (resource != null) loadResource(resource); - - } catch (Exception e) { - throw new BuildException(e); - } - } - - private void loadFile (String name) { - Properties props = new Properties(); - project.log("Loading " + name, project.MSG_VERBOSE); - try { - if (new File(name).exists()) { - props.load(new FileInputStream(name)); - addProperties(props); - } - } catch(Exception ex) { - ex.printStackTrace(); - } - } - - private void loadResource( String name ) { - Properties props = new Properties(); - project.log("Resource Loading " + name, project.MSG_VERBOSE); - try { - InputStream is = this.getClass().getResourceAsStream(name); - if (is != null) { - props.load(is); - addProperties(props); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - private void addProperties(Properties props) { - Enumeration e = props.keys(); - while (e.hasMoreElements()) { - String name = (String) e.nextElement(); - String value = (String) props.getProperty(name); - String v = ProjectHelper.replaceProperties(value, project.getProperties()); - if( userProperty ) - if (project.getUserProperty(name) == null) { - project.setUserProperty(name, v); - } else { - project.log("Override ignored for " + name, - project.MSG_VERBOSE); - } - else - if (project.getProperty(name) == null) { - project.setProperty(name, v); - } else { - project.log("Override ignored for " + name, - project.MSG_VERBOSE); - } - } - } - - public void setUserProperty( boolean userP ) { - userProperty=userP; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Rename.java b/src/main/org/apache/tools/ant/taskdefs/Rename.java deleted file mode 100644 index 22ac4d5e9..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Rename.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.BuildException; -import org.apache.tools.ant.Task; - -import java.io.File; - -/** - * Renames a file. - * - * @author haas@softwired.ch - */ -public class Rename extends Task { - - private File src; - private File dest; - private boolean replace = true; - - - /** - * Sets the file to be renamed. - * @param src the file to rename - */ - public void setSrc(String src) { - this.src = project.resolveFile(src); - } - - /** - * Sets the new name of the file. - * @param dest the new name of the file. - */ - public void setDest(String dest) { - this.dest = project.resolveFile(dest); - } - - /** - * Sets wheter an existing file should be replaced. - * @param replace on, if an existing file should be replaced. - */ - public void setReplace(String replace) { - this.replace = project.toBoolean(replace); - } - - - /** - * Renames the file src to dest - * @exception org.apache.tools.ant.BuildException The exception is - * thrown, if the rename operation fails. - */ - public void execute() throws BuildException { - if (replace && dest.exists()) { - if (!dest.delete()) { - throw new BuildException("Unable to remove existing file " + - dest); - } - } - if (!src.renameTo(dest)) { - throw new BuildException("Unable to rename " + src + " to " + - dest); - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java deleted file mode 100644 index ae9a1fc8c..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Replace.java +++ /dev/null @@ -1,190 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 indicated files. - * - * @author Stefano Mazzocchi stefano@apache.org - */ -public class Replace extends MatchingTask { - - private File src = null; - private String token = null; - private String value = ""; - - private File dir = null; - - /** - * Do the execution. - */ - public void execute() throws BuildException { - - if (token == null) { - throw new BuildException("replace token must not be null"); - } - - if (src == null && dir == null) { - throw new BuildException("Either the file or the dir attribute must be specified"); - } - - project.log("Replacing " + token + " --> " + value); - - if (src != null) { - processFile(src); - } - - if (dir != null) { - DirectoryScanner ds = super.getDirectoryScanner(dir); - String[] srcs = ds.getIncludedFiles(); - - for(int i=0; i -1) { - buffer.append(orig.substring(start, end)); - buffer.append(value); - start = end + token.length(); - } - - buffer.append(orig.substring(start)); - - return buffer.toString(); - } -} \ No newline at end of file diff --git a/src/main/org/apache/tools/ant/taskdefs/Rmic.java b/src/main/org/apache/tools/ant/taskdefs/Rmic.java deleted file mode 100644 index f4f41c523..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Rmic.java +++ /dev/null @@ -1,244 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.StringTokenizer; - -/** - * Task to compile RMI stubs and skeletons. This task can take the following - * arguments: - *

    - *
  • base: The base directory for the compiled stubs and skeletons - *
  • class: The name of the class to generate the stubs from - *
  • stubVersion: The version of the stub prototol to use (1.1, 1.2, compat) - *
  • sourceBase: The base directory for the generated stubs and skeletons - *
  • classpath: Additional classpath, appended before the system classpath - *
- * Of these arguments, the base and class are required. - *

- * - * @author duncan@x180.com - * @author ludovic.claude@websitewatchers.co.uk - */ - -public class Rmic extends Task { - - private String base; - private String classname; - private String sourceBase; - private String stubVersion; - private String compileClasspath; - private boolean filtering = false; - - public void setBase(String base) { - this.base = base; - } - - public void setClass(String classname) { - project.log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); - this.classname = classname; - } - - public void setClassname(String classname) { - this.classname = classname; - } - - public void setSourceBase(String sourceBase) { - this.sourceBase = sourceBase; - } - - public void setStubVersion(String stubVersion) { - this.stubVersion = stubVersion; - } - - public void setFiltering(String filter) { - filtering = Project.toBoolean(filter); - } - - /** - * Set the classpath to be used for this compilation. - */ - public void setClasspath(String classpath) { - compileClasspath = project.translatePath(classpath); - } - - public void execute() throws BuildException { - File baseFile = project.resolveFile(base); - File sourceBaseFile = null; - if (null != sourceBase) - sourceBaseFile = project.resolveFile(sourceBase); - String classpath = getCompileClasspath(baseFile); - // XXX - // need to provide an input stream that we read in from! - - sun.rmi.rmic.Main compiler = new sun.rmi.rmic.Main(System.out, "rmic"); - int argCount = 5; - int i = 0; - if (null != stubVersion) argCount++; - if (null != sourceBase) argCount++; - String[] args = new String[argCount]; - args[i++] = "-d"; - args[i++] = baseFile.getAbsolutePath(); - args[i++] = "-classpath"; - args[i++] = classpath; - args[i++] = classname; - if (null != stubVersion) { - if ("1.1".equals(stubVersion)) - args[i++] = "-v1.1"; - else if ("1.2".equals(stubVersion)) - args[i++] = "-v1.2"; - else - args[i++] = "-vcompat"; - } - if (null != sourceBase) args[i++] = "-keepgenerated"; - - compiler.compile(args); - - // Move the generated source file to the base directory - if (null != sourceBase) { - String stubFileName = classname.replace('.', '/') + "_Stub.java"; - File oldStubFile = new File(baseFile, stubFileName); - File newStubFile = new File(sourceBaseFile, stubFileName); - try { - project.copyFile(oldStubFile, newStubFile, filtering); - oldStubFile.delete(); - } catch (IOException ioe) { - String msg = "Failed to copy " + oldStubFile + " to " + - newStubFile + " due to " + ioe.getMessage(); - throw new BuildException(msg); - } - if (!"1.2".equals(stubVersion)) { - String skelFileName = classname.replace('.', '/') + "_Skel.java"; - File oldSkelFile = new File(baseFile, skelFileName); - File newSkelFile = new File(sourceBaseFile, skelFileName); - try { - project.copyFile(oldSkelFile, newSkelFile, filtering); - oldSkelFile.delete(); - } catch (IOException ioe) { - String msg = "Failed to copy " + oldSkelFile + " to " + - newSkelFile + " due to " + ioe.getMessage(); - throw new BuildException(msg); - } - } - } - } - - /** - * Builds the compilation classpath. - */ - - // XXX - // we need a way to not use the current classpath. - - private String getCompileClasspath(File baseFile) { - StringBuffer classpath = new StringBuffer(); - - // add dest dir to classpath so that previously compiled and - // untouched classes are on classpath - classpath.append(baseFile.getAbsolutePath()); - - // add our classpath to the mix - - if (compileClasspath != null) { - addExistingToClasspath(classpath,compileClasspath); - } - - // add the system classpath - - addExistingToClasspath(classpath,System.getProperty("java.class.path")); - // in jdk 1.2, the system classes are not on the visible classpath. - - if (Project.getJavaVersion().startsWith("1.2")) { - String bootcp = System.getProperty("sun.boot.class.path"); - if (bootcp != null) { - addExistingToClasspath(classpath, bootcp); - } - } - return classpath.toString(); - } - - /** - * Takes a classpath-like string, and adds each element of - * this string to a new classpath, if the components exist. - * Components that don't exist, aren't added. - * We do this, because jikes issues warnings for non-existant - * files/dirs in his classpath, and these warnings are pretty - * annoying. - * @param target - target classpath - * @param source - source classpath - * to get file objects. - */ - private void addExistingToClasspath(StringBuffer target,String source) { - StringTokenizer tok = new StringTokenizer(source, - System.getProperty("path.separator"), false); - while (tok.hasMoreTokens()) { - File f = project.resolveFile(tok.nextToken()); - - if (f.exists()) { - target.append(File.pathSeparator); - target.append(f.getAbsolutePath()); - } else { - project.log("Dropping from classpath: "+ - f.getAbsolutePath(),project.MSG_VERBOSE); - } - } - - } -} - diff --git a/src/main/org/apache/tools/ant/taskdefs/Tar.java b/src/main/org/apache/tools/ant/taskdefs/Tar.java deleted file mode 100644 index df9243f9b..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Tar.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 java.io.*; -import org.apache.tools.ant.*; -import org.apache.tools.tar.*; - -/** - * Creates a TAR archive. - * - * @author Stefano Mazzocchi stefano@apache.org - */ - -public class Tar extends MatchingTask { - - File tarFile; - File baseDir; - - /** - * This is the name/location of where to create the tar file. - */ - public void setTarfile(String tarFilename) { - tarFile = project.resolveFile(tarFilename); - } - - /** - * This is the base directory to look in for things to tar. - */ - public void setBasedir(String baseDirname) { - baseDir = project.resolveFile(baseDirname); - } - - public void execute() throws BuildException { - project.log("Building tar: "+ tarFile.getAbsolutePath()); - - if (baseDir == null) { - throw new BuildException("basedir attribute must be set!"); - } - if (!baseDir.exists()) { - throw new BuildException("basedir does not exist!"); - } - - DirectoryScanner ds = super.getDirectoryScanner(baseDir); - - String[] files = ds.getIncludedFiles(); - - try { - TarOutputStream tOut = new TarOutputStream(new FileOutputStream(tarFile)); - tOut.setDebug(true); - - for (int i = 0; i < files.length; i++) { - File f = new File(baseDir,files[i]); - String name = files[i].replace(File.separatorChar,'/'); - tarFile(f, tOut, name); - } - - // close up - tOut.close(); - } catch (IOException ioe) { - String msg = "Problem creating TAR: " + ioe.getMessage(); - throw new BuildException(msg); - } - } - - protected void tarFile(File file, TarOutputStream tOut, String vPath) - throws IOException - { - FileInputStream fIn = new FileInputStream(file); - - TarEntry te = new TarEntry(vPath); - te.setSize(file.length()); - te.setModTime(file.lastModified()); - tOut.putNextEntry(te); - - byte[] buffer = new byte[8 * 1024]; - int count = 0; - do { - tOut.write(buffer, 0, count); - count = fIn.read(buffer, 0, buffer.length); - } while (count != -1); - - tOut.closeEntry(); - - fIn.close(); - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Taskdef.java b/src/main/org/apache/tools/ant/taskdefs/Taskdef.java deleted file mode 100644 index c33200603..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Taskdef.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * Define a new task - name and class - * - * @author costin@dnt.ro - */ -public class Taskdef extends Task { - private String name; - private String value; - - // - // REVISIT: Is this the right thing to do? - // I moved the body of execute() into init(). - // - akv - // - public void init() throws BuildException { - try { - if (name==null || value==null ) { - String msg = "name or class attributes of taskdef element " - + "are undefined"; - throw new BuildException(msg); - } - try { - Class taskClass = Class.forName(value); - project.addTaskDefinition(name, taskClass); - } catch (ClassNotFoundException cnfe) { - String msg = "taskdef class " + value + - " cannot be found"; - throw new BuildException(msg); - } - } catch (Exception ex) { - ex.printStackTrace(); - } - } - - public void setName( String name) { - this.name = name; - } - - public void setClass(String v) { - project.log("The class attribute is deprecated. " + - "Please use the classname attribute.", - Project.MSG_WARN); - value = v; - } - - public String getClassname() { - return value; - } - - public void setClassname(String v) { - value = v; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Touch.java b/src/main/org/apache/tools/ant/taskdefs/Touch.java deleted file mode 100644 index b5f930f69..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Touch.java +++ /dev/null @@ -1,198 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.text.DateFormat; -import java.text.ParseException; -import java.util.Date; -import java.util.Locale; - -/** - * Touch a file - corresponds to the Unix touch command. - * - *

If the file to touch doesn't exist, an empty one is - * created. Setting the modification time of files is not supported in - * JDK 1.1. - * - * @author Stefan Bodewig stefan.bodewig@megabit.net - */ -public class Touch extends Task { - - private File file; // required - private long millis = -1; - private String dateTime; - - private static Method setLastModified = null; - private static Object lockReflection = new Object(); - - /** - * The name of the file to touch. - */ - public void setFile(String name) { - file = project.resolveFile(name); - } - - /** - * Milliseconds since 01/01/1970 00:00 am. - */ - public void setMillis(long millis) { - this.millis = millis; - } - - /** - * Date in the format MM/DD/YYYY HH:MM AM_PM. - */ - public void setDatetime(String dateTime) { - this.dateTime = dateTime; - } - - /** - * Do the work. - * - * @exception BuildException Thrown in unrecoverable error. - */ - public void execute() throws BuildException { - if (file.exists() && project.getJavaVersion() == Project.JAVA_1_1) { - project.log("Cannot change the modification time of " - + file + " in JDK 1.1", - Project.MSG_WARN); - return; - } - - if (dateTime != null) { - DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT, - DateFormat.SHORT, - Locale.US); - try { - setMillis(df.parse(dateTime).getTime()); - } catch (ParseException pe) { - throw new BuildException(pe.getMessage(), pe, location); - } - } - - if (millis >= 0 && project.getJavaVersion() == Project.JAVA_1_1) { - project.log(file + - " will be created but its modification time cannot be set in JDK 1.1", - Project.MSG_WARN); - } - - touch(); - } - - /** - * Does the actual work. Entry point for Untar and Expand as well. - */ - void touch() throws BuildException { - if (!file.exists()) { - project.log("Creating "+file, Project.MSG_INFO); - try { - FileOutputStream fos = new FileOutputStream(file); - fos.write(new byte[0]); - fos.close(); - } catch (IOException ioe) { - throw new BuildException("Could not create "+file, ioe, - location); - } - } - - if (project.getJavaVersion() == Project.JAVA_1_1) { - return; - } - - if (setLastModified == null) { - synchronized (lockReflection) { - if (setLastModified == null) { - try { - setLastModified = - java.io.File.class.getMethod("setLastModified", - new Class[] {Long.TYPE}); - } catch (NoSuchMethodException nse) { - throw new BuildException("File.setlastModified not in JDK > 1.1?", - nse, location); - } - } - } - } - - Long[] times = new Long[1]; - if (millis < 0) { - times[0] = new Long(System.currentTimeMillis()); - } else { - times[0] = new Long(millis); - } - - try { - project.log("Setting modification time for "+file, - Project.MSG_VERBOSE); - - setLastModified.invoke(file, times); - } catch (InvocationTargetException ite) { - Throwable nested = ite.getTargetException(); - throw new BuildException("Exception setting the modification time of " - + file, nested, location); - } catch (Throwable other) { - throw new BuildException("Exception setting the modification time of " - + file, other, location); - } - } - -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java deleted file mode 100644 index c77028b1f..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; -import java.text.*; - -/** - * Sets TSTAMP, DSTAMP and TODAY - * - * @author costin@dnt.ro - * @author stefano@apache.org - */ -public class Tstamp extends Task { - - public void init() throws BuildException { - try { - Date d = new Date(); - - SimpleDateFormat dstamp = new SimpleDateFormat ("yyyyMMdd"); - project.setProperty("DSTAMP", dstamp.format(d)); - - SimpleDateFormat tstamp = new SimpleDateFormat ("HHmm"); - project.setProperty("TSTAMP", tstamp.format(d)); - - SimpleDateFormat today = new SimpleDateFormat ("MMMM d yyyy", Locale.US); - project.setProperty("TODAY", today.format(d)); - } catch (Exception e) { - throw new BuildException(e); - } - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/Untar.java b/src/main/org/apache/tools/ant/taskdefs/Untar.java deleted file mode 100644 index 6bad0cdfb..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Untar.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 org.apache.tools.tar.*; -import java.io.*; - -/** - * Untar a file. - * - * Heavily based on the Expand task. - * - * @author Stefan Bodewig stefan.bodewig@megabit.net - */ -public class Untar extends Task { - private String dest; // req - private String source; // req - - /** - * Do the work. - * - * @exception BuildException Thrown in unrecoverable error. - */ - public void execute() throws BuildException { - - Touch touch = (Touch) project.createTask("touch"); - touch.setTarget(target); - - try { - if (source == null) { - throw new BuildException("No source specified", location); - } - File srcF=project.resolveFile(source); - if (!srcF.exists()) { - throw new BuildException("source "+srcF+" doesn't exist", - location); - } - - if (dest == null) { - throw new BuildException("No destination specified", location); - } - File dir=project.resolveFile(dest); - - project.log("Expanding: " + srcF + " into " + dir, Project.MSG_INFO); - // code from WarExpand - TarInputStream tis = new TarInputStream(new FileInputStream(srcF)); - TarEntry te = null; - - while ((te = tis.getNextEntry()) != null) { - try { - File f = new File(dir, project.translatePath(te.getName())); - project.log("expand-file " + te.getName() , "untar", - Project.MSG_VERBOSE ); - // create intermediary directories - sometimes tar don't add them - File dirF=new File(f.getParent()); - dirF.mkdirs(); - - if (te.isDirectory()) { - f.mkdirs(); - } else { - byte[] buffer = new byte[1024]; - int length = 0; - FileOutputStream fos = new FileOutputStream(f); - - while ((length = tis.read(buffer)) >= 0) { - fos.write(buffer, 0, length); - } - - fos.close(); - } - - if (project.getJavaVersion() != Project.JAVA_1_1) { - touch.setFile(f.getAbsolutePath()); - touch.setMillis(te.getModTime().getTime()); - touch.touch(); - } - - } catch(FileNotFoundException ex) { - project.log("FileNotFoundException: " + te.getName(), - Project.MSG_WARN); - } - } - } catch (IOException ioe) { - throw new BuildException(ioe); - } - } - - /** - * Set the destination directory. File will be untared into the - * destination directory. - * - * @param d Path to the directory. - */ - public void setDest(String d) { - this.dest=d; - } - - /** - * Set the path to tar-file. - * - * @param s Path to tar-file. - */ - public void setSrc(String s) { - this.source = s; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java b/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java deleted file mode 100644 index b155fbaf3..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.*; - -/** - * - * @author Sam Ruby - * @version $Revision$ $Date$ - */ -public interface XSLTLiaison { - - public void setStylesheet(String fileName) throws Exception; - - public void transform(String infile, String outfile) throws Exception; - -} //-- XSLTLiaison diff --git a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java b/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java deleted file mode 100644 index b41e8d838..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.Enumeration; -import java.util.Hashtable; -import java.util.StringTokenizer; -import java.util.Vector; - - -/** - * A Task to process via XSLT a set of XML documents. This is - * useful for building views of XML based documentation. - * arguments: - *

    - *
  • basedir - *
  • destdir - *
  • style - *
  • includes - *
  • excludes - *
- * Of these arguments, the sourcedir and destdir are required. - *

- * This task will recursively scan the sourcedir and destdir - * looking for XML documents to process via XSLT. Any other files, - * such as images, or html files in the source directory will be - * copied into the destination directory. - * - * @author Keith Visco - * @author Sam Ruby - * @version $Revision$ $Date$ - */ -public class XSLTProcess extends MatchingTask { - - private File destDir = null; - - private File baseDir = null; - - private File xslFile = null; - - private String targetExtension = "html"; - - private XSLTLiaison liaison; - - /** - * Creates a new XSLTProcess Task. - **/ - public XSLTProcess() { - } //-- XSLTProcess - - /** - * Executes the task. - */ - - public void execute() throws BuildException { - DirectoryScanner scanner; - String[] list; - String[] dirs; - - if (baseDir == null) - baseDir = project.resolveFile("."); - //-- make sure Source directory exists... - if (destDir == null ) { - String msg = "destdir attributes must be set!"; - throw new BuildException(msg); - } - scanner = getDirectoryScanner(baseDir); - project.log("Transforming into "+destDir,project.MSG_INFO); - - // if processor wasn't specified, default it to xslp or xalan, - // depending on which is in the classpath - if (liaison == null) { - try { - setProcessor("xslp"); - } catch (Throwable e1) { - try { - setProcessor("xalan"); - } catch (Throwable e2) { - throw new BuildException(e2); - } - } - } - - project.log("Using "+liaison.getClass().toString(),project.MSG_VERBOSE); - - try { - // Create a new XSL processor with the specified stylesheet - if (xslFile != null) { - String file = new File(baseDir,xslFile.toString()).toString(); - project.log("Loading stylesheet " + file, project.MSG_INFO); - liaison.setStylesheet( file ); - } - } catch (Exception ex) { - project.log("Failed to read stylesheet " + xslFile,project.MSG_INFO); - throw new BuildException(ex); - } - - // Process all the files marked for styling - list = scanner.getIncludedFiles(); - for (int i = 0;i < list.length; ++i) { - process(baseDir,list[i],destDir); - } - - // Process all the directoried marked for styling - dirs = scanner.getIncludedDirectories(); - for (int j = 0;j < dirs.length;++j){ - list=new File(baseDir,dirs[j]).list(); - for (int i = 0;i < list.length;++i) - process(baseDir,list[i],destDir); - } - } //-- execute - - /** - * Set the base directory. - **/ - public void setBasedir(String dirName) { - baseDir = project.resolveFile(dirName); - } //-- setSourceDir - - /** - * Set the destination directory into which the XSL result - * files should be copied to - * @param dirName the name of the destination directory - **/ - public void setDestdir(String dirName) { - destDir = project.resolveFile(dirName); - } //-- setDestDir - - /** - * Set the desired file extension to be used for the target - * @param name the extension to use - **/ - public void setExtension(String name) { - targetExtension = name; - } //-- setDestDir - - /** - * Sets the file to use for styling relative to the base directory. - */ - public void setStyle(String xslFile) { - this.xslFile = new File(xslFile); - } - - /** - * Sets the file to use for styling relative to the base directory. - */ - public void setProcessor(String processor) throws Exception { - - if (processor.equals("xslp")) { - liaison = (XSLTLiaison) Class.forName("org.apache.tools.ant.taskdefs.optional.XslpLiaison").newInstance(); - } else if (processor.equals("xalan")) { - liaison = (XSLTLiaison) Class.forName("org.apache.tools.ant.taskdefs.optional.XalanLiaison").newInstance(); - } else { - liaison = (XSLTLiaison) Class.forName(processor).newInstance(); - } - - } - - /* - private void process(File sourceDir, File destDir) - throws BuildException - { - - - if (!sourceDir.isDirectory()) { - throw new BuildException(sourceDir.getName() + - " is not a directory!"); - } - else if (!destDir.isDirectory()) { - throw new BuildException(destDir.getName() + - " is not a directory!"); - } - - String[] list = sourceDir.list(new DesirableFilter()); - - if (list == null) { - return; //-- nothing to do - } - - for (int i = 0; i < list.length; i++) { - - String filename = list[i]; - - File inFile = new File(sourceDir, filename); - - //-- if inFile is a directory, recursively process it - if (inFile.isDirectory()) { - if (!excluded(filename)) { - new File(destDir, filename).mkdir(); - process(inFile, new File(destDir, filename)); - } - } - //-- process XML files - else if (hasXMLFileExtension(filename) && ! excluded(filename)) { - - //-- replace extension with the target extension - int idx = filename.lastIndexOf('.'); - - File outFile = new File(destDir, - filename.substring(0,idx) + targetExt); - - if ((inFile.lastModified() > outFile.lastModified()) || - (xslFile != null && xslFile.lastModified() > outFile.lastModified())) - { - processXML(inFile, outFile); - } - } - else { - File outFile = new File(destDir, filename); - if (inFile.lastModified() > outFile.lastModified()) { - try { - copyFile(inFile, outFile); - } - catch(java.io.IOException ex) { - String err = "error copying file: "; - err += inFile.getAbsolutePath(); - err += "; " + ex.getMessage(); - throw new BuildException(err, ex); - } - //filecopyList.put(srcFile.getAbsolutePath(), - //destFile.getAbsolutePath()); - } - } - } //-- - } //-- process(File, File) - */ - - /** - * Processes the given input XML file and stores the result - * in the given resultFile. - **/ - private void process(File baseDir,String xmlFile,File destDir) - throws BuildException - { - String fileExt=targetExtension; - File outFile=null; - File inFile=null; - - try { - inFile = new File(baseDir,xmlFile); - outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt); - if (inFile.lastModified() > outFile.lastModified()) { - //-- command line status - project.log("Processing " + xmlFile + " to " + outFile,project.MSG_VERBOSE); - - liaison.transform(inFile.toString(), outFile.toString()); - } - } - catch (Exception ex) { - // If failed to process document, must delete target document, - // or it will not attempt to process it the second time - project.log("Failed to process " + inFile,project.MSG_INFO); - outFile.delete(); - throw new BuildException(ex); - } - - } //-- processXML - -} //-- XSLTProcess diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java deleted file mode 100644 index 1af5fc920..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/Zip.java +++ /dev/null @@ -1,230 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.Enumeration; -import java.util.StringTokenizer; -import java.util.Vector; -import java.util.zip.*; - -/** - * Create a ZIP archive. - * - * @author James Davidson duncan@x180.com - * @author Jon S. Stevens jon@clearink.com - */ - -public class Zip extends MatchingTask { - - private File zipFile; - private File baseDir; - private boolean doCompress = true; - protected String archiveType = "zip"; - - /** - * This is the name/location of where to - * create the .zip file. - */ - public void setZipfile(String zipFilename) { - zipFile = project.resolveFile(zipFilename); - } - - /** - * This is the base directory to look in for - * things to zip. - */ - public void setBasedir(String baseDirname) { - baseDir = project.resolveFile(baseDirname); - } - - /** - * Sets whether we want to compress the files or only store them. - */ - public void setCompress(String compress) { - doCompress = Project.toBoolean(compress); - } - - public void execute() throws BuildException { - if (baseDir == null) { - throw new BuildException("basedir attribute must be set!"); - } - if (!baseDir.exists()) { - throw new BuildException("basedir does not exist!"); - } - - DirectoryScanner ds = super.getDirectoryScanner(baseDir); - - String[] files = ds.getIncludedFiles(); - String[] dirs = ds.getIncludedDirectories(); - - // quick exit if the target is up to date - boolean upToDate = true; - for (int i=0; i - zipFile.lastModified()) - upToDate = false; - if (upToDate) return; - - project.log("Building "+ archiveType +": "+ zipFile.getAbsolutePath()); - - try { - ZipOutputStream zOut = new ZipOutputStream(new FileOutputStream(zipFile)); - if (doCompress) { - zOut.setMethod(ZipOutputStream.DEFLATED); - } else { - zOut.setMethod(ZipOutputStream.STORED); - } - initZipOutputStream(zOut); - - for (int i = 0; i < dirs.length; i++) { - File f = new File(baseDir,dirs[i]); - String name = dirs[i].replace(File.separatorChar,'/')+"/"; - zipDir(f, zOut, name); - } - - for (int i = 0; i < files.length; i++) { - File f = new File(baseDir,files[i]); - String name = files[i].replace(File.separatorChar,'/'); - zipFile(f, zOut, name); - } - - // close up - zOut.close(); - } catch (IOException ioe) { - String msg = "Problem creating " + archiveType + " " + ioe.getMessage(); - throw new BuildException(msg); - } - } - - protected void initZipOutputStream(ZipOutputStream zOut) - throws IOException, BuildException - { - } - - protected void zipDir(File dir, ZipOutputStream zOut, String vPath) - throws IOException - { - } - - protected void zipFile(InputStream in, ZipOutputStream zOut, String vPath, - long lastModified) - throws IOException - { - ZipEntry ze = new ZipEntry(vPath); - ze.setTime(lastModified); - - /* - * XXX ZipOutputStream.putEntry expects the ZipEntry to know its - * size and the CRC sum before you start writing the data when using - * STORED mode. - * - * This forces us to process the data twice. - * - * I couldn't find any documentation on this, just found out by try - * and error. - */ - if (!doCompress) { - long size = 0; - CRC32 cal = new CRC32(); - if (!in.markSupported()) { - // Store data into a byte[] - ByteArrayOutputStream bos = new ByteArrayOutputStream(); - - byte[] buffer = new byte[8 * 1024]; - int count = 0; - do { - size += count; - cal.update(buffer, 0, count); - bos.write(buffer, 0, count); - count = in.read(buffer, 0, buffer.length); - } while (count != -1); - in = new ByteArrayInputStream(bos.toByteArray()); - - } else { - in.mark(Integer.MAX_VALUE); - byte[] buffer = new byte[8 * 1024]; - int count = 0; - do { - size += count; - cal.update(buffer, 0, count); - count = in.read(buffer, 0, buffer.length); - } while (count != -1); - in.reset(); - } - ze.setSize(size); - ze.setCrc(cal.getValue()); - } - - zOut.putNextEntry(ze); - - byte[] buffer = new byte[8 * 1024]; - int count = 0; - do { - zOut.write(buffer, 0, count); - count = in.read(buffer, 0, buffer.length); - } while (count != -1); - } - - protected void zipFile(File file, ZipOutputStream zOut, String vPath) - throws IOException - { - FileInputStream fIn = new FileInputStream(file); - zipFile(fIn, zOut, vPath, file.lastModified()); - fIn.close(); - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties deleted file mode 100644 index 6fb1354f5..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ /dev/null @@ -1,44 +0,0 @@ -# standard ant tasks -mkdir=org.apache.tools.ant.taskdefs.Mkdir -javac=org.apache.tools.ant.taskdefs.Javac -chmod=org.apache.tools.ant.taskdefs.Chmod -deltree=org.apache.tools.ant.taskdefs.Deltree -delete=org.apache.tools.ant.taskdefs.Delete -jar=org.apache.tools.ant.taskdefs.Jar -copydir=org.apache.tools.ant.taskdefs.Copydir -copyfile=org.apache.tools.ant.taskdefs.Copyfile -rmic=org.apache.tools.ant.taskdefs.Rmic -cvs=org.apache.tools.ant.taskdefs.Cvs -get=org.apache.tools.ant.taskdefs.Get -expand=org.apache.tools.ant.taskdefs.Expand -echo=org.apache.tools.ant.taskdefs.Echo -javadoc=org.apache.tools.ant.taskdefs.Javadoc -zip=org.apache.tools.ant.taskdefs.Zip -gzip=org.apache.tools.ant.taskdefs.GZip -gunzip=org.apache.tools.ant.taskdefs.GUnzip -replace=org.apache.tools.ant.taskdefs.Replace -java=org.apache.tools.ant.taskdefs.Java -tstamp=org.apache.tools.ant.taskdefs.Tstamp -property=org.apache.tools.ant.taskdefs.Property -taskdef=org.apache.tools.ant.taskdefs.Taskdef -ant=org.apache.tools.ant.taskdefs.Ant -exec=org.apache.tools.ant.taskdefs.Exec -tar=org.apache.tools.ant.taskdefs.Tar -untar=org.apache.tools.ant.taskdefs.Untar -available=org.apache.tools.ant.taskdefs.Available -filter=org.apache.tools.ant.taskdefs.Filter -fixcrlf=org.apache.tools.ant.taskdefs.FixCRLF -rename=org.apache.tools.ant.taskdefs.Rename -patch=org.apache.tools.ant.taskdefs.Patch -compileTask=org.apache.tools.ant.taskdefs.CompileTask -style=org.apache.tools.ant.taskdefs.XSLTProcess -touch=org.apache.tools.ant.taskdefs.Touch - -# optional tasks -script=org.apache.tools.ant.taskdefs.optional.Script -netrexxc=org.apache.tools.ant.taskdefs.optional.NetRexxC -renameext=org.apache.tools.ant.taskdefs.optional.RenameExtensions - -# deprecated ant tasks (kept for back compatibility) -javadoc2=org.apache.tools.ant.taskdefs.Javadoc -keysubst=org.apache.tools.ant.taskdefs.KeySubst diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java deleted file mode 100644 index f230646b0..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java +++ /dev/null @@ -1,657 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.optional; - -import org.apache.tools.ant.*; -import org.apache.tools.ant.taskdefs.*; - -import netrexx.lang.Rexx; - -import java.io.*; -import java.lang.reflect.*; -import java.util.*; - -/** - * Task to compile NetRexx source files. This task can take the following - * arguments: - *

    - *
  • binary
  • - *
  • classpath
  • - *
  • comments
  • - *
  • compile
  • - *
  • console
  • - *
  • crossref
  • - *
  • decimal
  • - *
  • destdir
  • - *
  • diag
  • - *
  • explicit
  • - *
  • format
  • - *
  • keep
  • - *
  • logo
  • - *
  • replace
  • - *
  • savelog
  • - *
  • srcdir
  • - *
  • sourcedir
  • - *
  • strictargs
  • - *
  • strictassign
  • - *
  • strictcase
  • - *
  • strictimport
  • - *
  • symbols
  • - *
  • time
  • - *
  • trace
  • - *
  • utf8
  • - *
  • verbose
  • - *
- * Of these arguments, the srcdir argument is required. - * - *

When this task executes, it will recursively scan the srcdir - * looking for NetRexx source files to compile. This task makes its - * compile decision based on timestamp. - *

Before files are compiled they and any other file in the - * srcdir will be copied to the destdir allowing support files to be - * located properly in the classpath. The reason for copying the source files - * before the compile is that NetRexxC has only two destinations for classfiles: - *

    - *
  1. The current directory, and,
  2. - *
  3. The directory the source is in (see sourcedir option) - *
- * - * @author dIon Gillard dion@multitask.com.au - */ - -public class NetRexxC extends MatchingTask { - - // variables to hold arguments - private boolean binary; - private String classpath; - private boolean comments; - private boolean compact; - private boolean compile = true; - private boolean console; - private boolean crossref; - private boolean decimal = true; - private File destDir; - private boolean diag; - private boolean explicit; - private boolean format; - private boolean java; - private boolean keep; - private boolean logo = true; - private boolean replace; - private boolean savelog; - private File srcDir; - private boolean sourcedir = true; // ?? Should this be the default for ant? - private boolean strictargs; - private boolean strictassign; - private boolean strictcase; - private boolean strictimport; - private boolean strictprops; - private boolean strictsignal; - private boolean symbols; - private boolean time; - private String trace = "trace2"; - private boolean utf8; - private String verbose = "verbose3"; - - // other implementation variables - private Vector compileList = new Vector(); - private Hashtable filecopyList = new Hashtable(); - private String oldClasspath = System.getProperty("java.class.path"); - - - /** - * Set whether literals are treated as binary, rather than NetRexx types - */ - public void setBinary(String binary) { - this.binary = Project.toBoolean(binary); - } - - /** - * Set the classpath used for NetRexx compilation - */ - public void setClasspath(String classpath) { - this.classpath = classpath; - } - - /** - * Set whether comments are passed through to the generated java source. - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false - */ - public void setComments(String comments) { - this.comments = Project.toBoolean(comments); - } - - /** - * Set whether error messages come out in compact or verbose format. - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false - */ - public void setCompact(String compact) { - this.compact = Project.toBoolean(compact); - } - - /** - * Set whether the NetRexx compiler should compile the generated java code - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is true. - * Setting this flag to false, will automatically set the keep flag to true. - */ - public void setCompile(String compile) { - this.compile = Project.toBoolean(compile); - if (!this.compile && !this.keep) this.keep = true; - } - - /** - * Set whether or not messages should be displayed on the 'console' - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is true. - */ - public void setConsole(String console) { - this.console = Project.toBoolean(console); - } - - /** - * Whether variable cross references are generated - */ - public void setCrossref(String crossref) { - this.crossref = Project.toBoolean(crossref); - } - - /** - * Set whether decimal arithmetic should be used for the netrexx code. - * Binary arithmetic is used when this flag is turned off. - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is true. - */ - public void setDecimal(String decimal) { - this.decimal = Project.toBoolean(decimal); - } - - /** - * Set the destination directory into which the NetRexx source - * files should be copied and then compiled. - */ - public void setDestDir(String destDirName) { - destDir = project.resolveFile(destDirName); - } - - /** - * Whether diagnostic information about the compile is generated - */ - public void setDiag(String diag) { - this.diag = Project.toBoolean(diag); - } - - /** - * Sets whether variables must be declared explicitly before use. - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setExplicit(String explicit) { - this.explicit = Project.toBoolean(explicit); - } - - /** - * Whether the generated java code is formatted nicely or left to match NetRexx - * line numbers for call stack debugging - */ - public void setFormat(String format) { - this.format = Project.toBoolean(format); - } - - /** - * Whether the generated java code is produced - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setJava(String java) { - this.java = Project.toBoolean(java); - } - - - /** - * Sets whether the generated java source file should be kept after compilation. - * The generated files will have an extension of .java.keep, not .java - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setKeep(String keep) { - this.keep = Project.toBoolean(keep); - } - - /** - * Whether the compiler text logo is displayed when compiling - */ - public void setLogo(String logo) { - this.logo = Project.toBoolean(logo); - } - - /** - * Whether the generated .java file should be replaced when compiling - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setReplace(String replace) { - this.replace = Project.toBoolean(replace); - } - - /** - * Sets whether the compiler messages will be written to NetRexxC.log as - * well as to the console - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setSavelog(String savelog) { - this.savelog = Project.toBoolean(savelog); - } - - /** - * Tells the NetRexx compiler to store the class files in the same directory - * as the source files. The alternative is the working directory - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is true. - */ - public void setSourcedir(String sourcedir) { - this.sourcedir = Project.toBoolean(sourcedir); - } - - /** - * Set the source dir to find the source Java files. - */ - public void setSrcDir(String srcDirName) { - srcDir = project.resolveFile(srcDirName); - } - - /** - * Tells the NetRexx compiler that method calls always need parentheses, - * even if no arguments are needed, e.g. aStringVar.getBytes - * vs. aStringVar.getBytes() - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setStrictargs(String strictargs) { - this.strictargs = Project.toBoolean(strictargs); - } - - /** - * Tells the NetRexx compile that assignments must match exactly on type - */ - public void setStrictassign(String strictassign) { - this.strictassign = Project.toBoolean(strictassign); - } - - /** - * Specifies whether the NetRexx compiler should be case sensitive or not - */ - public void setStrictcase(String strictcase) { - this.strictcase = Project.toBoolean(strictcase); - } - - /** - * Sets whether classes need to be imported explicitly using an - * import statement. By default the NetRexx compiler will import - * certain packages automatically - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setStrictimport(String strictimport) { - this.strictimport = Project.toBoolean(strictimport); - } - - /** - * Sets whether local properties need to be qualified explicitly using this - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setStrictprops(String strictprops) { - this.strictprops = Project.toBoolean(strictprops); - } - - - /** - * Whether the compiler should force catching of exceptions by explicitly named types - */ - public void setStrictsignal(String strictsignal) { - this.strictsignal = Project.toBoolean(strictsignal); - } - - /** - * Sets whether debug symbols should be generated into the class file - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setSymbols(String symbols) { - this.symbols = Project.toBoolean(symbols); - } - - /** - * Asks the NetRexx compiler to print compilation times to the console - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setTime(String time) { - this.time = Project.toBoolean(time); - } - - /** - * Turns on or off tracing and directs the resultant trace output - * Valid values are: "trace", "trace1", "trace2" and "notrace". - * "trace" and "trace2" - */ - public void setTrace(String trace) { - if (trace.equalsIgnoreCase("trace") - || trace.equalsIgnoreCase("trace1") - || trace.equalsIgnoreCase("trace2") - || trace.equalsIgnoreCase("notrace")) { - this.trace = trace; - } else { - throw new BuildException("Unknown trace value specified: '" + trace + "'"); - } - } - - /** - * Tells the NetRexx compiler that the source is in UTF8 - * Valid true values are "on" or "true". Anything else sets the flag to false. - * The default value is false. - */ - public void setUtf8(String utf8) { - this.utf8 = Project.toBoolean(utf8); - } - - /** - * Whether lots of warnings and error messages should be generated - */ - public void setVerbose(String verbose) { - this.verbose = verbose; - } - - /** - * Executes the task, i.e. does the actual compiler call - */ - public void execute() throws BuildException { - - // first off, make sure that we've got a srcdir and destdir - if (srcDir == null || destDir == null ) { - throw new BuildException("srcDir and destDir attributes must be set!"); - } - - // scan source and dest dirs to build up both copy lists and - // compile lists - // scanDir(srcDir, destDir); - DirectoryScanner ds = getDirectoryScanner(srcDir); - - String[] files = ds.getIncludedFiles(); - - scanDir(srcDir, destDir, files); - - // copy the source and support files - copyFilesToDestination(); - - // compile the source files - if (compileList.size() > 0) { - project.log("Compiling " + compileList.size() + " source files to " + destDir); - doNetRexxCompile(); - } - } - - /** - * Scans the directory looking for source files to be compiled and - * support files to be copied. - */ - private void scanDir(File srcDir, File destDir, String[] files) { - for (int i = 0; i < files.length; i++) { - File srcFile = new File(srcDir, files[i]); - File destFile = new File(destDir, files[i]); - String filename = files[i]; - // if it's a non source file, copy it if a later date than the - // dest - // if it's a source file, see if the destination class file - // needs to be recreated via compilation - if (filename.toLowerCase().endsWith(".nrx")) { - File classFile = new File(destDir, filename.substring(0, filename.lastIndexOf('.')) + ".class"); - if (!compile || srcFile.lastModified() > classFile.lastModified()) { - filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); - compileList.addElement(destFile.getAbsolutePath()); - } - } else { - if (srcFile.lastModified() > destFile.lastModified()) { - filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); - } - } - } - } - - /** - * Copy eligible files from the srcDir to destDir - */ - private void copyFilesToDestination() { - if (filecopyList.size() > 0) { - project.log("Copying " + filecopyList.size() + " files to " + destDir.getAbsolutePath()); - Enumeration enum = filecopyList.keys(); - while (enum.hasMoreElements()) { - String fromFile = (String)enum.nextElement(); - String toFile = (String)filecopyList.get(fromFile); - try { - project.copyFile(fromFile, toFile); - } catch (IOException ioe) { - String msg = "Failed to copy " + fromFile + " to " + toFile - + " due to " + ioe.getMessage(); - throw new BuildException(msg, ioe); - } - } - } - } - - /** - * Peforms a copmile using the NetRexx 1.1.x compiler - */ - private void doNetRexxCompile() throws BuildException { - project.log("Using NetRexx compiler", project.MSG_VERBOSE); - String classpath = getCompileClasspath(); - StringBuffer compileOptions = new StringBuffer(); - StringBuffer fileList = new StringBuffer(); - - // create an array of strings for input to the compiler: one array - // comes from the compile options, the other from the compileList - String[] compileOptionsArray = getCompileOptionsAsArray(); - String[] fileListArray = new String[compileList.size()]; - Enumeration e = compileList.elements(); - int j = 0; - while (e.hasMoreElements()) { - fileListArray[j] = (String)e.nextElement(); - j++; - } - // create a single array of arguments for the compiler - String compileArgs[] = new String[compileOptionsArray.length + fileListArray.length]; - for (int i = 0; i < compileOptionsArray.length; i++) { - compileArgs[i] = compileOptionsArray[i]; - } - for (int i = 0; i < fileListArray.length; i++) { - compileArgs[i+compileOptionsArray.length] = fileListArray[i]; - } - - // print nice output about what we are doing for the log - compileOptions.append("Compilation args: "); - for (int i = 0; i < compileOptionsArray.length; i++) { - compileOptions.append(compileOptionsArray[i]); - compileOptions.append(" "); - } - project.log(compileOptions.toString(), project.MSG_VERBOSE); - - String eol = System.getProperty("line.separator"); - StringBuffer niceSourceList = new StringBuffer("Files to be compiled:" + eol); - - for (int i = 0; i < compileList.size(); i++) { - niceSourceList.append(" "); - niceSourceList.append(compileList.elementAt(i).toString()); - niceSourceList.append(eol); - } - - project.log(niceSourceList.toString(), project.MSG_VERBOSE); - - // need to set java.class.path property and restore it later - // since the NetRexx compiler has no option for the classpath - String currentClassPath = System.getProperty("java.class.path"); - Properties currentProperties = System.getProperties(); - currentProperties.put("java.class.path", classpath); - - try { - StringWriter out = new StringWriter(); - int rc = COM.ibm.netrexx.process.NetRexxC.main( - new Rexx(compileArgs), new PrintWriter(out)); - - if (rc > 1) { // 1 is warnings from real NetRexxC - project.log(out.toString(), Project.MSG_ERR); - String msg = "Compile failed, messages should have been provided."; - throw new BuildException(msg); - } - else if (rc == 1) { - project.log(out.toString(), Project.MSG_WARN); - } - else { - project.log(out.toString(), Project.MSG_INFO); - } - } finally { - // need to reset java.class.path property - // since the NetRexx compiler has no option for the classpath - currentProperties = System.getProperties(); - currentProperties.put("java.class.path", currentClassPath); - } - } - - /** - * Builds the compilation classpath. - */ - private String getCompileClasspath() { - StringBuffer classpath = new StringBuffer(); - - // add dest dir to classpath so that previously compiled and - // untouched classes are on classpath - classpath.append(destDir.getAbsolutePath()); - - // add our classpath to the mix - if (this.classpath != null) { - addExistingToClasspath(classpath, this.classpath); - } - - // add the system classpath - // addExistingToClasspath(classpath,System.getProperty("java.class.path")); - return classpath.toString(); - } - - /** - * This - */ - private String[] getCompileOptionsAsArray() { - Vector options = new Vector(); - options.addElement(binary ? "-binary" : "-nobinary"); - options.addElement(comments ? "-comments" : "-nocomments"); - options.addElement(compile ? "-compile" : "-nocompile"); - options.addElement(compact ? "-compact" : "-nocompact"); - options.addElement(console ? "-console" : "-noconsole"); - options.addElement(crossref ? "-crossref" : "-nocrossref"); - options.addElement(decimal ? "-decimal" : "-nodecimal"); - options.addElement(diag ? "-diag" : "-nodiag"); - options.addElement(explicit ? "-explicit": "-noexplicit"); - options.addElement(format ? "-format" : "-noformat"); - options.addElement(keep ? "-keep" : "-nokeep"); - options.addElement(logo ? "-logo" : "-nologo"); - options.addElement(replace ? "-replace" : "-noreplace"); - options.addElement(savelog ? "-savelog" : "-nosavelog"); - options.addElement(sourcedir ? "-sourcedir" : "-nosourcedir"); - options.addElement(strictargs ? "-strictargs" : "-nostrictargs"); - options.addElement(strictassign ? "-strictassign" : "-nostrictassign"); - options.addElement(strictcase ? "-strictcase": "-nostrictcase"); - options.addElement(strictimport ? "-strictimport" : "-nostrictimport"); - options.addElement(strictprops ? "-strictprops" : "-nostrictprops"); - options.addElement(strictsignal ? "-strictsignal" : "-nostrictsignal"); - options.addElement(symbols ? "-symbols" : "-nosymbols"); - options.addElement(time ? "-time" : "-notime"); - options.addElement("-" + trace); - options.addElement(utf8 ? "-utf8" : "-noutf8"); - options.addElement("-" + verbose); - String[] results = new String[options.size()]; - options.copyInto(results); - return results; - } - /** - * Takes a classpath-like string, and adds each element of - * this string to a new classpath, if the components exist. - * Components that don't exist, aren't added. - * We do this, because jikes issues warnings for non-existant - * files/dirs in his classpath, and these warnings are pretty - * annoying. - * @param target - target classpath - * @param source - source classpath - * to get file objects. - */ - private void addExistingToClasspath(StringBuffer target,String source) { - StringTokenizer tok = new StringTokenizer(source, - System.getProperty("path.separator"), false); - while (tok.hasMoreTokens()) { - File f = project.resolveFile(tok.nextToken()); - - if (f.exists()) { - target.append(File.pathSeparator); - target.append(f.getAbsolutePath()); - } else { - project.log("Dropping from classpath: "+ - f.getAbsolutePath(),project.MSG_VERBOSE); - } - } - - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java b/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java deleted file mode 100644 index bcd2df1ae..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java +++ /dev/null @@ -1,163 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 - * . - * - * Task to rename files based on extension. This task has the following - * properties which can be set: - *
    - *
  • fromExtension:
  • - *
  • toExtension:
  • - *
  • srcDir:
  • - *
  • replace:
  • - *
- * - * @author dIon Gillard dion@multitask.com.au - * @version 1.2 - */ - -package org.apache.tools.ant.taskdefs.optional; - -import java.io.*; -import java.util.*; -import org.apache.tools.ant.*; -import org.apache.tools.ant.taskdefs.*; - -/** - * - * @author dion - */ -public class RenameExtensions extends MatchingTask { - - private String fromExtension = ""; - private String toExtension = ""; - private boolean replace = false; - private File srcDir; - - - /** Creates new RenameExtensions */ - public RenameExtensions() { - super(); - } - - /** store fromExtension **/ - public void setFromExtension(String from) { - fromExtension = from; - } - - /** store toExtension **/ - public void setToExtension(String to) { - toExtension = to; - } - - /** - * store replace attribute - this determines whether the target file - * should be overwritten if present - */ - public void setReplace(String replaceString) { - replace = Project.toBoolean(replaceString); - } - - /** - * Set the source dir to find the files to be renamed. - */ - public void setSrcDir(String srcDirName) { - srcDir = project.resolveFile(srcDirName); - } - - /** - * Executes the task, i.e. does the actual compiler call - */ - public void execute() throws BuildException { - - // first off, make sure that we've got a from and to extension - if (fromExtension == null || toExtension == null || srcDir == null) { - throw new BuildException("srcDir, fromExtension and toExtension attributes must be set!"); - } - - // scan source and dest dirs to build up rename list - DirectoryScanner ds = getDirectoryScanner(srcDir); - - String[] files = ds.getIncludedFiles(); - - Hashtable renameList = scanDir(srcDir, files); - - Enumeration e = renameList.keys(); - File fromFile = null; - File toFile = null; - while (e.hasMoreElements()) { - fromFile = (File)e.nextElement(); - toFile = (File)renameList.get(fromFile); - if (toFile.exists() && replace) toFile.delete(); - if (!fromFile.renameTo(toFile)) throw new BuildException("Rename from: '" + fromFile + "' to '" + toFile + "' failed."); - } - - } - private Hashtable scanDir(File srcDir, String[] files) { - Hashtable list = new Hashtable(); - for (int i = 0; i < files.length; i++) { - File srcFile = new File(srcDir, files[i]); - String filename = files[i]; - // if it's a file that ends in the fromExtension, copy to the rename list - if (filename.toLowerCase().endsWith(fromExtension)) { - File destFile = new File(srcDir, filename.substring(0, filename.lastIndexOf(fromExtension)) + toExtension); - if (replace || !destFile.exists()) { - list.put(srcFile, destFile); - } else { - project.log("Rejecting file: '" + srcFile + "' for rename as replace is false and file exists", Project.MSG_VERBOSE); - } - } else { - project.log("File '"+ filename + "' doesn't match fromExtension: '" + fromExtension + "'", Project.MSG_VERBOSE); - } - } - return list; - } - -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Script.java b/src/main/org/apache/tools/ant/taskdefs/optional/Script.java deleted file mode 100644 index 86ddc12fd..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/Script.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.optional; - -import org.apache.tools.ant.*; -import java.io.*; -import java.util.*; -import com.ibm.bsf.*; - -/** - * Execute a script - * - * @author Sam Ruby rubys@us.ibm.com - */ -public class Script extends Task { - private String language; - private String script = ""; - private Hashtable beans = new Hashtable(); - - /** - * Add a list of named objects to the list to be exported to the script - */ - private void addBeans(Hashtable dictionary) { - for (Enumeration e=dictionary.keys(); e.hasMoreElements(); ) { - String key = (String)e.nextElement(); - - boolean isValid = key.length()>0 && - Character.isJavaIdentifierStart(key.charAt(0)); - - for (int i=1; isValid && i", 0, 0, script); - } catch (BSFException be) { - Exception e = be; - Throwable te = be.getTargetException(); - if (te != null && te instanceof Exception) e = (Exception) te; - throw new BuildException(e); - } - } - - /** - * Defines the language (required). - * - * @param msg Sets the value for the script variable. - */ - public void setLanguage(String language) { - this.language = language; - } - - /** - * Load the script from an external file - * - * @param msg Sets the value for the script variable. - */ - public void setSrc(String fileName) { - File file = new File(fileName); - if (!file.exists()) - throw new BuildException("file " + fileName + " not found."); - - int count = (int)file.length(); - byte data[] = new byte[count]; - - try { - FileInputStream inStream = new FileInputStream(file); - inStream.read(data); - inStream.close(); - } catch (IOException e) { - throw new BuildException(e); - } - - script += new String(data); - } - - /** - * Defines the script. - * - * @param msg Sets the value for the script variable. - */ - public void addText(String text) { - this.script += text; - } -} diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java deleted file mode 100644 index 29ff7eba3..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/XalanLiaison.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.optional; - -import org.apache.tools.ant.taskdefs.XSLTLiaison; - -import org.apache.xalan.xslt.XSLTProcessorFactory; -import org.apache.xalan.xslt.XSLTProcessor; -import org.apache.xalan.xslt.XSLTInputSource; -import org.apache.xalan.xslt.XSLTResultTarget; - -/** - * - * @author Sam Ruby - * @version $Revision$ $Date$ - */ -public class XalanLiaison implements XSLTLiaison { - - XSLTProcessor processor; - XSLTInputSource xslSheet; - - public XalanLiaison() throws Exception { - processor = XSLTProcessorFactory.getProcessor(); - } - - public void setStylesheet(String fileName) throws Exception { - xslSheet = new XSLTInputSource (fileName); - }; - - public void transform(String infile, String outfile) throws Exception { - processor.process(new XSLTInputSource(infile), xslSheet, - new XSLTResultTarget(outfile)); - } - -} //-- XalanLiaison diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java b/src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java deleted file mode 100644 index b9dbad22d..000000000 --- a/src/main/org/apache/tools/ant/taskdefs/optional/XslpLiaison.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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.optional; - -import java.io.FileWriter; - -import org.apache.tools.ant.taskdefs.XSLTLiaison; - -import com.kvisco.xsl.XSLProcessor; -import com.kvisco.xsl.XSLReader; -import com.kvisco.xsl.XSLStylesheet; - -/** - * - * @author Sam Ruby - * @version $Revision$ $Date$ - */ -public class XslpLiaison implements XSLTLiaison { - - XSLProcessor processor; - XSLStylesheet xslSheet; - - public XslpLiaison() { - processor = new XSLProcessor(); - } - - public void setStylesheet(String fileName) throws Exception { - XSLReader xslReader = new XSLReader(); - xslSheet = xslReader.read( fileName ); - }; - - public void transform(String infile, String outfile) throws Exception { - processor.process(infile, xslSheet, new FileWriter(outfile)); - } - -} //-- XSLPLiaison diff --git a/src/main/org/apache/tools/ant/version.txt b/src/main/org/apache/tools/ant/version.txt deleted file mode 100644 index b6b2f8db9..000000000 --- a/src/main/org/apache/tools/ant/version.txt +++ /dev/null @@ -1,2 +0,0 @@ -VERSION=@VERSION@ -DATE=@DATE@ diff --git a/src/main/org/apache/tools/tar/TarBuffer.java b/src/main/org/apache/tools/tar/TarBuffer.java deleted file mode 100644 index dbf916625..000000000 --- a/src/main/org/apache/tools/tar/TarBuffer.java +++ /dev/null @@ -1,440 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 - * . - */ - -/* - * This package is based on the work done by Timothy Gerard Endres - * (time@ice.com) to whom the Ant project is very grateful for his great code. - */ - -package org.apache.tools.tar; - -import java.io.*; - -/** - * The TarBuffer class implements the tar archive concept - * of a buffered input stream. This concept goes back to the - * days of blocked tape drives and special io devices. In the - * Java universe, the only real function that this class - * performs is to ensure that files have the correct "block" - * size, or other tars will complain. - *

- * You should never have a need to access this class directly. - * TarBuffers are created by Tar IO Streams. - * - * @author Timothy Gerard Endres time@ice.com - */ - -public class TarBuffer { - - public static final int DEFAULT_RCDSIZE = (512); - public static final int DEFAULT_BLKSIZE = (DEFAULT_RCDSIZE * 20); - - private InputStream inStream; - private OutputStream outStream; - private byte[] blockBuffer; - private int currBlkIdx; - private int currRecIdx; - private int blockSize; - private int recordSize; - private int recsPerBlock; - private boolean debug; - - public TarBuffer(InputStream inStream) { - this(inStream, TarBuffer.DEFAULT_BLKSIZE); - } - - public TarBuffer(InputStream inStream, int blockSize) { - this(inStream, blockSize, TarBuffer.DEFAULT_RCDSIZE); - } - - public TarBuffer(InputStream inStream, int blockSize, int recordSize) { - this.inStream = inStream; - this.outStream = null; - - this.initialize(blockSize, recordSize); - } - - public TarBuffer(OutputStream outStream) { - this(outStream, TarBuffer.DEFAULT_BLKSIZE); - } - - public TarBuffer(OutputStream outStream, int blockSize) { - this(outStream, blockSize, TarBuffer.DEFAULT_RCDSIZE); - } - - public TarBuffer(OutputStream outStream, int blockSize, int recordSize) { - this.inStream = null; - this.outStream = outStream; - - this.initialize(blockSize, recordSize); - } - - /** - * Initialization common to all constructors. - */ - private void initialize(int blockSize, int recordSize) { - this.debug = false; - this.blockSize = blockSize; - this.recordSize = recordSize; - this.recsPerBlock = (this.blockSize / this.recordSize); - this.blockBuffer = new byte[this.blockSize]; - - if (this.inStream != null) { - this.currBlkIdx = -1; - this.currRecIdx = this.recsPerBlock; - } else { - this.currBlkIdx = 0; - this.currRecIdx = 0; - } - } - - /** - * Get the TAR Buffer's block size. Blocks consist of multiple records. - */ - public int getBlockSize() { - return this.blockSize; - } - - /** - * Get the TAR Buffer's record size. - */ - public int getRecordSize() { - return this.recordSize; - } - - /** - * Set the debugging flag for the buffer. - * - * @param debug If true, print debugging output. - */ - public void setDebug(boolean debug) { - this.debug = debug; - } - - /** - * Determine if an archive record indicate End of Archive. End of - * archive is indicated by a record that consists entirely of null bytes. - * - * @param record The record data to check. - */ - public boolean isEOFRecord(byte[] record) { - for (int i = 0, sz = this.getRecordSize(); i < sz; ++i) { - if (record[i] != 0) { - return false; - } - } - - return true; - } - - /** - * Skip over a record on the input stream. - */ - public void skipRecord() throws IOException { - if (this.debug) { - System.err.println("SkipRecord: recIdx = " + this.currRecIdx - + " blkIdx = " + this.currBlkIdx); - } - - if (this.inStream == null) { - throw new IOException("reading (via skip) from an output buffer"); - } - - if (this.currRecIdx >= this.recsPerBlock) { - if (!this.readBlock()) { - return; // UNDONE - } - } - - this.currRecIdx++; - } - - /** - * Read a record from the input stream and return the data. - * - * @return The record data. - */ - public byte[] readRecord() throws IOException { - if (this.debug) { - System.err.println("ReadRecord: recIdx = " + this.currRecIdx - + " blkIdx = " + this.currBlkIdx); - } - - if (this.inStream == null) { - throw new IOException("reading from an output buffer"); - } - - if (this.currRecIdx >= this.recsPerBlock) { - if (!this.readBlock()) { - return null; - } - } - - byte[] result = new byte[this.recordSize]; - - System.arraycopy(this.blockBuffer, - (this.currRecIdx * this.recordSize), result, 0, - this.recordSize); - - this.currRecIdx++; - - return result; - } - - /** - * @return false if End-Of-File, else true - */ - private boolean readBlock() throws IOException { - if (this.debug) { - System.err.println("ReadBlock: blkIdx = " + this.currBlkIdx); - } - - if (this.inStream == null) { - throw new IOException("reading from an output buffer"); - } - - this.currRecIdx = 0; - - int offset = 0; - int bytesNeeded = this.blockSize; - - while (bytesNeeded > 0) { - long numBytes = this.inStream.read(this.blockBuffer, offset, - bytesNeeded); - - // - // NOTE - // We have fit EOF, and the block is not full! - // - // This is a broken archive. It does not follow the standard - // blocking algorithm. However, because we are generous, and - // it requires little effort, we will simply ignore the error - // and continue as if the entire block were read. This does - // not appear to break anything upstream. We used to return - // false in this case. - // - // Thanks to 'Yohann.Roussel@alcatel.fr' for this fix. - // - if (numBytes == -1) { - break; - } - - offset += numBytes; - bytesNeeded -= numBytes; - - if (numBytes != this.blockSize) { - if (this.debug) { - System.err.println("ReadBlock: INCOMPLETE READ " - + numBytes + " of " + this.blockSize - + " bytes read."); - } - } - } - - this.currBlkIdx++; - - return true; - } - - /** - * Get the current block number, zero based. - * - * @return The current zero based block number. - */ - public int getCurrentBlockNum() { - return this.currBlkIdx; - } - - /** - * Get the current record number, within the current block, zero based. - * Thus, current offset = (currentBlockNum * recsPerBlk) + currentRecNum. - * - * @return The current zero based record number. - */ - public int getCurrentRecordNum() { - return this.currRecIdx - 1; - } - - /** - * Write an archive record to the archive. - * - * @param record The record data to write to the archive. - */ - public void writeRecord(byte[] record) throws IOException { - if (this.debug) { - System.err.println("WriteRecord: recIdx = " + this.currRecIdx - + " blkIdx = " + this.currBlkIdx); - } - - if (this.outStream == null) { - throw new IOException("writing to an input buffer"); - } - - if (record.length != this.recordSize) { - throw new IOException("record to write has length '" - + record.length - + "' which is not the record size of '" - + this.recordSize + "'"); - } - - if (this.currRecIdx >= this.recsPerBlock) { - this.writeBlock(); - } - - System.arraycopy(record, 0, this.blockBuffer, - (this.currRecIdx * this.recordSize), - this.recordSize); - - this.currRecIdx++; - } - - /** - * Write an archive record to the archive, where the record may be - * inside of a larger array buffer. The buffer must be "offset plus - * record size" long. - * - * @param buf The buffer containing the record data to write. - * @param offset The offset of the record data within buf. - */ - public void writeRecord(byte[] buf, int offset) throws IOException { - if (this.debug) { - System.err.println("WriteRecord: recIdx = " + this.currRecIdx - + " blkIdx = " + this.currBlkIdx); - } - - if (this.outStream == null) { - throw new IOException("writing to an input buffer"); - } - - if ((offset + this.recordSize) > buf.length) { - throw new IOException("record has length '" + buf.length - + "' with offset '" + offset - + "' which is less than the record size of '" - + this.recordSize + "'"); - } - - if (this.currRecIdx >= this.recsPerBlock) { - this.writeBlock(); - } - - System.arraycopy(buf, offset, this.blockBuffer, - (this.currRecIdx * this.recordSize), - this.recordSize); - - this.currRecIdx++; - } - - /** - * Write a TarBuffer block to the archive. - */ - private void writeBlock() throws IOException { - if (this.debug) { - System.err.println("WriteBlock: blkIdx = " + this.currBlkIdx); - } - - if (this.outStream == null) { - throw new IOException("writing to an input buffer"); - } - - this.outStream.write(this.blockBuffer, 0, this.blockSize); - this.outStream.flush(); - - this.currRecIdx = 0; - this.currBlkIdx++; - } - - /** - * Flush the current data block if it has any data in it. - */ - private void flushBlock() throws IOException { - if (this.debug) { - System.err.println("TarBuffer.flushBlock() called."); - } - - if (this.outStream == null) { - throw new IOException("writing to an input buffer"); - } - - if (this.currRecIdx > 0) { - this.writeBlock(); - } - } - - /** - * Close the TarBuffer. If this is an output buffer, also flush the - * current block before closing. - */ - public void close() throws IOException { - if (this.debug) { - System.err.println("TarBuffer.closeBuffer()."); - } - - if (this.outStream != null) { - this.flushBlock(); - - if (this.outStream != System.out - && this.outStream != System.err) { - this.outStream.close(); - - this.outStream = null; - } - } else if (this.inStream != null) { - if (this.inStream != System.in) { - this.inStream.close(); - - this.inStream = null; - } - } - } -} diff --git a/src/main/org/apache/tools/tar/TarConstants.java b/src/main/org/apache/tools/tar/TarConstants.java deleted file mode 100644 index 41b76c327..000000000 --- a/src/main/org/apache/tools/tar/TarConstants.java +++ /dev/null @@ -1,182 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 - * . - */ - -/* - * This package is based on the work done by Timothy Gerard Endres - * (time@ice.com) to whom the Ant project is very grateful for his great code. - */ - -package org.apache.tools.tar; - -/** - * This interface contains all the definitions used in the package. - * - * @author Timothy Gerard Endres time@ice.com - * @author Stefano Mazzocchi stefano@apache.org - */ - -public interface TarConstants { - - /** - * The length of the name field in a header buffer. - */ - public static final int NAMELEN = 100; - - /** - * The length of the mode field in a header buffer. - */ - public static final int MODELEN = 8; - - /** - * The length of the user id field in a header buffer. - */ - public static final int UIDLEN = 8; - - /** - * The length of the group id field in a header buffer. - */ - public static final int GIDLEN = 8; - - /** - * The length of the checksum field in a header buffer. - */ - public static final int CHKSUMLEN = 8; - - /** - * The length of the size field in a header buffer. - */ - public static final int SIZELEN = 12; - - /** - * The length of the magic field in a header buffer. - */ - public static final int MAGICLEN = 8; - - /** - * The length of the modification time field in a header buffer. - */ - public static final int MODTIMELEN = 12; - - /** - * The length of the user name field in a header buffer. - */ - public static final int UNAMELEN = 32; - - /** - * The length of the group name field in a header buffer. - */ - public static final int GNAMELEN = 32; - - /** - * The length of the devices field in a header buffer. - */ - public static final int DEVLEN = 8; - - /** - * LF_ constants represent the "link flag" of an entry, or more commonly, - * the "entry type". This is the "old way" of indicating a normal file. - */ - public static final byte LF_OLDNORM = 0; - - /** - * Normal file type. - */ - public static final byte LF_NORMAL = (byte) '0'; - - /** - * Link file type. - */ - public static final byte LF_LINK = (byte) '1'; - - /** - * Symbolic link file type. - */ - public static final byte LF_SYMLINK = (byte) '2'; - - /** - * Character device file type. - */ - public static final byte LF_CHR = (byte) '3'; - - /** - * Block device file type. - */ - public static final byte LF_BLK = (byte) '4'; - - /** - * Directory file type. - */ - public static final byte LF_DIR = (byte) '5'; - - /** - * FIFO (pipe) file type. - */ - public static final byte LF_FIFO = (byte) '6'; - - /** - * Contiguous file type. - */ - public static final byte LF_CONTIG = (byte) '7'; - - /** - * The magic tag representing a POSIX tar archive. - */ - public static final String TMAGIC = "ustar"; - - /** - * The magic tag representing a GNU tar archive. - */ - public static final String GNU_TMAGIC = "ustar "; - -} diff --git a/src/main/org/apache/tools/tar/TarEntry.java b/src/main/org/apache/tools/tar/TarEntry.java deleted file mode 100644 index 436579d67..000000000 --- a/src/main/org/apache/tools/tar/TarEntry.java +++ /dev/null @@ -1,572 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 - * . - */ - -/* - * This package is based on the work done by Timothy Gerard Endres - * (time@ice.com) to whom the Ant project is very grateful for his great code. - */ - -package org.apache.tools.tar; - -import java.io.*; -import java.util.*; - -/** - * This class represents an entry in a Tar archive. It consists - * of the entry's header, as well as the entry's File. Entries - * can be instantiated in one of three ways, depending on how - * they are to be used. - *

- * TarEntries that are created from the header bytes read from - * an archive are instantiated with the TarEntry( byte[] ) - * constructor. These entries will be used when extracting from - * or listing the contents of an archive. These entries have their - * header filled in using the header bytes. They also set the File - * to null, since they reference an archive entry not a file. - *

- * TarEntries that are created from Files that are to be written - * into an archive are instantiated with the TarEntry( File ) - * constructor. These entries have their header filled in using - * the File's information. They also keep a reference to the File - * for convenience when writing entries. - *

- * Finally, TarEntries can be constructed from nothing but a name. - * This allows the programmer to construct the entry by hand, for - * instance when only an InputStream is available for writing to - * the archive, and the header information is constructed from - * other information. In this case the header fields are set to - * defaults and the File is set to null. - * - *

- * The C structure for a Tar Entry's header is: - *

- * struct header {
- * char name[NAMSIZ];
- * char mode[8];
- * char uid[8];
- * char gid[8];
- * char size[12];
- * char mtime[12];
- * char chksum[8];
- * char linkflag;
- * char linkname[NAMSIZ];
- * char magic[8];
- * char uname[TUNMLEN];
- * char gname[TGNMLEN];
- * char devmajor[8];
- * char devminor[8];
- * } header;
- * 
- * - * @author Timothy Gerard Endres time@ice.com - * @author Stefano Mazzocchi stefano@apache.org - */ - -public class TarEntry implements TarConstants { - - private StringBuffer name; /** The entry's name. */ - private int mode; /** The entry's permission mode. */ - private int userId; /** The entry's user id. */ - private int groupId; /** The entry's group id. */ - private long size; /** The entry's size. */ - private long modTime; /** The entry's modification time. */ - private int checkSum; /** The entry's checksum. */ - private byte linkFlag; /** The entry's link flag. */ - private StringBuffer linkName; /** The entry's link name. */ - private StringBuffer magic; /** The entry's magic tag. */ - private StringBuffer userName; /** The entry's user name. */ - private StringBuffer groupName; /** The entry's group name. */ - private int devMajor; /** The entry's major device number. */ - private int devMinor; /** The entry's minor device number. */ - private File file; /** The entry's file reference */ - - /** - * Construct an empty entry and prepares the header values. - */ - private TarEntry () { - this.magic = new StringBuffer(TMAGIC); - this.name = new StringBuffer(); - this.linkName = new StringBuffer(); - - String user = System.getProperty("user.name", ""); - - if (user.length() > 31) { - user = user.substring(0, 31); - } - - this.userId = 0; - this.groupId = 0; - this.userName = new StringBuffer(user); - this.groupName = new StringBuffer(""); - this.file = null; - } - - /** - * Construct an entry with only a name. This allows the programmer - * to construct the entry's header "by hand". File is set to null. - */ - public TarEntry(String name) { - this(); - - boolean isDir = name.endsWith("/"); - - this.checkSum = 0; - this.devMajor = 0; - this.devMinor = 0; - this.name = new StringBuffer(name); - this.mode = isDir ? 040755 : 0100644; - this.linkFlag = isDir ? LF_DIR : LF_NORMAL; - this.userId = 0; - this.groupId = 0; - this.size = 0; - this.checkSum = 0; - this.modTime = (new Date()).getTime() / 1000; - this.linkName = new StringBuffer(""); - this.userName = new StringBuffer(""); - this.groupName = new StringBuffer(""); - this.devMajor = 0; - this.devMinor = 0; - } - - /** - * Construct an entry for a file. File is set to file, and the - * header is constructed from information from the file. - * - * @param file The file that the entry represents. - */ - public TarEntry(File file) { - this(); - - this.file = file; - - String name = file.getPath(); - String osname = System.getProperty("os.name"); - - if (osname != null) { - - // Strip off drive letters! - // REVIEW Would a better check be "(File.separator == '\')"? - String Win32Prefix = "Windows"; - String prefix = osname.substring(0, Win32Prefix.length()); - - if (prefix.equalsIgnoreCase(Win32Prefix)) { - if (name.length() > 2) { - char ch1 = name.charAt(0); - char ch2 = name.charAt(1); - - if (ch2 == ':' - && ((ch1 >= 'a' && ch1 <= 'z') - || (ch1 >= 'A' && ch1 <= 'Z'))) { - name = name.substring(2); - } - } - } - } - - name = name.replace(File.separatorChar, '/'); - - // No absolute pathnames - // Windows (and Posix?) paths can start with "\\NetworkDrive\", - // so we loop on starting /'s. - while (name.startsWith("/")) { - name = name.substring(1); - } - - this.linkName = new StringBuffer(""); - this.name = new StringBuffer(name); - - if (file.isDirectory()) { - this.mode = 040755; - this.linkFlag = LF_DIR; - - if (this.name.charAt(this.name.length() - 1) != '/') { - this.name.append("/"); - } - } else { - this.mode = 0100644; - this.linkFlag = LF_NORMAL; - } - - if (this.name.length() > NAMELEN) { - throw new RuntimeException("file name '" + this.name - + "' is too long ( > " - + NAMELEN + " bytes)"); - - // UNDONE When File lets us get the userName, use it! - } - - this.size = file.length(); - this.modTime = file.lastModified() / 1000; - this.checkSum = 0; - this.devMajor = 0; - this.devMinor = 0; - } - - /** - * Construct an entry from an archive's header bytes. File is set - * to null. - * - * @param headerBuf The header bytes from a tar archive entry. - */ - public TarEntry(byte[] headerBuf) { - this(); - this.parseTarHeader(headerBuf); - } - - /** - * Determine if the two entries are equal. Equality is determined - * by the header names being equal. - * - * @return it Entry to be checked for equality. - * @return True if the entries are equal. - */ - public boolean equals(TarEntry it) { - return this.getName().equals(it.getName()); - } - - /** - * Determine if the given entry is a descendant of this entry. - * Descendancy is determined by the name of the descendant - * starting with this entry's name. - * - * @param desc Entry to be checked as a descendent of this. - * @return True if entry is a descendant of this. - */ - public boolean isDescendent(TarEntry desc) { - return desc.getName().startsWith(this.getName()); - } - - /** - * Get this entry's name. - * - * @return This entry's name. - */ - public String getName() { - return this.name.toString(); - } - - /** - * Set this entry's name. - * - * @param name This entry's new name. - */ - public void setName(String name) { - this.name = new StringBuffer(name); - } - - /** - * Get this entry's user id. - * - * @return This entry's user id. - */ - public int getUserId() { - return this.userId; - } - - /** - * Set this entry's user id. - * - * @param userId This entry's new user id. - */ - public void setUserId(int userId) { - this.userId = userId; - } - - /** - * Get this entry's group id. - * - * @return This entry's group id. - */ - public int getGroupId() { - return this.groupId; - } - - /** - * Set this entry's group id. - * - * @param groupId This entry's new group id. - */ - public void setGroupId(int groupId) { - this.groupId = groupId; - } - - /** - * Get this entry's user name. - * - * @return This entry's user name. - */ - public String getUserName() { - return this.userName.toString(); - } - - /** - * Set this entry's user name. - * - * @param userName This entry's new user name. - */ - public void setUserName(String userName) { - this.userName = new StringBuffer(userName); - } - - /** - * Get this entry's group name. - * - * @return This entry's group name. - */ - public String getGroupName() { - return this.groupName.toString(); - } - - /** - * Set this entry's group name. - * - * @param groupName This entry's new group name. - */ - public void setGroupName(String groupName) { - this.groupName = new StringBuffer(groupName); - } - - /** - * Convenience method to set this entry's group and user ids. - * - * @param userId This entry's new user id. - * @param groupId This entry's new group id. - */ - public void setIds(int userId, int groupId) { - this.setUserId(userId); - this.setGroupId(groupId); - } - - /** - * Convenience method to set this entry's group and user names. - * - * @param userName This entry's new user name. - * @param groupName This entry's new group name. - */ - public void setNames(String userName, String groupName) { - this.setUserName(userName); - this.setGroupName(groupName); - } - - /** - * Set this entry's modification time. The parameter passed - * to this method is in "Java time". - * - * @param time This entry's new modification time. - */ - public void setModTime(long time) { - this.modTime = time / 1000; - } - - /** - * Set this entry's modification time. - * - * @param time This entry's new modification time. - */ - public void setModTime(Date time) { - this.modTime = time.getTime() / 1000; - } - - /** - * Set this entry's modification time. - * - * @param time This entry's new modification time. - */ - public Date getModTime() { - return new Date(this.modTime * 1000); - } - - /** - * Get this entry's file. - * - * @return This entry's file. - */ - public File getFile() { - return this.file; - } - - /** - * Get this entry's file size. - * - * @return This entry's file size. - */ - public long getSize() { - return this.size; - } - - /** - * Set this entry's file size. - * - * @param size This entry's new file size. - */ - public void setSize(long size) { - this.size = size; - } - - /** - * Return whether or not this entry represents a directory. - * - * @return True if this entry is a directory. - */ - public boolean isDirectory() { - if (this.file != null) { - return this.file.isDirectory(); - } - - if (this.linkFlag == LF_DIR) { - return true; - } - - if (this.getName().endsWith("/")) { - return true; - } - - return false; - } - - /** - * If this entry represents a file, and the file is a directory, return - * an array of TarEntries for this entry's children. - * - * @return An array of TarEntry's for this entry's children. - */ - public TarEntry[] getDirectoryEntries() { - if (this.file == null ||!this.file.isDirectory()) { - return new TarEntry[0]; - } - - String[] list = this.file.list(); - TarEntry[] result = new TarEntry[list.length]; - - for (int i = 0; i < list.length; ++i) { - result[i] = new TarEntry(new File(this.file, list[i])); - } - - return result; - } - - /** - * Write an entry's header information to a header buffer. - * - * @param outbuf The tar entry header buffer to fill in. - */ - public void writeEntryHeader(byte[] outbuf) { - int offset = 0; - - offset = TarUtils.getNameBytes(this.name, outbuf, offset, NAMELEN); - offset = TarUtils.getOctalBytes(this.mode, outbuf, offset, MODELEN); - offset = TarUtils.getOctalBytes(this.userId, outbuf, offset, UIDLEN); - offset = TarUtils.getOctalBytes(this.groupId, outbuf, offset, GIDLEN); - offset = TarUtils.getLongOctalBytes(this.size, outbuf, offset, SIZELEN); - offset = TarUtils.getLongOctalBytes(this.modTime, outbuf, offset, MODTIMELEN); - - int csOffset = offset; - - for (int c = 0; c < CHKSUMLEN; ++c) { - outbuf[offset++] = (byte) ' '; - } - - outbuf[offset++] = this.linkFlag; - offset = TarUtils.getNameBytes(this.linkName, outbuf, offset, NAMELEN); - offset = TarUtils.getNameBytes(this.magic, outbuf, offset, MAGICLEN); - offset = TarUtils.getNameBytes(this.userName, outbuf, offset, UNAMELEN); - offset = TarUtils.getNameBytes(this.groupName, outbuf, offset, GNAMELEN); - offset = TarUtils.getOctalBytes(this.devMajor, outbuf, offset, DEVLEN); - offset = TarUtils.getOctalBytes(this.devMinor, outbuf, offset, DEVLEN); - - while (offset < outbuf.length) { - outbuf[offset++] = 0; - } - - long checkSum = TarUtils.computeCheckSum(outbuf); - - TarUtils.getCheckSumOctalBytes(checkSum, outbuf, csOffset, CHKSUMLEN); - } - - /** - * Parse an entry's header information from a header buffer. - * - * @param header The tar entry header buffer to get information from. - */ - public void parseTarHeader(byte[] header) { - int offset = 0; - - this.name = TarUtils.parseName(header, offset, NAMELEN); - offset += NAMELEN; - this.mode = (int) TarUtils.parseOctal(header, offset, MODELEN); - offset += MODELEN; - this.userId = (int) TarUtils.parseOctal(header, offset, UIDLEN); - offset += UIDLEN; - this.groupId = (int) TarUtils.parseOctal(header, offset, GIDLEN); - offset += GIDLEN; - this.size = TarUtils.parseOctal(header, offset, SIZELEN); - offset += SIZELEN; - this.modTime = TarUtils.parseOctal(header, offset, MODTIMELEN); - offset += MODTIMELEN; - this.checkSum = (int) TarUtils.parseOctal(header, offset, CHKSUMLEN); - offset += CHKSUMLEN; - this.linkFlag = header[offset++]; - this.linkName = TarUtils.parseName(header, offset, NAMELEN); - offset += NAMELEN; - this.magic = TarUtils.parseName(header, offset, MAGICLEN); - offset += MAGICLEN; - this.userName = TarUtils.parseName(header, offset, UNAMELEN); - offset += UNAMELEN; - this.groupName = TarUtils.parseName(header, offset, GNAMELEN); - offset += GNAMELEN; - this.devMajor = (int) TarUtils.parseOctal(header, offset, DEVLEN); - offset += DEVLEN; - this.devMinor = (int) TarUtils.parseOctal(header, offset, DEVLEN); - } -} diff --git a/src/main/org/apache/tools/tar/TarInputStream.java b/src/main/org/apache/tools/tar/TarInputStream.java deleted file mode 100644 index a0758983e..000000000 --- a/src/main/org/apache/tools/tar/TarInputStream.java +++ /dev/null @@ -1,419 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 - * . - */ - -/* - * This package is based on the work done by Timothy Gerard Endres - * (time@ice.com) to whom the Ant project is very grateful for his great code. - */ - -package org.apache.tools.tar; - -import java.io.*; - -/** - * The TarInputStream reads a UNIX tar archive as an InputStream. - * methods are provided to position at each successive entry in - * the archive, and the read each entry as a normal input stream - * using read(). - * - * @author Timothy Gerard Endres time@ice.com - * @author Stefano Mazzocchi stefano@apache.org - */ -public class TarInputStream extends FilterInputStream { - - protected boolean debug; - protected boolean hasHitEOF; - protected int entrySize; - protected int entryOffset; - protected byte[] oneBuf; - protected byte[] readBuf; - protected TarBuffer buffer; - protected TarEntry currEntry; - - public TarInputStream(InputStream is) { - this(is, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE); - } - - public TarInputStream(InputStream is, int blockSize) { - this(is, blockSize, TarBuffer.DEFAULT_RCDSIZE); - } - - public TarInputStream(InputStream is, int blockSize, int recordSize) { - super(is); - - this.buffer = new TarBuffer(is, blockSize, recordSize); - this.readBuf = null; - this.oneBuf = new byte[1]; - this.debug = false; - this.hasHitEOF = false; - } - - /** - * Sets the debugging flag. - * - * @param debugF True to turn on debugging. - */ - public void setDebug(boolean debug) { - this.debug = debug; - this.buffer.setDebug(debug); - } - - /** - * Closes this stream. Calls the TarBuffer's close() method. - */ - public void close() throws IOException { - this.buffer.close(); - } - - /** - * Get the record size being used by this stream's TarBuffer. - * - * @return The TarBuffer record size. - */ - public int getRecordSize() { - return this.buffer.getRecordSize(); - } - - /** - * Get the available data that can be read from the current - * entry in the archive. This does not indicate how much data - * is left in the entire archive, only in the current entry. - * This value is determined from the entry's size header field - * and the amount of data already read from the current entry. - * - * - * @return The number of available bytes for the current entry. - */ - public int available() throws IOException { - return this.entrySize - this.entryOffset; - } - - /** - * Skip bytes in the input buffer. This skips bytes in the - * current entry's data, not the entire archive, and will - * stop at the end of the current entry's data if the number - * to skip extends beyond that point. - * - * @param numToSkip The number of bytes to skip. - */ - public void skip(int numToSkip) throws IOException { - - // REVIEW - // This is horribly inefficient, but it ensures that we - // properly skip over bytes via the TarBuffer... - // - byte[] skipBuf = new byte[8 * 1024]; - - for (int num = numToSkip; num > 0; ) { - int numRead = this.read(skipBuf, 0, - (num > skipBuf.length ? skipBuf.length - : num)); - - if (numRead == -1) { - break; - } - - num -= numRead; - } - } - - /** - * Since we do not support marking just yet, we return false. - * - * @return False. - */ - public boolean markSupported() { - return false; - } - - /** - * Since we do not support marking just yet, we do nothing. - * - * @param markLimit The limit to mark. - */ - public void mark(int markLimit) {} - - /** - * Since we do not support marking just yet, we do nothing. - */ - public void reset() {} - - /** - * Get the next entry in this tar archive. This will skip - * over any remaining data in the current entry, if there - * is one, and place the input stream at the header of the - * next entry, and read the header and instantiate a new - * TarEntry from the header bytes and return that entry. - * If there are no more entries in the archive, null will - * be returned to indicate that the end of the archive has - * been reached. - * - * @return The next TarEntry in the archive, or null. - */ - public TarEntry getNextEntry() throws IOException { - if (this.hasHitEOF) { - return null; - } - - if (this.currEntry != null) { - int numToSkip = this.entrySize - this.entryOffset; - - if (this.debug) { - System.err.println("TarInputStream: SKIP currENTRY '" - + this.currEntry.getName() + "' SZ " - + this.entrySize + " OFF " - + this.entryOffset + " skipping " - + numToSkip + " bytes"); - } - - if (numToSkip > 0) { - this.skip(numToSkip); - } - - this.readBuf = null; - } - - byte[] headerBuf = this.buffer.readRecord(); - - if (headerBuf == null) { - if (this.debug) { - System.err.println("READ NULL RECORD"); - } - this.hasHitEOF = true; - } else if (this.buffer.isEOFRecord(headerBuf)) { - if (this.debug) { - System.err.println("READ EOF RECORD"); - } - this.hasHitEOF = true; - } - - if (this.hasHitEOF) { - this.currEntry = null; - } else { - this.currEntry = new TarEntry(headerBuf); - - if (!(headerBuf[257] == 'u' && headerBuf[258] == 's' - && headerBuf[259] == 't' && headerBuf[260] == 'a' - && headerBuf[261] == 'r')) { - this.entrySize = 0; - this.entryOffset = 0; - this.currEntry = null; - - throw new IOException("bad header in block " - + this.buffer.getCurrentBlockNum() - + " record " - + this.buffer.getCurrentRecordNum() - + ", " + - "header magic is not 'ustar', but '" - + headerBuf[257] - + headerBuf[258] - + headerBuf[259] - + headerBuf[260] - + headerBuf[261] - + "', or (dec) " - + ((int) headerBuf[257]) - + ", " - + ((int) headerBuf[258]) - + ", " - + ((int) headerBuf[259]) - + ", " - + ((int) headerBuf[260]) - + ", " - + ((int) headerBuf[261])); - } - - if (this.debug) { - System.err.println("TarInputStream: SET CURRENTRY '" - + this.currEntry.getName() - + "' size = " - + this.currEntry.getSize()); - } - - this.entryOffset = 0; - - // REVIEW How do we resolve this discrepancy?! - this.entrySize = (int) this.currEntry.getSize(); - } - - return this.currEntry; - } - - /** - * Reads a byte from the current tar archive entry. - * - * This method simply calls read( byte[], int, int ). - * - * @return The byte read, or -1 at EOF. - */ - public int read() throws IOException { - int num = this.read(this.oneBuf, 0, 1); - - if (num == -1) { - return num; - } else { - return (int) this.oneBuf[0]; - } - } - - /** - * Reads bytes from the current tar archive entry. - * - * This method simply calls read( byte[], int, int ). - * - * @param buf The buffer into which to place bytes read. - * @return The number of bytes read, or -1 at EOF. - */ - public int read(byte[] buf) throws IOException { - return this.read(buf, 0, buf.length); - } - - /** - * Reads bytes from the current tar archive entry. - * - * This method is aware of the boundaries of the current - * entry in the archive and will deal with them as if they - * were this stream's start and EOF. - * - * @param buf The buffer into which to place bytes read. - * @param offset The offset at which to place bytes read. - * @param numToRead The number of bytes to read. - * @return The number of bytes read, or -1 at EOF. - */ - public int read(byte[] buf, int offset, int numToRead) throws IOException { - int totalRead = 0; - - if (this.entryOffset >= this.entrySize) { - return -1; - } - - if ((numToRead + this.entryOffset) > this.entrySize) { - numToRead = (this.entrySize - this.entryOffset); - } - - if (this.readBuf != null) { - int sz = (numToRead > this.readBuf.length) ? this.readBuf.length - : numToRead; - - System.arraycopy(this.readBuf, 0, buf, offset, sz); - - if (sz >= this.readBuf.length) { - this.readBuf = null; - } else { - int newLen = this.readBuf.length - sz; - byte[] newBuf = new byte[newLen]; - - System.arraycopy(this.readBuf, sz, newBuf, 0, newLen); - - this.readBuf = newBuf; - } - - totalRead += sz; - numToRead -= sz; - offset += sz; - } - - while (numToRead > 0) { - byte[] rec = this.buffer.readRecord(); - - if (rec == null) { - // Unexpected EOF! - throw new IOException("unexpected EOF with " + numToRead - + " bytes unread"); - } - - int sz = numToRead; - int recLen = rec.length; - - if (recLen > sz) { - System.arraycopy(rec, 0, buf, offset, sz); - - this.readBuf = new byte[recLen - sz]; - - System.arraycopy(rec, sz, this.readBuf, 0, recLen - sz); - } else { - sz = recLen; - - System.arraycopy(rec, 0, buf, offset, recLen); - } - - totalRead += sz; - numToRead -= sz; - offset += sz; - } - - this.entryOffset += totalRead; - - return totalRead; - } - - /** - * Copies the contents of the current tar archive entry directly into - * an output stream. - * - * @param out The OutputStream into which to write the entry's data. - */ - public void copyEntryContents(OutputStream out) throws IOException { - byte[] buf = new byte[32 * 1024]; - - while (true) { - int numRead = this.read(buf, 0, buf.length); - - if (numRead == -1) { - break; - } - - out.write(buf, 0, numRead); - } - } -} diff --git a/src/main/org/apache/tools/tar/TarOutputStream.java b/src/main/org/apache/tools/tar/TarOutputStream.java deleted file mode 100644 index c8e1e52f6..000000000 --- a/src/main/org/apache/tools/tar/TarOutputStream.java +++ /dev/null @@ -1,314 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 - * . - */ - -/* - * This package is based on the work done by Timothy Gerard Endres - * (time@ice.com) to whom the Ant project is very grateful for his great code. - */ - -package org.apache.tools.tar; - -import java.io.*; - -/** - * The TarOutputStream writes a UNIX tar archive as an OutputStream. - * Methods are provided to put entries, and then write their contents - * by writing to this stream using write(). - * - * @author Timothy Gerard Endres time@ice.com - */ -public class TarOutputStream extends FilterOutputStream { - protected boolean debug; - protected int currSize; - protected int currBytes; - protected byte[] oneBuf; - protected byte[] recordBuf; - protected int assemLen; - protected byte[] assemBuf; - protected TarBuffer buffer; - - public TarOutputStream(OutputStream os) { - this(os, TarBuffer.DEFAULT_BLKSIZE, TarBuffer.DEFAULT_RCDSIZE); - } - - public TarOutputStream(OutputStream os, int blockSize) { - this(os, blockSize, TarBuffer.DEFAULT_RCDSIZE); - } - - public TarOutputStream(OutputStream os, int blockSize, int recordSize) { - super(os); - - this.buffer = new TarBuffer(os, blockSize, recordSize); - this.debug = false; - this.assemLen = 0; - this.assemBuf = new byte[recordSize]; - this.recordBuf = new byte[recordSize]; - this.oneBuf = new byte[1]; - } - - /** - * Sets the debugging flag. - * - * @param debugF True to turn on debugging. - */ - public void setDebug(boolean debugF) { - this.debug = debugF; - } - - /** - * Sets the debugging flag in this stream's TarBuffer. - * - * @param debugF True to turn on debugging. - */ - public void setBufferDebug(boolean debug) { - this.buffer.setDebug(debug); - } - - /** - * Ends the TAR archive without closing the underlying OutputStream. - * The result is that the EOF record of nulls is written. - */ - public void finish() throws IOException { - this.writeEOFRecord(); - } - - /** - * Ends the TAR archive and closes the underlying OutputStream. - * This means that finish() is called followed by calling the - * TarBuffer's close(). - */ - public void close() throws IOException { - this.finish(); - this.buffer.close(); - } - - /** - * Get the record size being used by this stream's TarBuffer. - * - * @return The TarBuffer record size. - */ - public int getRecordSize() { - return this.buffer.getRecordSize(); - } - - /** - * Put an entry on the output stream. This writes the entry's - * header record and positions the output stream for writing - * the contents of the entry. Once this method is called, the - * stream is ready for calls to write() to write the entry's - * contents. Once the contents are written, closeEntry() - * MUST be called to ensure that all buffered data - * is completely written to the output stream. - * - * @param entry The TarEntry to be written to the archive. - */ - public void putNextEntry(TarEntry entry) throws IOException { - entry.writeEntryHeader(this.recordBuf); - this.buffer.writeRecord(this.recordBuf); - - this.currBytes = 0; - - if (entry.isDirectory()) { - this.currSize = 0; - } else { - this.currSize = (int) entry.getSize(); - } - } - - /** - * Close an entry. This method MUST be called for all file - * entries that contain data. The reason is that we must - * buffer data written to the stream in order to satisfy - * the buffer's record based writes. Thus, there may be - * data fragments still being assembled that must be written - * to the output stream before this entry is closed and the - * next entry written. - */ - public void closeEntry() throws IOException { - if (this.assemLen > 0) { - for (int i = this.assemLen; i < this.assemBuf.length; ++i) { - this.assemBuf[i] = 0; - } - - this.buffer.writeRecord(this.assemBuf); - - this.currBytes += this.assemLen; - this.assemLen = 0; - } - - if (this.currBytes < this.currSize) { - throw new IOException("entry closed at '" + this.currBytes - + "' before the '" + this.currSize - + "' bytes specified in the header were written"); - } - } - - /** - * Writes a byte to the current tar archive entry. - * - * This method simply calls read( byte[], int, int ). - * - * @param b The byte written. - */ - public void write(int b) throws IOException { - this.oneBuf[0] = (byte) b; - - this.write(this.oneBuf, 0, 1); - } - - /** - * Writes bytes to the current tar archive entry. - * - * This method simply calls read( byte[], int, int ). - * - * @param wBuf The buffer to write to the archive. - * @return The number of bytes read, or -1 at EOF. - */ - public void write(byte[] wBuf) throws IOException { - this.write(wBuf, 0, wBuf.length); - } - - /** - * Writes bytes to the current tar archive entry. This method - * is aware of the current entry and will throw an exception if - * you attempt to write bytes past the length specified for the - * current entry. The method is also (painfully) aware of the - * record buffering required by TarBuffer, and manages buffers - * that are not a multiple of recordsize in length, including - * assembling records from small buffers. - * - * This method simply calls read( byte[], int, int ). - * - * @param wBuf The buffer to write to the archive. - * @param wOffset The offset in the buffer from which to get bytes. - * @param numToWrite The number of bytes to write. - */ - public void write(byte[] wBuf, int wOffset, int numToWrite) throws IOException { - if ((this.currBytes + numToWrite) > this.currSize) { - throw new IOException("request to write '" + numToWrite - + "' bytes exceeds size in header of '" - + this.currSize + "' bytes"); - - // - // We have to deal with assembly!!! - // The programmer can be writing little 32 byte chunks for all - // we know, and we must assemble complete records for writing. - // REVIEW Maybe this should be in TarBuffer? Could that help to - // eliminate some of the buffer copying. - // - } - - if (this.assemLen > 0) { - if ((this.assemLen + numToWrite) >= this.recordBuf.length) { - int aLen = this.recordBuf.length - this.assemLen; - - System.arraycopy(this.assemBuf, 0, this.recordBuf, 0, - this.assemLen); - System.arraycopy(wBuf, wOffset, this.recordBuf, - this.assemLen, aLen); - this.buffer.writeRecord(this.recordBuf); - - this.currBytes += this.recordBuf.length; - wOffset += aLen; - numToWrite -= aLen; - this.assemLen = 0; - } else { - System.arraycopy(wBuf, wOffset, this.assemBuf, this.assemLen, - numToWrite); - - wOffset += numToWrite; - this.assemLen += numToWrite; - numToWrite -= numToWrite; - } - } - - // - // When we get here we have EITHER: - // o An empty "assemble" buffer. - // o No bytes to write (numToWrite == 0) - // - while (numToWrite > 0) { - if (numToWrite < this.recordBuf.length) { - System.arraycopy(wBuf, wOffset, this.assemBuf, this.assemLen, - numToWrite); - - this.assemLen += numToWrite; - - break; - } - - this.buffer.writeRecord(wBuf, wOffset); - - int num = this.recordBuf.length; - - this.currBytes += num; - numToWrite -= num; - wOffset += num; - } - } - - /** - * Write an EOF (end of archive) record to the tar archive. - * An EOF record consists of a record of all zeros. - */ - private void writeEOFRecord() throws IOException { - for (int i = 0; i < this.recordBuf.length; ++i) { - this.recordBuf[i] = 0; - } - - this.buffer.writeRecord(this.recordBuf); - } -} - - diff --git a/src/main/org/apache/tools/tar/TarUtils.java b/src/main/org/apache/tools/tar/TarUtils.java deleted file mode 100644 index 71ff31129..000000000 --- a/src/main/org/apache/tools/tar/TarUtils.java +++ /dev/null @@ -1,234 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999 The Apache Software Foundation. All rights - * 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. - * - * 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: - * "This product includes software developed by the - * 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 - * 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. - * ==================================================================== - * - * 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 - * . - */ - -/* - * This package is based on the work done by Timothy Gerard Endres - * (time@ice.com) to whom the Ant project is very grateful for his great code. - */ - -package org.apache.tools.tar; - -/** - * This class provides static utility methods to work with byte streams. - * - * @author Timothy Gerard Endres time@ice.com - * @author Stefano Mazzocchi stefano@apache.org - */ -public class TarUtils { - - /** - * Parse an octal string from a header buffer. This is used for the - * file permission mode value. - * - * @param header The header buffer from which to parse. - * @param offset The offset into the buffer from which to parse. - * @param length The number of header bytes to parse. - * @return The long value of the octal string. - */ - public static long parseOctal(byte[] header, int offset, int length) { - long result = 0; - boolean stillPadding = true; - int end = offset + length; - - for (int i = offset; i < end; ++i) { - if (header[i] == 0) { - break; - } - - if (header[i] == (byte) ' ' || header[i] == '0') { - if (stillPadding) { - continue; - } - - if (header[i] == (byte) ' ') { - break; - } - } - - stillPadding = false; - result = (result << 3) + (header[i] - '0'); - } - - return result; - } - - /** - * Parse an entry name from a header buffer. - * - * @param header The header buffer from which to parse. - * @param offset The offset into the buffer from which to parse. - * @param length The number of header bytes to parse. - * @return The header's entry name. - */ - public static StringBuffer parseName(byte[] header, int offset, int length) { - StringBuffer result = new StringBuffer(length); - int end = offset + length; - - for (int i = offset; i < end; ++i) { - if (header[i] == 0) { - break; - } - - result.append((char) header[i]); - } - - return result; - } - - /** - * Determine the number of bytes in an entry name. - * - * @param header The header buffer from which to parse. - * @param offset The offset into the buffer from which to parse. - * @param length The number of header bytes to parse. - * @return The number of bytes in a header's entry name. - */ - public static int getNameBytes(StringBuffer name, byte[] buf, int offset, int length) { - int i; - - for (i = 0; i < length && i < name.length(); ++i) { - buf[offset + i] = (byte) name.charAt(i); - } - - for (; i < length; ++i) { - buf[offset + i] = 0; - } - - return offset + length; - } - - /** - * Parse an octal integer from a header buffer. - * - * @param header The header buffer from which to parse. - * @param offset The offset into the buffer from which to parse. - * @param length The number of header bytes to parse. - * @return The integer value of the octal bytes. - */ - public static int getOctalBytes(long value, byte[] buf, int offset, int length) { - byte[] result = new byte[length]; - int idx = length - 1; - - buf[offset + idx] = 0; - --idx; - buf[offset + idx] = (byte) ' '; - --idx; - - if (value == 0) { - buf[offset + idx] = (byte) '0'; - --idx; - } else { - for (long val = value; idx >= 0 && val > 0; --idx) { - buf[offset + idx] = (byte) ((byte) '0' + (byte) (val & 7)); - val = val >> 3; - } - } - - for (; idx >= 0; --idx) { - buf[offset + idx] = (byte) ' '; - } - - return offset + length; - } - - /** - * Parse an octal long integer from a header buffer. - * - * @param header The header buffer from which to parse. - * @param offset The offset into the buffer from which to parse. - * @param length The number of header bytes to parse. - * @return The long value of the octal bytes. - */ - public static int getLongOctalBytes(long value, byte[] buf, int offset, int length) { - byte[] temp = new byte[length + 1]; - - getOctalBytes(value, temp, 0, length + 1); - System.arraycopy(temp, 0, buf, offset, length); - - return offset + length; - } - - /** - * Parse the checksum octal integer from a header buffer. - * - * @param header The header buffer from which to parse. - * @param offset The offset into the buffer from which to parse. - * @param length The number of header bytes to parse. - * @return The integer value of the entry's checksum. - */ - public static int getCheckSumOctalBytes(long value, byte[] buf, int offset, int length) { - getOctalBytes(value, buf, offset, length); - - buf[offset + length - 1] = (byte) ' '; - buf[offset + length - 2] = 0; - - return offset + length; - } - - /** - * Compute the checksum of a tar entry header. - * - * @param buf The tar entry's header buffer. - * @return The computed checksum. - */ - public static long computeCheckSum(byte[] buf) { - long sum = 0; - - for (int i = 0; i < buf.length; ++i) { - sum += 255 & buf[i]; - } - - return sum; - } -} -- cgit v1.2.1