diff options
author | No Author <dev-null@apache.org> | 2000-06-30 22:39:45 +0000 |
---|---|---|
committer | No Author <dev-null@apache.org> | 2000-06-30 22:39:45 +0000 |
commit | f0855dc2ad63dc096b1526c258ee77360a9f27ca (patch) | |
tree | 9ce99ea8746d8a055a7920fa18db3126bdb0d8ad | |
parent | b21634835a8db02403c02bbae6f6c65218ae8754 (diff) | |
download | ant-tomcat_32.tar.gz |
This commit was manufactured by cvs2svn to create branch 'tomcat_32'.tomcat_32
git-svn-id: https://svn.apache.org/repos/asf/ant/core/branches/tomcat_32@267721 13f79535-47bb-0310-9956-ffa450edef68
90 files changed, 0 insertions, 19412 deletions
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 <http://www.apache.org/>. - * - */ 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 <http://jakarta.apache.org/>. - - - 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 - <http://jakarta.apache.org/> @@ -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 @@ -<?xml version="1.0"?> - -<!-- ======================================================================= --> -<!-- Ant own build file --> -<!-- ======================================================================= --> - -<project name="Ant" default="main" basedir="."> - - <property name="Name" value="Ant"/> - <property name="name" value="ant"/> - <property name="version" value="1.0-rc1"/> - - <property name="ant.home" value="."/> - <property name="bin.dir" value="bin"/> - <property name="src.bin.dir" value="src/bin"/> - <property name="src.dir" value="src/main"/> - <property name="lib.dir" value="lib"/> - <property name="docs.dir" value="docs"/> - <property name="build.dir" value="../build/ant"/> - <property name="build.classes" value="${build.dir}/classes"/> - <property name="build.javadocs" value="${build.dir}/javadocs"/> - <property name="ant.dist.dir" value="../dist/ant"/> - - <property name="classpath" value=""/> - <property name="packages" value="org.apache.tools.*,com.oreilly.servlet.*"/> - <property name="manifest" value="src/etc/manifest"/> - - <property name="build.compiler" value="classic"/> - - <!-- Give user a chance to override without editing this file - (and without typing -D each time it compiles it --> - <property file="${user.home}/.ant.properties" /> - - <!-- =================================================================== --> - <!-- Check to see what optional dependencies are available --> - <!-- =================================================================== --> - <target name="check_for_optional_packages"> - <available property="bsf.present" classname="com.ibm.bsf.BSFManager" /> - <available property="netrexx.present" classname="netrexx.lang.Rexx" /> - <available property="xslp.present" - classname="com.kvisco.xsl.XSLProcessor" /> - <available property="xalan.present" - classname="org.apache.xalan.xslt.XSLTProcessorFactory" /> - </target> - - <!-- =================================================================== --> - <!-- Prepares the build directory --> - <!-- =================================================================== --> - <target name="prepare"> - <mkdir dir="${build.dir}"/> - <tstamp /> - </target> - - <!-- =================================================================== --> - <!-- Compiles the source code --> - <!-- =================================================================== --> - <target name="compile" depends="prepare,check_for_optional_packages"> - <mkdir dir="${build.classes}"/> - - <javac srcdir="${src.dir}" - destdir="${build.classes}" - classpath="${classpath}" - debug="on" - deprecation="off" - optimize="on" > - <include name="**/*.java"/> - <exclude name="**/Script.java" unless="bsf.present" /> - <exclude name="**/NetRexxC.java" unless="netrexx.present" /> - <exclude name="**/XslpLiaison.java" unless="xslp.present" /> - <exclude name="**/XalanLiaison.java" unless="xalan.present" /> - <exclude name="**/version.txt" /> - </javac> - - <copydir src="${src.dir}" dest="${build.classes}"> - <include name="**/defaultManifest.mf" /> - <include name="**/*.properties" /> - </copydir> - - <filter token="VERSION" value="${version}" /> - <filter token="DATE" value="${TODAY}" /> - <filter token="TIME" value="${TSTAMP}" /> - <copydir src="${src.dir}" - dest="${build.classes}" - filtering="on" - forceoverwrite="true"> - <include name="**/version.txt" /> - </copydir> - </target> - - <!-- =================================================================== --> - <!-- Creates the jar archive --> - <!-- =================================================================== --> - <target name="jar" depends="compile"> - <mkdir dir="${lib.dir}"/> - <jar jarfile="${lib.dir}/${name}.jar" - basedir="${build.classes}" - includes="org/**,com/**" - manifest="${manifest}" - /> - </target> - - <!-- =================================================================== --> - <!-- Creates the binary structure --> - <!-- =================================================================== --> - <target name="main" depends="jar"> - <mkdir dir="${bin.dir}"/> - <copydir src="${src.bin.dir}" dest="${bin.dir}"/> - <chmod perm="+x" src="${bin.dir}/ant"/> - <chmod perm="+x" src="${bin.dir}/antRun"/> - <fixcrlf srcdir="${bin.dir}" includes="ant,antRun" cr="remove"/> - <fixcrlf srcdir="${bin.dir}" includes="*.bat" cr="add"/> - </target> - - <!-- =================================================================== --> - <!-- Creates the API documentation --> - <!-- =================================================================== --> - <target name="javadocs" depends="prepare"> - <mkdir dir="${build.javadocs}"/> - <javadoc packagenames="${packages}" - sourcepath="${basedir}/${src.dir}" - destdir="${build.javadocs}" - author="true" - version="true" - windowtitle="${Name} API" - doctitle="${Name}" - bottom="Copyright © 2000 Apache Software Foundation. All Rights Reserved." - /> - </target> - - <!-- =================================================================== --> - <!-- Creates the distribution --> - <!-- =================================================================== --> - <target name="dist" depends="main,jar,javadocs"> - <mkdir dir="${ant.dist.dir}"/> - <mkdir dir="${ant.dist.dir}/bin"/> - <mkdir dir="${ant.dist.dir}/lib"/> - <mkdir dir="${ant.dist.dir}/docs"/> - <mkdir dir="${ant.dist.dir}/docs/api"/> - <mkdir dir="${ant.dist.dir}/src"/> - - <copydir src="${src.dir}" dest="${ant.dist.dir}/src"/> - <copydir src="${lib.dir}" dest="${ant.dist.dir}/lib"/> - - <copyfile src="build.xml" dest="${ant.dist.dir}/lib/build.xml"/> - <copydir src="src/bin" dest="${ant.dist.dir}/bin"/> - <copydir src="${docs.dir}" dest="${ant.dist.dir}/docs"/> - <copydir src="${build.javadocs}" dest="${ant.dist.dir}/docs/api"/> - - <chmod perm="+x" src="${ant.dist.dir}/bin/ant"/> - <chmod perm="+x" src="${ant.dist.dir}/bin/antRun"/> - - <copyfile src="README" dest="${ant.dist.dir}/README"/> - <copyfile src="TODO" dest="${ant.dist.dir}/TODO"/> - <copyfile src="LICENSE" dest="${ant.dist.dir}/LICENSE"/> - </target> - - <!-- =================================================================== --> - <!-- Packages the distribution with ZIP --> - <!-- =================================================================== --> - <target name="dist-zip" depends="dist"> - <zip zipfile="${Name}-${version}.zip" basedir="${ant.dist.dir}" includes="**"/> - </target> - - <!-- =================================================================== --> - <!-- Packages the distribution with TAR-GZIP --> - <!-- =================================================================== --> - <target name="dist-tgz" depends="dist"> - <tar tarfile="${Name}-${version}.tar" basedir="${ant.dist.dir}" includes="**"/> - <gzip zipfile="${Name}-${version}.tar.gz" src="${Name}-${version}.tar"/> - </target> - - <!-- =================================================================== --> - <!-- Cleans up generated stuff --> - <!-- =================================================================== --> - <target name="clean"> - <deltree dir="${build.dir}"/> - <deltree dir="${ant.dist.dir}"/> - </target> - - <!-- =================================================================== --> - <!-- Total cleanup --> - <!-- =================================================================== --> - <target name="total-clean" depends="clean"> - <deltree dir="${bin.dir}"/> - <delete file="${lib.dir}/${name}.jar"/> - <delete file="${Name}-${version}.zip"/> - <delete file="${Name}-${version}.tar"/> - <delete file="${Name}-${version}.tar.gz"/> - </target> - - <!-- in progress ! (may not work) --> - - <target name="get.snapshot"> - <get src="http://jakarta.apache.org/build/tmp/ant/ant.src.zip" dest="ant-src.zip" /> - <expand src="ant-src.zip" dest="." /> - </target> - - <target name="make.snapshot"> - <cvs cvsRoot=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic" - package="jakarta-ant" - dest="." /> - <zip zipfile="/www/jakarta.apache.org/builds/tmp/ant/ant.src.zip" basedir="." includes="jakarta-ant/**"/> - </target> - -</project> - 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 @@ -<project name="Ant Nightly Distribution" default="all" basedir="."> - - <!-- Build Management Properties - - buildAnt.archive Distribution directory to be archived - buildAnt.cvsRoot CVS login root for Ant - buildAnt.dateStamp YYYYMMDD date stamp (from executing script) - buildAnt.dist Distribution directory produced by "build" target - buildAnt.name Base name of packaged distribution files - buildAnt.package CVS package name for Ant - buildAnt.server Jakarta server's nightly builds directory - buildAnt.source Directory into which Ant sources are extracted - buildAnt.uploads Directory into which archives to upload are made - jaxp.home Home directory of the JAXP distribution - - --> - - <property name="buildAnt.archive" value="archive/jakarta-ant"/> - <property name="buildAnt.cvsRoot" value=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic"/> - <property name="buildAnt.dist" value="dist/ant"/> - <property name="buildAnt.name" value="jakarta-ant"/> - <property name="buildAnt.package" value="jakarta-ant"/> - <property name="buildAnt.server" value="/www/jakarta.apache.org/builds/ant/nightly"/> - <property name="buildAnt.source" value="jakarta-ant"/> - <property name="buildAnt.uploads" value="uploads/ant"/> - - <!-- Extract the most recent sources from the CVS repository --> - <target name="extract"> - <deltree dir="${buildAnt.source}"/> - <cvs cvsRoot="${buildAnt.cvsRoot}" package="${buildAnt.package}" - dest="${buildAnt.source}"/> - </target> - - <!-- Build the distribution according to its instructions --> - <target name="build"> - <ant dir="${buildAnt.source}" target="clean"/> - <ant dir="${buildAnt.source}" target="dist"/> - </target> - - <!-- Insert add-ons as required for the nightly distribution --> - <target name="addons"> - <echo message="Copying addons from '${jaxp.home}' to '${buildAnt.dist}/lib'"/> - <copyfile src="${jaxp.home}/jaxp.jar" - dest="${buildAnt.dist}/lib/jaxp.jar"/> - <copyfile src="${jaxp.home}/parser.jar" - dest="${buildAnt.dist}/lib/parser.jar"/> - </target> - - <!-- Package up the distribution in various formats --> - <target name="package"> - <!-- Recreate the archive directory --> - <deltree dir="${buildAnt.archive}"/> - <mkdir dir="${buildAnt.archive}"/> - <copydir src="${buildAnt.dist}" dest="${buildAnt.archive}"/> - <!-- Recreate the uploads directory --> - <deltree dir="${buildAnt.uploads}"/> - <mkdir dir="${buildAnt.uploads}"/> - <!-- Create the uploadable files in various formats --> - <tstamp/> - <tar tarfile="${buildAnt.uploads}/${buildAnt.name}-${DSTAMP}.tar" - basedir="${buildAnt.archive}/.."/> - <gzip src="${buildAnt.uploads}/${buildAnt.name}-${DSTAMP}.tar" - zipfile="${buildAnt.uploads}/${buildAnt.name}-${DSTAMP}.tar.gz"/> - <exec dir="${buildAnt.uploads}" - command="compress ${buildAnt.name}-${DSTAMP}.tar"/> - <zip zipfile="${buildAnt.uploads}/${buildAnt.name}-${DSTAMP}.zip" - basedir="${buildAnt.archive}/.."/> - </target> - - <!-- Install the distributable files to the Jakarta server --> - <!-- Obviously, this will only work right on the real server!!! --> - <target name="install"> - <copydir src="${buildAnt.uploads}" dest="${buildAnt.server}" - includes="${buildAnt.name}-${DSTAMP}.*"/> - <chmod src="${buildAnt.server}/${buildAnt.name}-${DSTAMP}.*" - perm="g+w"/> - <chmod src="${buildAnt.server}/${buildAnt.name}-${DSTAMP}.*" - perm="o+r"/> - </target> - - <!-- All-in-one target (except for install) --> - <target name="all" depends="extract,build,addons,package"/> - -</project> 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 @@ -<html> - -<head> -<meta http-equiv="Content-Language" content="en-us"> -<title>Ant</title> -</head> - -<body> - -<h1>Ant User Manual</h1> -<p>by</p> -<!-- Names are in alphabetical order, on last name --> -<ul> - <li>Jacques Bergeron (<a href="mailto:jacques.bergeron@dogico.com">jacques.bergeron@dogico.com</a>)</li> - <li>Stefan Bodewig (<a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a>)</li> - <li>Patrick Chanezon (<a href="mailto:chanezon@netscape.com">chanezon@netscape.com</a>)</li> - <li>James Duncan Davison (<a href="mailto:duncan@x180.com">duncan@x180.com</a>)</li> - <li>Tom Dimock (<a href="mailto:tad1@cornell.edu">tad1@cornell.edu</a>)</li> - <li>Bill Kelly (<a href="mailto:bill.kelly@softwired-inc.com">bill.kelly@softwired-inc.com</a>)</li> - <li>Arnout J. Kuiper (<a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a>)</li> - <li>Conor MacNeill (<a href="mailto:conor@cortexebusiness.com.au">conor@cortexebusiness.com.au</a>)</li> - <li>Stefano Mazzocchi (<a href="mailto:stefano@apache.org">stefano@apache.org</a>)</li> - <li>Sam Ruby (<a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a>)</li> -</ul> - -<p>Version 1.0.8.1 - 2000/06/28</p> - -<hr> -<h2>Table of Contents</h2> -<ul> - <li><a href="#introduction">Introduction</a></li> - <li><a href="#getting">Getting Ant</a></li> - <li><a href="#sysrequirements">System Requirements</a></li> - <li><a href="#buildingant">Building Ant</a></li> - <li><a href="#installing">Installing Ant</a></li> - <li><a href="#running">Running Ant</a></li> - <li><a href="#buildfile">Writing a simple buildfile</a> - <li><a href="#directorybasedtasks">Directory based tasks</a></li> - <li><a href="#tasks">Built in Tasks</a> - <li><a href="#optionaltasks">Optional Tasks</a> - <li><a href="#buildevents">Build Events</a> - <li><a href="#writingowntask">Writing your own task</a></li> - <li><a href="#license">License</a></li> - <li><a href="#feedback">Feedback</a></li> -</ul> - -<hr> -<h2><a name="introduction">Introduction</a></h2> -<p>Ant is a Java based build tool. In theory it is kind of like make without -make's wrinkles.</p> -<h3>Why?</h3> -<p>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.</p> -<p>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.</p> -<p>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.</p> -<p>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.</p> - -<hr> -<h2><a name="getting">Getting Ant</a></h2> -<h3>Binary edition</h3> -<p>The latest stable version of Ant can be downloaded from <a -href="http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip">http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip</a>. -If you like living on the edge, you can download the latest version from <a -href="http://jakarta.apache.org/builds/tomcat/nightly/ant.zip">http://jakarta.apache.org/builds/tomcat/nightly/ant.zip</a>.</p> -<h3>Source edition</h3> -<p>If you prefer the source edition, you can download Ant from <a -href="http://jakarta.apache.org/builds/tomcat/release/v3.0/src/jakarta-tools.src.zip">http://jakarta.apache.org/builds/tomcat/release/v3.0/src/jakarta-tools.src.zip</a> -(latest stable) or from <a -href="http://jakarta.apache.org/from-cvs/jakarta-tools/">http://jakarta.apache.org/from-cvs/jakarta-ant/</a> -(current). See the section <a href="#buildingant">Building Ant</a> on how to -build Ant from the source code.</p> - -<hr> -<h2><a name="sysrequirements">System Requirements</a></h2> -<p> - To build and use ant you must have a JAXP compilant XML parser installed and available on your classpath. - <p> - If you do not have a JAXP compliant XML parse installed, you may use the reference implementation - available from Sun. It is available from <a href="http://java.sun.com/xml">http://java.sun.com/xml</a>. - Once installed make sure the "jaxp.jar" and "parser.jar" files are in your classpath. - <p> - You will also need the JDK installed on your system, version 1.1 or later. - -<hr> -<h2><a name="buildingant">Building Ant</a></h2> -<p>Go to the directory <code>jakarta-ant</code>.</p> -<p>Make sure the JDK is in you path.</p> -<p>Run <code>bootstrap.bat</code> (Windows) or <code>bootstrap.sh</code> (UNIX) -to build a bootstrap version of Ant.</p> -<p>When finished, use</p> -<blockquote> - <p><code>build.bat -Dant.dist.dir=<directory to install Ant> dist</code></p> -</blockquote> -<p>for Windows, and</p> -<blockquote> - <p><code>build.sh -Dant.dist.dir=<directory to install Ant> dist</code></p> -</blockquote> -<p>for UNIX, to create a binary distribution of Ant. This distribution can be -found in the directory you specified.</p> -<hr> -<h2><a name="installing">Installing Ant</a></h2> -<p>The binary distribution of Ant consists of three directories: <code>bin</code>, -<code>docs</code> and <code>lib</code>. Only the <code>bin</code> and <code>lib</code> -directory are crucial for running Ant. To run Ant, the following must be done:</p> -<ul> - <li>Add the <code>bin</code> directory to your path.</li> - <li>Set the ANT_HOME environment variable. This should be set to the directory - which contains the <code>bin</code> and <code>lib</code> directory.</li> - <li>Set the JAVA_HOME environment variable. This should be set to the - directory where the JDK is installed.</li> -</ul> -<h3>Windows</h3> -<p>Assume Ant is installed in <code>c:\ant\</code>. The following sets up the -environment:</p> -<pre>set ANT_HOME=c:\ant -set JAVA_HOME=c:\jdk1.2.2 -set PATH=%PATH%;%ANT_HOME%\bin</pre> -<h3>Unix (bash)</h3> -<p>Assume Ant is installed in <code>/usr/local/ant</code>. The following sets up -the environment:</p> -<pre>export ANT_HOME=/usr/local/ant -export JAVA_HOME=/usr/local/jdk-1.2.2 -export PATH=${PATH}:${ANT_HOME}/bin</pre> -<h3>Advanced</h3> -<p>There are lots of variants that can be used to run Ant. What you need is at -least the following:</p> -<p>The classpath for Ant must contain <code>ant.jar</code> and any jars/classes -needed for your chosen JAXP compliant XML parser.</p> -<p>When you need JDK functionality (like a <a href="#javac">javac</a> task, or a -<a href="#rmic">rmic</a> task), then for JDK 1.1, the <code>classes.zip</code> -file of the JDK must be added to the classpath; for JDK 1.2, <code>tools.jar</code> -must be added. The scripts supplied with ant, in the bin directory, will add -<code>tools.jar</code> automatically if the JAVA_HOME environment variable is set.</p> -<p>When you are executing platform specific applications (like the <a -href="#exec">exec</a> task, or the <a href="#cvs">cvs</a> task), the property <code>ant.home</code> -must be set to the directory containing a bin directory, which contains the <code>antRun</code> shell script necessary to run execs on Unix.</p> -<hr> -<h2><a name="running">Running Ant</a></h2> -<p>Running Ant is simple, when you installed it as described in the previous -section. Just type <code>ant</code>.</p> -<p>When nothing is specified, Ant looks for a <code>build.xml</code> file in the -current directory. When found, it uses that file as a buildfile. To make Ant use -another buildfile, use the commandline option <i>-buildfile <file></i>, -where <i><file></i> is the buildfile you want to use.</p> -<p>You can also set properties which override properties specified in the -buildfile (see the <a href="#property">property task</a>). -This can be done with the <i>-D<property>=<value></i> -option, where <i><property></i> is the name of the property and <i><value></i> -the value.</p> -<p>To more options are <i>-quiet</i> which instructs Ant to print less -information on the console when running. The option <i>-verbose</i> on the other -hand makes Ant print more information on the console.</p> -<p>It is also possible to specify the target that should be executed. Default -the target that is mentioned in the <i>default</i> attribute of the project is -used. This can be overridden by adding the target name to the end of the -commandline.</p> -<p>Commandline option summary:</p> -<pre>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</pre> -<h3>Examples</h3> -<blockquote> - <pre>ant</pre> -</blockquote> -<p>runs Ant using the <code>build.xml</code> file in the current directory, on -the default target.</p> -<blockquote> - <pre>ant -buildfile test.xml</pre> -</blockquote> -<p>runs Ant using the <code>test.xml</code> file in the current directory, on -the default target.</p> -<blockquote> - <pre>ant -buildfile test.xml dist</pre> -</blockquote> -<p>runs Ant using the <code>test.xml</code> file in the current directory, on a -target called <code>dist</code>.</p> -<blockquote> - <pre>ant -buildfile test.xml -Dbuild=build/classes dist</pre> -</blockquote> -<p>runs Ant using the <code>test.xml</code> file in the current directory, on a -target called <code>dist</code>. It also sets the <i>build</i> property to the -value <i>build/classes</i>.</p> -<h3>Running Ant by hand</h3> -<p>When you have installed Ant in the do-it-yourself way, Ant can be started -with:</p> -<blockquote> - <pre>java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]</pre> -</blockquote> - -<p>These instructions actually do exactly the same as the <code>ant</code> -command. The options and target are the same as when running Ant with the <code>ant</code> -command. This example assumes you have set up your classpath to include -<ul> -<li>ant.jar -<li>jars/classes for your XML parser -<li>the JDK's tools.jar -</ul> -<hr> -<h2><a name="buildfile">Writing a simple buildfile</a></h2> -<p>The buildfile is written in XML. Each buildfile contains one project.</p> -<h3>Projects</h3> -<p>A project has three attributes:</p> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">name</td> - <td valign="top">the name of the project.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">default</td> - <td valign="top">the default target to use when no target is supplied.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">basedir</td> - <td valign="top">the 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.</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> -<p>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.</p> -<h3>Targets</h3> -<p>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.</p> -<p>Ant tries to execute the targets in the <i>depends</i> 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:</p> -<blockquote> -<pre><target name="A"/> -<target name="B" depends="A"/> -<target name="C" depends="B"/> -<target name="D" depends="C,B,A"/></pre> -</blockquote> -<p>Suppose we want to execute target D. From its <i>depends</i> 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.</p> -<p>A target gets executed only once. Even when more targets depend on it (see -the previous example).</p> -<p>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 <i>sense</i> this property you should add the <i>if</i> attribute -with the name of the property that the target should react to, for example</p> -<blockquote> - <pre><target name="build-module-A" if="module-A-present"/></pre> -</blockquote> -<p>If no <i>if</i> attribute is present, the target will always be executed.</p> -<p>It is a good practice to place your <a href="#property">property</a> and <a -href="#tstamp">tstamp</a> 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".</p> -<p>A target has the following attributes:</p> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">name</td> - <td valign="top">the name of the project.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">depends</td> - <td valign="top">a comma separated list of names of targets on which this - target depends.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">if</td> - <td valign="top">the name of the property that must be set in order for this - target to execute.</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Tasks</h3> -<p>A task is a piece of code that can be executed.</p> -<p>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.</p> -<p>Tasks have a common structure:</p> -<blockquote> - <pre><name attribute1="value1" attribute2="value2" ... /></pre> -</blockquote> -<p>where name is the name of the task, attribute-x the attribute name, and -value-x the value of this attribute.</p> -<p>There is a set of <a href="#tasks">built in tasks</a>, but it is also very -easy to <a href="#writingowntask">write your own</a>.</p> -<h3>Properties</h3> -<p>A project can have a set of properties. These might be set in the buildfile -by the <a href="#property">property task</a>, 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.</p> -<p>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".</p> -<h3>Token Filters</h3> -<p>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 <a href="#filter">filter task</a>. </p> -<p>Since this can be a very harmful behavior, the tokens in the files <b>must</b> -be of the form<i> @token@</i> where <i>token</i> 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.</p> -<p>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.</p> -<h3>Examples</h3> -<blockquote> - <pre><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> -</pre> -</blockquote> - -<hr> -<h2><a name="directorybasedtasks">Directory based tasks</a></h2> -<p>Some tasks use directory trees for the task they perform. For instance, the <a -href="#javac">Javac task</a> 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.</p> -<p>Ant gives you two ways to create a subset, both of which can be used at the same -time:</p> -<ul> - <li>Only include files/directories that match at least one pattern of a set of - patterns</li> - <li>Exclude files/directories that match at least one pattern a set of - patterns</li> -</ul> -<p>When both inclusion and exclusion are used, only files/directories that match -the include patterns, and don't match the exclude patterns are used.</p> -<p>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.</p> -<h3>Patterns</h3> -<p>As described earlier, patterns are used for the inclusion and exclusion. -These patterns look very much like the patterns used in DOS and UNIX:</p> -<p>'*' matches zero or more characters, '?' matches one character.</p> -<p>Examples:</p> -<p>'*.java' matches '.java', 'x.java' and 'FooBar.java', but not 'FooBar.xml' -(does not end with '.java').</p> -<p>'?.java' matches 'x.java', 'A.java', but not '.java' or 'xyz.java' (both -don't have one character before '.java').</p> -<p>Combinations of '*'s and '?'s are allowed.</p> -<p>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.</p> -<p>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'.</p> -<p>There is one "shorthand", if a pattern ends with '/' or '\', then '**' -is appended. E.g. "mypackage/test/" is interpreted as were it "mypackage/test/**".</p> -<p>Examples:</p> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top">**/CVS/*</td> - <td valign="top">Matches all files in CVS directories, that can be located - anywhere in the directory tree. - <p>Matches:</p> - <p>CVS/Repository<br> - org/apache/CVS/Entries<br> - org/apache/jakarta/tools/ant/CVS/Entries</p> - <p>But not:</p> - <p>org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match)</td> - </tr> - <tr> - <td valign="top">org/apache/jakarta/**</td> - <td valign="top">Matches all files in the org/apache/jakarta directory tree. - <p>Matches:</p> - <p>org/apache/jakarta/tools/ant/docs/index.html<br> - org/apache/jakarta/test.xml</p> - <p>But not:</p> - <p>org/apache/xyz.java ('jakarta'/' part is missing)</td> - </tr> - <tr> - <td valign="top">org/apache/**/CVS/*</td> - <td valign="top">Matches all files in CVS directories, that are located - anywhere in the directory tree under org/apache. - <p>Matches:</p> - <p>org/apache/CVS/Entries<br> - org/apache/jakarta/tools/ant/CVS/Entries</p> - <p>But not:</p> - <p>org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match)</td> - </tr> - <tr> - <td valign="top">**/test/**</td> - <td valign="top">Matches all files which have a directory 'test' in their - path, including 'test' as a filename.</td> - </tr> -</table> -<p>When these patterns are used in inclusion and exclusion, you have a powerful -way to select just the files you want.</p> -<h3>Examples</h3> -<pre> <copydir src="${src}" - dest="${dist}" - includes="**/images/*" - excludes="**/*.gif" /></pre> -<p>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.</p> -<p> This example can also be expressed using nested elements as -<pre> <copydir src="${src}" - dest="${dist}"> - <include name="**/images/*"/> - <exclude name="**/*.gif" /> - </copydir> -</pre> - -<h3>Default Excludes</h3> -<p>There are a set of definitions which are excluded by default from all directory based tasks. -They are: -<pre> "**/*~", - "**/#*#", - "**/%*%", - "**/CVS", - "**/CVS/*", - "**/.cvsignore" -</pre> -If you do not want these default excludes applied, you may disable them with the -<code>defaultexcludes="no"</code> attribute.</p> -<hr> -<h2><a name="tasks">Built in tasks</a></h2> -<ul> - <li><a href="#ant">Ant</a></li> - <li><a href="#available">Available</a></li> - <li><a href="#chmod">Chmod</a></li> - <li><a href="#copydir">Copydir</a></li> - <li><a href="#copyfile">Copyfile</a></li> - <li><a href="#cvs">Cvs</a></li> - <li><a href="#delete">Delete</a></li> - <li><a href="#deltree">Deltree</a></li> - <li><a href="#echo">Echo</a></li> - <li><a href="#exec">Exec</a></li> - <li><a href="#expand">Expand</a></li> - <li><a href="#filter">Filter</a></li> - <li><a href="#fixcrlf">FixCRLF</a></li> - <li><a href="#get">Get</a></li> - <li><a href="#gunzip">GUnzip</a></li> - <li><a href="#gzip">GZip</a></li> - <li><a href="#jar">Jar</a></li> - <li><a href="#java">Java</a></li> - <li><a href="#javac">Javac</a></li> - <li><a href="#javadoc">Javadoc/Javadoc2</a></li> - <li><a href="#keysubst">KeySubst</a></li> - <li><a href="#mkdir">Mkdir</a></li> - <li><a href="#patch">Patch</a></li> - <li><a href="#property">Property</a></li> - <li><a href="#rename">Rename</a></li> - <li><a href="#replace">Replace</a></li> - <li><a href="#rmic">Rmic</a></li> - <li><a href="#tar">Tar</a></li> - <li><a href="#taskdef">Taskdef</a></li> - <li><a href="#touch">Touch</a></li> - <li><a href="#tstamp">Tstamp</a></li> - <li><a href="#style">Style</a></li> - <li><a href="#untar">Untar</a></li> - <li><a href="#zip">Zip</a></li> -</ul> -<hr> -<h2><a name="ant">Ant</a></h2> -<h3><b>Description:</b></h3> -<p>Runs Ant on a supplied buildfile. This can be used to build subprojects.</p> -<p>When the <i>antfile</i> attribute is omitted, the file "build.xml" -in the supplied directory (<i>dir</i> attribute) is used.</p> -<p>If no target attribute is supplied, the default target of the new project is -used.</p> -<p>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 <a href="#property">properties task</a>).</p> -<h3>Parameters:</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">antfile</td> - <td valign="top">the buildfile to use.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">dir</td> - <td valign="top">the directory to use as a basedir for the new Ant project.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">target</td> - <td valign="top">the target of the new Ant project that should be executed.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">output</td> - <td valign="top">Filename to write the ant output to. - </td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><ant antfile="subproject/subbuild.xml" dir="subproject" - target="compile" /></code></p> - <p><code><ant dir="subproject" /></code></p> -</blockquote> -<hr> -<h2><a name="available">Available</a></h2> -<h3>Description</h3> -<p>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.</p> -<p>The value part of the properties being set is <i>true</i> if the resource is -present, otherwise, the property is not set.</p> -<p>Normally, this task is used to set properties that are useful to avoid target -execution depending on system parameters.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">property</td> - <td valign="top">the name of the property to set.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">classname</td> - <td valign="top">the class to look for in classpath.</td> - <td valign="middle" align="center" rowspan="3">Yes</td> - </tr> - <tr> - <td valign="top">resource</td> - <td valign="top">the resource to look for in the JVM</td> - </tr> - <tr> - <td valign="top">file</td> - <td valign="top">the file to look for.</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <available classname="org.whatever.Myclass" property="Myclass.present" /></pre> -<p>sets the property <code><i>Myclass.present</i></code> to the value "true" -if the <i>org.whatever.Myclass</i> is found in Ant's classpath.</p> -<hr> -<h2><a name="chmod">Chmod</a></h2> -<h3>Description</h3> -<p>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.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">the file of which the permissions must be changed.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">perm</td> - <td valign="top">the new permissions.</td> - <td valign="top" align="center">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><chmod src="${dist}/start.sh" perm="ugo+rx" - /></code></p> -</blockquote> -<p>makes the "start.sh" file readable and executable for anyone on a -UNIX system.</p> -<hr> -<h2><a name="copydir">Copydir</a></h2> -<h3>Description</h3> -<p>Copies a directory tree from the source to the destination.</p> -<p>It is possible to refine the set of files that are being copied. This can be -done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i> -attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to -have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the <i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the <i>src</i> directory.</p> -<p>The <i>ignore</i> attribute contains the names of the files/directories that -must be excluded from the copy. The names specified in the <i>ignore</i> -attribute are just names, they do not contain any path information! Note that -this attribute has been replaced by the <i>excludes</i> attribute.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">the directory to copy.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">the directory to copy to.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">ignore</td> - <td valign="top">comma separated list of filenames/directorynames to ignore. - No files (except default excludes) are excluded when omitted. (<b>deprecated</b>, - use <i>excludes</i> instead).</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">filtering</td> - <td valign="top">indicates whether token filtering should take place during - the copy</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">forceoverwrite</td> - <td valign="top">overwrite existing files even if the destination - files are newer (default is false).</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <copydir src="${src}/resources" - dest="${dist}" - /></pre> -<p>copies the directory <code>${src}/resources</code> to <code>${dist}</code>.</p> -<pre> <copydir src="${src}/resources" - dest="${dist}" - includes="**/*.java" - excludes="**/Test.java" - /></pre> -<p>copies the directory <code>${src}/resources</code> to <code>${dist}</code> -recursively. All java files are copied, except for files with the name <code>Test.java</code>.</p> -<pre> <copydir src="${src}/resources" - dest="${dist}" - includes="**/*.java" - excludes="mypackage/test/**" /></pre> -<p>copies the directory <code>${src}/resources</code> to <code>${dist}</code> -recursively. All java files are copied, except for the files under the <code>mypackage/test</code> -directory.</p> -<hr> -<h2><a name="copyfile">Copyfile</a></h2> -<h3>Description</h3> -<p>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.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">the filename of the file to copy.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">the filename of the file where to copy to.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">filtering</td> - <td valign="top">indicates whether token filtering should take place during - the copy</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><copyfile src="test.java" dest="subdir/test.java" - /></code></p> - <p><code><copyfile src="${src}/index.html" dest="${dist}/help/index.html" - /></code></p> -</blockquote> -<hr> -<h2><a name="cvs">Cvs</a></h2> -<h3>Description</h3> -<p>Handles packages/modules retrieved from a -<a href="http://www.cyclic.com/">CVS</a> repository.</p> -<p>When doing automated builds, the <a href="#get">get task</a> should be -preferred over the <i>checkout</i> command, because of speed.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">command</td> - <td valign="top">the CVS command to execute.</td> - <td align="center" valign="top">No, default "checkout"</td> - </tr> - <tr> - <td valign="top">cvsRoot</td> - <td valign="top">the CVSROOT variable.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">the directory where the checked out files should be placed.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">package</td> - <td valign="top">the package/module to check out.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">tag</td> - <td valign="top">the tag of the package/module to check out.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">date</td> - <td valign="top">Use the most recent revision no later than the given date</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">quiet</td> - <td valign="top">supress informational messages.</td> - <td align="center" valign="top">No, default "false"</td> - </tr> - <tr> - <td valign="top">noexec</td> - <td valign="top">report only, don't change any files.</td> - <td align="center" valign="top">No, default "false"</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <cvs cvsRoot=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic" - package="jakarta-tools" - dest="${ws.dir}" - /></pre> -<p>checks out the package/module "jakarta-tools" from the CVS -repository pointed to by the cvsRoot attribute, and stores the files in "${ws.dir}".</p> -<pre> <cvs dest="${ws.dir}" command="update" /></pre> -<p>updates the package/module that has previously been checked out into -"${ws.dir}".</p> -<hr> -<h2><a name="delete">Delete</a></h2> -<h3>Description</h3> -<p>Deletes either a single file or -all files in a specified directory and its sub-directories.</p> -<p>It is possible to refine the set of files that are being deleted. This can be -done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i> -attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to -have included in the deletion process by using patterns. The <i>exclude</i> or <i>excludesfile</i> 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 <i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the <i>dir</i> directory.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">file</td> - <td valign="top">The file to delete.</td> - <td align="center" valign="middle" rowspan="2">at least one of the two</td> - </tr> - <tr> - <td valign="top">dir</td> - <td valign="top">The directory to delete files from.</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">Comma 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.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">Comma separated list of patterns of files that must be - excluded from the deletion list. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">Indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">verbose</td> - <td valign="top">Show name of each deleted file ("true"/"false"). Default is "false" when omitted.</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <delete file="/lib/ant.jar" /></pre> -<p>deletes the file <code>/lib/ant.jar</code>.</p> -<pre> <delete dir="lib" /></pre> -<p>deletes all files in the <code>/lib</code> directory.</p> -<pre> <delete dir="." - include="**/*.bak" - /> -</pre> -<p>deletes all files with the extension "<code>.bak</code>" from the current directory -and any sub-directories.</p> -<h2><a name="deltree">Deltree</a></h2> -<h3>Description</h3> -<p>Deletes a directory with all its files and subdirectories.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">dir</td> - <td valign="top">the directory to delete.</td> - <td valign="top" align="center">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <deltree dir="dist" /></pre> -<p>deletes the directory <code>dist</code>, including its files and -subdirectories.</p> -<pre> <deltree dir="${dist}" /></pre> -<p>deletes the directory <code>${dist}</code>, including its files and -subdirectories.</p> -<hr> -<h2><a name="echo">Echo</a></h2> -<h3>Description</h3> -<p>Echoes a message to System.out.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">message</td> - <td valign="top">the message to echo.</td> - <td valign="top" align="center">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <echo message="Hello world" /></pre> -<hr> -<h2><a name="exec">Exec</a></h2> -<h3>Description</h3> -<p>Executes a system command. When the <i>os</i> attribute is specified, then -the command is only executed when Ant is run on one of the specified operating -systems.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">command</td> - <td valign="top">the command to execute.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">dir</td> - <td valign="top">the directory in which the command should be executed.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">os</td> - <td valign="top">list of Operating Systems on which the command may be - executed.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">output</td> - <td valign="top">the file to which the output of the command should be - redirected.</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><exec dir="${src}" command="dir" os="windows" - output="dir.txt" /></code></p> -</blockquote> -<hr> -<h2><a name="expand">Expand</a></h2> -<h3>Description</h3> -<p>Unzips a zipfile.</p> -<p>For JDK 1.1 "last modified time" field is set to current time instead of being -carried from zipfile.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">zipfile to expand.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">directory where to store the expanded files.</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><expand src="${tomcat_src}/tools-src.zip" dest="${tools.home}" - /></code></p> -</blockquote> -<hr> -<h2><a name="filter">Filter</a></h2> -<h3>Description</h3> -<p>Sets a token filter for this project. Token filters are used by all tasks -that perform file copying operations through the Project commodity methods.</p> -<p>Note: the token string must not contain the separators chars (@).</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">token</td> - <td valign="top">the token string without @</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">value</td> - <td valign="top">the string that should be put to replace the token when the - file is copied</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <filter token="year" value="2000" /> - <copydir src="${src.dir}" dest="${dest.dir}"/></pre> -<p>will copy recursively all the files from the <i>src.dir</i> directory into -the <i>dest.dir</i> directory replacing all the occurencies of the string <i>@year@</i> -with <i>2000.</i></p> -<hr> -<h2><a name="fixcrlf">FixCRLF</a></h2> -<h3>Description</h3> -<p>Adjusts a text file to local.</p> -<p>It is possible to refine the set of files that are being adjusted. This can be -done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i> -attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to -have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the <i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the <i>src</i> directory.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">srcDir</td> - <td valign="top">Where to find the files to be fixed up.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">destDir</td> - <td valign="top">Where to place the corrected files. Defaults to - srcDir (replacing the original file)</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">cr</td> - <td valign="top">Specifies how carriage return (CR) characters are to - be handled. Valid values for this property are: - <ul> - <li>add: ensure that there is a CR before every LF - <li>asis: leave CR characters alone - <li>remove: remove all CR characters - </ul> - 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. - <p> - Note: Unless this property is specified as "asis", extra CR characters - which do not preceed a LF will be removed. - </td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">tab</td> - <td valign="top">Specifies how tab characters are to be handled. Valid - values for this property are: - <ul> - <li>add: convert sequences of spaces which span a tab stop to tabs - <li>asis: leave tab and space characters alone - <li>remove: convert tabs to spaces - </ul> - Default for this parameter is "asis". - <p> - Note: Unless this property is specified as "asis", extra spaces and - tabs after the last non-whitespace character on the line will be removed. - </td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">eof</td> - <td valign="top">Specifies how DOS end of file (control-Z) characters are - to be handled. Valid values for this property are: - <ul> - <li>add: ensure that there is an EOF character at the end of the file - <li>asis: leave EOF characters alone - <li>remove: remove any EOF character found at the end - </ul> - 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. - </td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <fixcrlf srcdir="${src}" - cr="remove" eof="remove" - includes="**/*.sh" - /></pre> -<p>Removes carriage return and eof characters from the shell scripts. Tabs and -spaces are left as is. -<pre> <fixcrlf srcdir="${src}" - cr="add" - includes="**/*.bat" - /></pre> -<p>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.</p> -<pre> <fixcrlf srcdir="${src}" - tabs="add" - includes="**/Makefile" - /></pre> -<p>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.</p> -<pre> <fixcrlf srcdir="${src}" - tabs="remove" - includes="**/README*" - /></pre> -<p>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.</p> -<hr> -<h2><a name="get">Get</a></h2> -<h3>Description</h3> -<p>Gets a file from an URL. When the verbose option is "on", this task -displays a '.' for every 100 Kb retrieved.</p> -<p>This task should be preferred above the <a href="#cvs">CVS task</a> when -doing automated builds. CVS is significant slower than loading a compressed -archive with http/ftp.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">the URL from which to retrieve a file.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">the file where to store the retrieved file.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">verbose</td> - <td valign="top">show verbose information ("on"/"off").</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">ignoreerrors</td> - <td valign="top">Log errors but don't treat as fatal.</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <get src="http://jakarta.apache.org/" dest="help/index.html" /></pre> -<p>gets the index page of http://jakarta.apache.org/, and stores it in the file <code>help/index.html</code>.</p> -<hr> -<h2><a name="gunzip">GUnzip</a></h2> -<h3>Description</h3> -<p>Expands a GZip file.</p> - -<p>If <i>dest</i> is a directory the name of the destination file is -the same as <i>src</i> (with the ".gz" extension removed if -present). If <i>dest</i> is ommited, the parent dir of <i>src</i> 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.</p> - -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">the file to expand.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">the destination file or directory.</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><gunzip src="test.tar.gz"/></code></p> -</blockquote> -<p>expands <i>test.tar.gz</i> to <i>test.tar</i></p> -<blockquote> - <p><code><gunzip src="test.tar.gz" dest="test2.tar"/></code></p> -</blockquote> -<p>expands <i>test.tar.gz</i> to <i>test2.tar</i></p> -<blockquote> - <p><code><gunzip src="test.tar.gz" dest="subdir"/></code></p> -</blockquote> -<p>expands <i>test.tar.gz</i> to <i>subdir/test.tar</i> (assuming -subdir is a directory).</p> - -<hr> -<h2><a name="gzip">GZip</a></h2> -<h3>Description</h3> -<p>GZips a file.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">the file to gzip.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">zipfile</td> - <td valign="top">the destination file.</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><gzip src="test.tar" zipfile="test.tar.gz" - /></code></p> -</blockquote> -<hr> -<h2><a name="jar">Jar</a></h2> -<h3>Description</h3> -<p>Jars a set of files.</p> -<p>The <i>basedir</i> attribute is the reference directory from where to jar.</p> -<p>It is possible to refine the set of files that are being jarred. This can be -done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i> -attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to -have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the <i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the <i>basedir</i> directory.</p> -<p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes -replace the <i>items</i> and <i>ignore</i> attributes. The following explains -how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p> -<p>When "*" is used for <i>items</i>, 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.</p> -<p>With the <i>ignore</i> attribute, you can specify files or directories to -ignore. These files will not be jarred. The items in the <i>ignore</i> attribute -override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i> -attribute are just names, they do not contain any path information!</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">jarfile</td> - <td valign="top">the jar-file to create.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">basedir</td> - <td valign="top">the directory from which to jar the files.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">compress</td> - <td valign="top">Not only store data but also compress them, defaults to true</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">items</td> - <td valign="top">a comma separated list of the files/directories to jar. All - files are included when omitted. (<b>deprecated</b>, use <i>includes</i> - instead).</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">ignore</td> - <td valign="top">comma separated list of filenames/directorynames to exclude - from the jar. No files (except default excludes) are excluded when - omitted. (<b>deprecated</b>, use <i>excludes</i> instead).</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">manifest</td> - <td valign="top">the manifest file to use.</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" /></pre> -<p>jars all files in the <code>${build}/classes</code> directory in a file -called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p> -<pre> <jar jarfile="${dist}/lib/app.jar" - basedir="${build}/classes" - excludes="**/Test.class" - /></pre> -<p>jars all files in the <code>${build}/classes</code> directory in a file -called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Files -with the name <code>Test.class</code> are excluded.</p> -<pre> <jar jarfile="${dist}/lib/app.jar" - basedir="${build}/classes" - includes="mypackage/test/**" - excludes="**/Test.class" - /></pre> -<p>jars all files in the <code>${build}/classes</code> directory in a file -called <code>app.jar</code> in the <code>${dist}/lib</code> directory. Only -files under the directory <code>mypackage/test</code> are used, and files with -the name <code>Test.class</code> are excluded.</p> -<h3>Deprecated examples</h3> -<pre> <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" items="*" /></pre> -<p>jars all files in the <code>${build}/classes</code> directory in a file -called <code>app.jar</code> in the <code>${dist}/lib</code> directory.</p> -<pre> <jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" items="*" ignore="Test.class" /></pre> -<p>jars all files in the <code>${build}/classes</code> directory in a file -called <code>app.jar</code> in the <code>${dist}/lib</code> directory. -Files/directories with the name <code>Test.class</code> are excluded.</p> -<hr> -<h2><a name="java">Java</a></h2> -<h3>Description</h3> -<p>Executes a Java class within the running (Ant) VM or forks another VM if -specified.</p> -<p>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.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">classname</td> - <td valign="top">the Java class to execute.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">args</td> - <td valign="top">the arguments for the class that is executed.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">classpath</td> - <td valign="top">the classpath to use.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">fork</td> - <td valign="top">if enabled triggers the class execution in another VM - (disabled by default)</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">jvm</td> - <td valign="top">the 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. - </td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">jvmargs</td> - <td valign="top">the arguments to pass to the forked VM (ignored if fork is - disabled)</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <java classname="test.Main" /></pre> -<pre> <java classname="test.Main" args="-h" /></pre> -<pre> <java classname="test.Main" - args="-h" - fork="yes" - jvmargs="-Xrunhprof:cpu=samples,file=log.txt,depth=3" - /></pre> -<hr> -<h2><a name="javac">Javac</a></h2> -<h3>Description</h3> -<p>Compiles a source tree within the running (Ant) VM.</p> -<p>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.</p> -<p>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.</p> -<p>The directory structure of the source tree should follow the package -hierarchy.</p> -<p>It is possible to refine the set of files that are being compiled/copied. -This can be done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i> -attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to -have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the <i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the <i>srcdir</i> directory.</p> -<p>It is possible to use different compilers. This can be selected with the -"build.compiler" property. There are three choices:</p> -<ul> - <li>classic (the standard compiler of JDK 1.1/1.2)</li> - <li>modern (the new compiler of JDK 1.3)</li> - <li>jikes (the <a - href="http://oss.software.ibm.com/developerworks/opensource/jikes/project">Jikes</a> - compiler)</li> -</ul> -<p>For JDK 1.1/1.2 is classic the default. For JDK 1.3 is modern the default.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">srcdir</td> - <td valign="top">location of the java files.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">destdir</td> - <td valign="top">location where to store the class files.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">classpath</td> - <td valign="top">the classpath to use.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">bootclasspath</td> - <td valign="top">location of bootstrap class files.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">extdirs</td> - <td valign="top">location of installed extensions.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">debug</td> - <td valign="top">indicates whether there should be compiled with debug - information ("on").</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">optimize</td> - <td valign="top">indicates whether there should be compiled with - optimization ("on").</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">deprecation</td> - <td valign="top">indicates whether there should be compiled with deprecation - information ("on").</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">filtering</td> - <td valign="top">indicates whether token filtering should take place</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">target</td> - <td valign="top">Generate class files for specific VM version, e.g. "1.1" or "1.2".</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <javac srcdir="${src}" - destdir="${build}" - classpath="xyz.jar" - debug="on" - /></pre> -<p>compiles all .java files under the directory <code>${src}</code>, and stores -the .class files in the directory <code>${build}</code>. It also copies the non-java -files from the tree under <code>${src}</code> to the tree under <code>${build}</code>. -The classpath used contains <code>xyz.jar</code>, and debug information is on.</p> -<pre> <javac srcdir="${src}" - destdir="${build}" - includes="mypackage/p1/**,mypackage/p2/**" - excludes="mypackage/p1/testpackage/**" - classpath="xyz.jar" - debug="on" - /></pre> -<p>compiles .java files under the directory <code>${src}</code>, and stores the -.class files in the directory <code>${build}</code>. It also copies the non-java -files from the tree under <code>${src}</code> to the tree under <code>${build}</code>. -The classpath used contains <code>xyz.jar</code>, and debug information is on. -Only files under <code>mypackage/p1</code> and <code>mypackage/p2</code> are -used. Files in the <code>mypackage/p1/testpackage</code> directory are excluded -form compilation and copy.</p> - -<hr> -<h2><a name="javadoc">Javadoc/Javadoc2</a></h2> -<h3>Description</h3> -<p>Generates code documentation using the javadoc tool.</p> -<p>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 <a href="#javac">javac</a> task. This means -all packages will be processed each time this task is run. In general, however, -this task is used much less frequently.</p> -<p>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.</p> -<p>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.</p> -<p>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. - -<p>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 <a href="#javadoc">javadoc</a> -instead.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Availability</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">sourcepath</td> - <td valign="top">Specify where to find source files</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">destdir</td> - <td valign="top">Destination directory for output files</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">maxmemory</td> - <td valign="top">Max amount of memory to allocate to the javadoc VM</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">sourcefiles</td> - <td valign="top">Space separated list of source files</td> - <td align="center" valign="top">all</td> - <td align="center" valign="middle" rowspan="2">at least one of the two</td> - </tr> - <tr> - <td valign="top">packagenames</td> - <td valign="top">Space separated list of package files (with terminating - wildcard)</td> - <td align="center" valign="top">all</td> - </tr> - <tr> - <td valign="top">packageList</td> - <td valign="top">The name of a file containing the packages to process</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">classpath</td> - <td valign="top">Specify where to find user class files</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Bootclasspath</td> - <td valign="top">Override location of class files loaded by the bootstrap - class loader</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Extdirs</td> - <td valign="top">Override location of installed extensions</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Overview</td> - <td valign="top">Read overview documentation from HTML file</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Public</td> - <td valign="top">Show only public classes and members</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Protected</td> - <td valign="top">Show protected/public classes and members (default)</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Package</td> - <td valign="top">Show package/protected/public classes and members</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Private</td> - <td valign="top">Show all classes and members</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Old</td> - <td valign="top">Generate output using JDK 1.1 emulating doclet</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Verbose</td> - <td valign="top">Output messages about what Javadoc is doing</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Locale</td> - <td valign="top">Locale to be used, e.g. en_US or en_US_WIN</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Encoding</td> - <td valign="top">Source file encoding name</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Version</td> - <td valign="top">Include @version paragraphs</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Use</td> - <td valign="top">Create class and package usage pages</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Author</td> - <td valign="top">Include @author paragraphs</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Splitindex</td> - <td valign="top">Split index into one file per letter</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Windowtitle</td> - <td valign="top">Browser window title for the documenation (text)</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Doctitle</td> - <td valign="top">Include title for the package index(first) page (html-code)</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Header</td> - <td valign="top">Include header text for each page (html-code)</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">Footer</td> - <td valign="top">Include footer text for each page (html-code)</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">bottom</td> - <td valign="top">Include bottom text for each page (html-code)</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">link</td> - <td valign="top">Create links to javadoc output at the given URL</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">linkoffline</td> - <td valign="top">Link to docs at <url> using package list at - <url2></td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">group</td> - <td valign="top">Group specified packages together in overview page</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">nodeprecated</td> - <td valign="top">Do not include @deprecated information</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">nodeprecatedlist</td> - <td valign="top">Do not generate deprecated list</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">notree</td> - <td valign="top">Do not generate class hierarchy</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">noindex</td> - <td valign="top">Do not generate index</td> - <td align="center" valign="top">all</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">nohelp</td> - <td valign="top">Do not generate help link</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">nonavbar</td> - <td valign="top">Do not generate navigation bar</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">serialwarn</td> - <td valign="top">FUTURE: Generate warning about @serial tag</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">helpfile</td> - <td valign="top">FUTURE: Specifies the HTML help file to use</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">stylesheetfile</td> - <td valign="top">Specifies the CSS stylesheet to use</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">charset</td> - <td valign="top">FUTURE: Charset for cross-platform viewing of generated - documentation</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">docencoding</td> - <td valign="top">Output file encoding name</td> - <td align="center" valign="top">1.1</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">doclet</td> - <td valign="top">Specifies the class file that starts the doclet used in generating the documentation.</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">docletpath</td> - <td valign="top">Specifies the path to the doclet class file that is specified with the -doclet option.</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">additionalparam</td> - <td valign="top">Lets you add additional parameters to the javadoc command line. Useful for doclets</td> - <td align="center" valign="top">1.2</td> - <td align="center" valign="top">No</td> - </tr> -</table> - -<h3>Parameters specified as subelements</h3> -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. -<h4>link</h4> -Create link to javadoc output at the given URL -<h4>Parameters</h4> - -<table width="60%" border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">href</td> - <td valign="top">The URL for the external documentation you wish to link to</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">offline</td> - <td valign="top">True if this link is not available online at the time of - generating the documentation</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">packagelistLoc</td> - <td valign="top">The location to the directory containing the package-list file for - the external documentation</td> - <td align="center" valign="top">Only if the offline attribute is true</td> - </tr> -</table> - -<h4>groups</h4> -Separates packages on the overview page into whatever groups you specify, -one group per table. - -<table width="60%" border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">title</td> - <td valign="top">Title of the group</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">packages</td> - <td valign="top">List of packages to include in that group</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> - -<h3>Example</h3> -<pre> <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></pre> - -<hr> -<h2><a name="keysubst">KeySubst</a></h2> -<h3>Description</h3> -<p>Performs keyword substitution in the source file, and writes the result to -the destination file.</p> -<p>Keys in the source file are of the form ${keyname}. The <i>keys</i> attribute -contains key/value pairs. When a key is found in the <i>keys</i> attribute, then -"${keyname}" is replaced by the corresponding value.</p> -<p>The <i>keys</i> attribute is of the form -"name1=value1*name2=value2*name3=value3". The '*' is called the -separator, which might we changed with the <i>sep</i> attribute.</p> -<p>Note: the source file and destination file may not be the same.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">the source file.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">the destination file.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">sep</td> - <td valign="top">the separator for the name/value pairs.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">keys</td> - <td valign="top">name/value pairs for replacement.</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <keysubst src="abc.txt" dest="def.txt" keys="VERSION=1.0.3*DATE=2000-01-10" /></pre> -<hr> -<h2><a name="mkdir">Mkdir</a></h2> -<h3>Description</h3> -<p>Creates a directory. Also non-existent parent directories are created, when -necessary.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">dir</td> - <td valign="top">the directory to create.</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<pre><mkdir dir="${dist}" /></pre> -<p>creates a directory <code>${dist}</code>.</p> -<pre><mkdir dir="${dist}/lib" /></pre> -<p>creates a directory <code>${dist}/lib</code>.</p> -<hr> -<h2><a name="patch">Patch</a></h2> -<h3>Description</h3> -<p>Applies a diff file to originals. -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">dir</td> - <td valign="top">the directory in which the command should be executed.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">os</td> - <td valign="top">list of Operating Systems on which the command may be - executed.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">output</td> - <td valign="top">the file to which the output of the patch command - should be redirected.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">patchfile</td> - <td valign="top">the file that includes the diff output</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">originalfile</td> - <td valign="top">the file to patch</td> - <td align="center" valign="top">No, tries to guess it from the diff - file</td> - </tr> - <tr> - <td valign="top">backups</td> - <td valign="top">Keep backups of the unpatched files</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">quiet</td> - <td valign="top">Work silently unless an error occurs</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">reverse</td> - <td valign="top">Assume patch was created with old and new files - swapped.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">ignorewhitespace</td> - <td valign="top">Ignore whitespace differences.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">strip</td> - <td valign="top">Strip the smallest prefix containing <i>num</i> leading - slashes from filenames.</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <patch patchfile="module.1.0-1.1.patch" /></pre> -<p>applies the diff included in <i>module.1.0-1.1.patch</i> to the -files in base directory guessing the filename(s) from the diff output. -<pre> <patch patchfile="module.1.0-1.1.patch" strip="1" /></pre> -<p>like above but one leading directory part will be removed. i.e. if -the diff output looked like -<pre> ---- a/mod1.0/A Mon Jun 5 17:28:41 2000 -+++ a/mod1.1/A Mon Jun 5 17:28:49 2000 -</pre> -the leading <i>a/</i> will be stripped. -<h2><a name="property">Property</a></h2> -<h3>Description</h3> -<p>Sets a property (by name and value), or set of properties (from file or -resource) in the project.</p> -<p>When a property was set by the user, or was a property in a parent project -(that started this project with the <a href="#ant">ant task</a>), 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.</p> -<p>There are three ways to set properties:</p> -<ul> - <li>By supplying both the <i>name</i> and <i>value</i> attribute.</li> - <li>By setting the <i>file</i> 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.</li> - <li>By setting the <i>resource</i> 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.</li> -</ul> -<p>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.</p> -<p>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.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">name</td> - <td valign="top">the name of the property to set.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">value</td> - <td valign="top">the value of the property.</td> - <td valign="middle" align="center" rowspan="3">Yes</td> - </tr> - <tr> - <td valign="top">resource</td> - <td valign="top">the resource name of the property file.</td> - </tr> - <tr> - <td valign="top">file</td> - <td valign="top">the filename of the property file .</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <property name="foo.dist" value="dist" /></pre> -<p>sets the property <code>foo.dist</code> to the value "dist".</p> -<pre> <property file="foo.properties" /></pre> -<p>reads a set of properties from a file called "foo.properties".</p> -<pre> <property resource="foo.properties" /></pre> -<p>reads a set of properties from a resource called "foo.properties".</p> -<p>Note that you can reference a global properties file for all of your Ant -builds using the following: -<pre> <property file="${user.home}/.ant-global.properties" /></pre> -<p>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. -<hr> -<h2><a name="rename">Rename</a></h2> -<h3>Description</h3> -<p>Renames a given file.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">file to rename.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">new name of the file.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">replace</td> - <td valign="top">Enable replacing of existing file (default: on).</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <rename src="foo.jar" dest="${name}-${version}.jar" /></pre> -<p>Renames the file <code>foo.jar</code> to <code>${name}-${version}.jar</code> (assuming <code>name</code> - and <code>version</code> being predefined properties). If a file named <code>${name}-${version}.jar</code> - already exists, it will be removed prior to renameing <code>foo.jar</code>.</p> -<hr> -<h2><a name="replace">Replace</a></h2> -<h3>Description</h3> -<p>Replace is a directory based task for replacing the occurrence of a given string with another string -in selected file.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">file</td> - <td valign="top">file for which the token should be replaced. If not present the dir attribute - must be specified</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">dir</td> - <td valign="top">The base directory to use when replacing a token in multiple files. If not present the file attribute - must be specified</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">token</td> - <td valign="top">the token which must be replaced.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">value</td> - <td valign="top">the new value for the token. When omitted, an empty string - ("") is used.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <replace file="${src}/index.html" token="@@@" value="wombat" /></pre> -<p>replaces occurrences of the string "@@@" with the string -"wombat", in the file <code>${src}/index.html</code>.</p> -<hr> -<h2><a name="rmic">Rmic</a></h2> -<h3>Description</h3> -<p>Runs the rmic compiler for a certain class.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">base</td> - <td valign="top">the location to store the compiled files.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">classname</td> - <td valign="top">the class for which to run <code>rmic</code>.</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">filtering</td> - <td valign="top">indicates whether token filtering should take place</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">sourcebase</td> - <td valign="top">Pass the "-keepgenerated" flag to rmic and - move the generated source file to the base directory.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">stubversion</td> - <td valign="top">Specify the JDK version for the generated stub code. - Specify "1.1" to pass the "-v1.1" option to rmic.</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">classpath</td> - <td valign="top">The classpath to use during compilation</td> - <td align="center" valign="top">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <rmic classname="com.xyz.FooBar" base="${build}/classes" /></pre> -<p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The -compiled files will be stored in the directory <code>${build}/classes</code>.</p> -<hr> -<h2><a name="tar">Tar</a></h2> -<h3>Description</h3> -<p>Creates a tar archive.</p> -<p>The <i>basedir</i> attribute is the reference directory from where to tar.</p> -<p>It is possible to refine the set of files that are being tarred. This can be -done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i> -attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to -have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the <i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the <i>basedir</i> directory.</p> -<p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes -replace the <i>items</i> and <i>ignore</i> attributes. The following explains -how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p> -<p>When "*" is used for <i>items</i>, 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.</p> -<p>With the <i>ignore</i> attribute, you can specify files or directories to -ignore. These files will not be tarred. The items in the <i>ignore</i> attribute -override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i> -attribute are just names, they do not contain any path information!</p> -<p>Note that this task does not perform compression. You might want to use the <a href="#gzip">GZip</a> -task to come up with a .tar.gz package.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td valign="top" align="center"><b>Required</b></td> - </tr> - <tr> - <td valign="top">tarfile</td> - <td valign="top">the tar-file to create.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">basedir</td> - <td valign="top">the directory from which to zip the files.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <tar tarfile="${dist}/manual.tar" basedir="htdocs/manual" /> - <gzip zipfile="${dist}/manual.tar.gz" src="${dist}/manual.tar" /></pre> -<p>tars all files in the <code>htdocs/manual</code> directory in a file called <code>manual.tar</code> -in the <code>${dist}</code> directory, then applies the gzip task to compress -it.</p> -<pre> <tar tarfile="${dist}/manual.tar" - basedir="htdocs/manual" - excludes="mydocs/**, **/todo.html" - /></pre> -<p>tars all files in the <code>htdocs/manual</code> directory in a file called <code>manual.tar</code> -in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>, -or files with the name <code>todo.html</code> are excluded.</p> -<hr> -<h2><a name="taskdef">Taskdef</a></h2> -<h3>Description</h3> -<p>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.</p> -<p>Taskdef should be used to add your own tasks to the system. See also "<a -href="#writingowntask">Writing your own task</a>".</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">name</td> - <td valign="top">the name of the task</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">classname</td> - <td valign="top">the full class name implementing the task</td> - <td valign="top" align="center">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <taskdef name="myjavadoc" classname="com.mydomain.JavadocTask" /></pre> -<p>makes a task called <code>myjavadoc</code> available to Ant. The class <code>com.mydomain.JavadocTask</code> -implements the task.</p> -<hr> -<h2><a name="touch">Touch</a></h2> -<h3>Description</h3> -<p>Changes the modification time of a file and possibly creates it at -the same time.</p> -<p>For JDK 1.1 only the creation of new files with a modification time -of now works, all other cases will emit a warning.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">file</td> - <td valign="top">the name of the file</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">millis</td> - <td valign="top">specifies the new modification time of the file - in milliseconds since midnight Jan 1 1970</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">datetime</td> - <td valign="top">specifies the new modification time of the file - in the format MM/DD/YYYY HH:MM AM_or_PM.</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<p>If both <code>millis</code> and <code>datetime</code> are ommited -the current time is assumed.</p> -<h3>Examples</h3> -<pre> <touch file="myfile" /></pre> -<p>creates <code>myfile</code> if it doesn't exist and changes the -modification time to the current time.</p> -<pre> <touch file="myfile" datetime="06/28/2000 2:02 pm" /></pre> -<p>creates <code>myfile</code> 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).</p> -<hr> -<h2><a name="tstamp">Tstamp</a></h2> -<h3>Description</h3> -<p>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".</p> -<p>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.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> -</table> -<h3>Examples</h3> -<pre> <tstamp/></pre> -<hr> -<h2><a name="style">Style</a></h2> -<h3>Description</h3> -<p>Process a set of documents via XSLT.</p> -<p>This is useful for building views of XML based documentation, -or in generating code.</p> -<p>It is possible to refine the set of files that are being copied. This can be -done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i> -attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to -have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the <i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the <i>basedir</i> directory.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">basedir</td> - <td valign="top">where to find the source xml file.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">destdir</td> - <td valign="top">directory where to store the results.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">extention</td> - <td valign="top">desired file extension to be used for the targets. - If not specified, the default is "html".</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">style</td> - <td valign="top">name of the stylesheet to use.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">processor</td> - <td valign="top">name 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 path</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><pre> -<style basedir="doc" destdir="build/doc" - extension="html" style="style/apache.xml"/> -</pre></p> -</blockquote> -<hr> -<h2><a name="untar">Untar</a></h2> -<h3>Description</h3> -<p>Untars a tarfile.</p> -<p>For JDK 1.1 "last modified time" field is set to current time instead of being -carried from tarfile.</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">tarfile to expand.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">dest</td> - <td valign="top">directory where to store the expanded files.</td> - <td align="center" valign="top">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code> -<gunzip src="tools.tar.gz"/><br> -<untar src="tools.tar" dest="${tools.home}"/> -</code></p> -</blockquote> -<hr> -<h2><a name="zip">Zip</a></h2> -<h3>Description</h3> -<p>Creates a zipfile.</p> -<p>The <i>basedir</i> attribute is the reference directory from where to zip.</p> -<p>It is possible to refine the set of files that are being zipped. This can be -done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and <i>defaultexcludes</i> -attributes. With the <i>includes</i> or <i>includesfile</i> attribute you specify the files you want to -have included by using patterns. The <i>exclude</i> or <i>excludesfile</i> attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the <i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the <i>basedir</i> directory.</p> -<p>The <i>includes</i>, <i>excludes</i> and <i>defaultexcludes</i> attributes -replace the <i>items</i> and <i>ignore</i> attributes. The following explains -how the deprecated <i>items</i> and <i>ignore</i> attribute behave.</p> -<p>When "*" is used for <i>items</i>, 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.</p> -<p>With the <i>ignore</i> attribute, you can specify files or directories to -ignore. These files will not be zipped. The items in the <i>ignore</i> attribute -override the items in the <i>items</i> attribute. The names specified in the <i>ignore</i> -attribute are just names, they do not contain any path information!</p> -<h3>Parameters</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td valign="top" align="center"><b>Required</b></td> - </tr> - <tr> - <td valign="top">zipfile</td> - <td valign="top">the zip-file to create.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">basedir</td> - <td valign="top">the directory from which to zip the files.</td> - <td align="center" valign="top">Yes</td> - </tr> - <tr> - <td valign="top">compress</td> - <td valign="top">Not only store data but also compress them, defaults to true</td> - <td align="center" valign="top">No</td> - </tr> - <tr> - <td valign="top">items</td> - <td valign="top">a comma separated list of the files/directories to zip. All - files are included when omitted. (<b>deprecated</b>, use <i>includes</i> - instead).</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">ignore</td> - <td valign="top">comma separated list of filenames/directorynames to exclude - from the zip. No files (except default excludes) are excluded when - omitted. (<b>deprecated</b>, use <i>excludes</i> instead).</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted.</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<pre> <zip zipfile="${dist}/manual.zip" - basedir="htdocs/manual" - /></pre> -<p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code> -in the <code>${dist}</code> directory.</p> -<pre> <zip zipfile="${dist}/manual.zip" - basedir="htdocs/manual" - excludes="mydocs/**, **/todo.html" - /></pre> -<p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code> -in the <code>${dist}</code> directory. Files in the directory <code>mydocs</code>, -or files with the name <code>todo.html</code> are excluded.</p> -<pre> <zip zipfile="${dist}/manual.zip" - basedir="htdocs/manual" - includes="api/**/*.html" - excludes="**/todo.html" - /></pre> -<p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code> -in the <code>${dist}</code> directory. Only html files under the directory <code>api</code> -are zipped, and files with the name <code>todo.html</code> are excluded.</p> -<h3>Deprecated examples</h3> -<pre> <zip zipfile="${dist}/manual.zip" - basedir="htdocs/manual" - items="*" - /></pre> -<p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code> -in the <code>${dist}</code> directory.</p> -<pre> <zip zipfile="${dist}/manual.zip" - basedir="htdocs/manual" - items="*" - ignore="mydocs, todo.html" - /></pre> -<p>zips all files in the <code>htdocs/manual</code> directory in a file called <code>manual.zip</code> -in the <code>${dist}</code> directory. Files/directories with the names <code>mydocs</code> -and <code>todo.html</code> are excluded.</p> - -<hr> -<h2><a name="buildevents">Build Events</a></h2> -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. - -<p>To use build events you need to create an ant <code>Project</code> object. You can then call the -<code>addBuildListener</code> method to add your listener to the project. Your listener must implement -the <code>org.apache.tools.antBuildListener</code> interface. The listener will receive BuildEvents -for the following events -<ul> -<li>Build started -<li>Build finished -<li>Target started -<li>Target finished -<li>Task started -<li>Task finished -<li>Message logged -</ul> - -If you wish to attach a listener from the command line you may use the -listener option. For example -<blockquote> - <pre>ant -listener org.apache.tools.ant.XmlLogger</pre> -</blockquote> -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. - - -<hr> -<h2><a name="writingowntask">Writing your own task</a></h2> -<p>It is very easy to write your own task:</p> -<ol> - <li>Create a Java class that extends <code>org.apache.tools.ant.Task</code>.</li> - <li>For each attribute, write a setter method. The setter method must be a <code>public - void</code> method that takes one <code>String</code> 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.</li> - <li>Write a <code>public void execute</code> method, with no arguments, that - throws a <code>BuildException</code>. This method implements the task - itself.</li> -</ol> -<p>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.</p> -<p>Let's write our own task, that prints a message on the System.out stream. The -task has one attribute called "message".</p> -<blockquote> - <pre>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; - } -}</pre> -</blockquote> -<p>It's really this simple;-)</p> -<p>Adding your task to the system is rather simple too:</p> -<ol> - <li>Make sure the class that implements your task is in the classpath when - starting Ant.</li> - <li>In your initialization target, add a <i>taskdef</i> task. This actually adds - your task to the system.</li> - <li>Use your task in the rest of the buildfile.</li> -</ol> -<h3>Example</h3> -<blockquote> - <pre><?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> -</pre> -</blockquote> -<p>Another way to add a task (more permanently), is to add the task name and -implementing class name to the <code>default.properties</code> file in the <code>org.apache.tools.ant.taskdefs</code> -package. Then you can use it as if it were a built in task.</p> -<hr> -<h2><a name="feedback">Feedback</a></h2> -<p>To provide feedback on this software, please subscribe to the Ant Development -Mail List <a href="mailto:(ant-dev-subscribe@jakarta.apache.org">(ant-dev-subscribe@jakarta.apache.org</a>)</p> -<hr> -<p align="center">Copyright © 2000 Apache Software Foundation. All rights -Reserved.</p> - -<h2><a name="optionaltasks">Optional tasks</a></h2> -<ul> - <li><a href="#netrexxc">NetRexxC</a></li> - <li><a href="#renameexts">RenameExtensions</a></li> - <li><a href="#script">Script</a></li> -</ul> -<hr> -<h2><a name="netrexxc">NetRexxC</a></h2> -<h3><b>Description:</b></h3> -<p>Compiles a <a href="http://www2.hursley.ibm.com/netrexx">NetRexx</a> -source tree within the running (Ant) VM.</p> -<p>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.</p> -<p>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</p> -<p>The directory structure of the source tree should follow the package -hierarchy.</p> -<p>It is possible to refine the set of files that are being compiled/copied. -This can be done with the <i>includes</i>, <i>includesfile</i>, <i>excludes</i>, <i>excludesfile</i> and -<i>defaultexcludes</i> attributes. With the <i>includes</i> or <i>includesfile</i> attribute you -specify the files you want to have included by using patterns. The -<i>exclude</i> or <i>excludesfile</i> attribute is used to specify the files you want to have -excluded. This is also done with patterns. And finally with the -<i>defaultexcludes</i> attribute, you can specify whether you -want to use default exclusions or not. See the section on <a -href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The -patterns are relative to the <i>srcDir</i> directory.</p> - -<h3>Parameters:</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">binary</td> - <td valign="top">Whether literals are treated as the java binary - type rather than the NetRexx types</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">classpath</td> - <td valign="top">The classpath to use during compilation</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">comments</td> - <td valign="top">Whether comments are passed through to the - generated java source</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">compact</td> - <td valign="top">Whether error messages come out in compact or - verbose format</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">compile</td> - <td valign="top">Whether the NetRexx compiler should compile the - generated java code</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">console</td> - <td valign="top">Whether or not messages should be displayed on the - 'console'</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">crossref</td> - <td valign="top">Whether variable cross references are generated</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">decimal</td> - <td valign="top">Whether decimal arithmetic should be used for the - NetRexx code</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when - omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">destDir</td> - <td valign="top">the destination directory into which the NetRexx - source files should be copied and then compiled</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">diag</td> - <td valign="top">Whether diagnostic information about the compile is - generated</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when - omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">explicit</td> - <td valign="top">Whether variables must be declared explicitly - before use</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">format</td> - <td valign="top">Whether the generated java code is formatted nicely - or left to match NetRexx line numbers for call stack debugging</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">java</td> - <td valign="top">Whether the generated java code is produced</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">keep</td> - <td valign="top">Sets whether the generated java source file should be kept - after compilation. The generated files will have an extension of - .java.keep, <b>not</b> .java</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">logo</td> - <td valign="top">Whether the compiler text logo is displayed when - compiling</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">replace</td> - <td valign="top">Whether the generated .java file should be replaced - when compiling</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">savelog</td> - <td valign="top">Whether the compiler messages will be written to - NetRexxC.log as well as to the console</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">sourcedir</td> - <td valign="top">Tells the NetRexx compiler to store the class files in the - same directory as the source files. The alternative is the working - directory</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">srcDir</td> - <td valign="top">Set the source dir to find the source Netrexx - files</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">strictargs</td> - <td valign="top">Tells the NetRexx compiler that method calls always - need parentheses, even if no arguments are needed, e.g. - <code>aStringVar.getBytes</code> vs. - <code>aStringVar.getBytes()</code></td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">strictassign</td> - <td valign="top">Tells the NetRexx compile that assignments must - match exactly on type</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">strictcase</td> - <td valign="top">Specifies whether the NetRexx compiler should be - case sensitive or not</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">strictimport</td> - <td valign="top">Whether classes need to be imported explicitly using an - <code>import</code> statement. By default the NetRexx compiler will - import certain packages automatically</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">strictprops</td> - <td valign="top">Whether local properties need to be qualified - explicitly using <code>this</code></td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">strictsignal</td> - <td valign="top">Whether the compiler should force catching of - exceptions by explicitly named types</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">symbols</td> - <td valign="top">Whether debug symbols should be generated into the - class file</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">time</td> - <td valign="top">Asks the NetRexx compiler to print compilation - times to the console</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">trace</td> - <td valign="top">Turns on or off tracing and directs the resultant - trace output</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">utf8</td> - <td valign="top">Tells the NetRexx compiler that the source is in UTF8</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">verbose</td> - <td valign="top">Whether lots of warnings and error messages should - be generated</td> - <td valign="top" align="center">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><netrexxc srcDir="/source/project" - includes="vnr/util/*" - destDir="/source/project/build" - classpath="/source/project2/proj.jar" - comments="true" - crossref="false" replace="true" - keep="true" /></code> - </p> -</blockquote> -<hr> -<h2><a name="renameexts">RenameExtensions</a></h2> -<h3><b>Description:</b></h3> -<p>Renames files in the <code>srcDir</code> directory ending with the -<code>fromExtension</code> string so that they end with the -<code>toExtension</code> string. Files are only replaced if -<code>replace</code> is true -</p> -<p>See the section on -<a href="#directorybasedtasks">directory based tasks</a>, on how the -inclusion/exclusion of files works, and how to write patterns. The -patterns are relative to the <i>srcDir</i> directory.</p> -<h3>Parameters:</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">defaultexcludes</td> - <td valign="top">indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when - omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludes</td> - <td valign="top">comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when - omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">excludesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an exclude pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">fromExtention</td> - <td valign="top">The string that files must end in to be renamed</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">includes</td> - <td valign="top">comma separated list of patterns of files that must be - included. All files are included when omitted.</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">includesfile</td> - <td valign="top">the name of a file. Each line of this file is - taken to be an include pattern</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">replace</td> - <td valign="top">Whether the file being renamed to should be - replaced if it already exists</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">srcDir</td> - <td valign="top">The starting directory for files to search in</td> - <td valign="top" align="center">Yes</td> - </tr> - <tr> - <td valign="top">toExtension</td> - <td valign="top">The string that renamed files will end with on - completion</td> - <td valign="top" align="center">Yes</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p><code><renameext srcDir="/source/project1" - includes="**" - excludes="**/samples/*" - fromExtension=".java.keep" - toExtension=".java" - replace="true" /> -</code> - </p> -</blockquote> - -<hr> -<h2><a name="script">Script</a></h2> -<h3><b>Description:</b></h3> -<p>Execute a script in a - <a href="http://www.alphaworks.ibm.com/tech/bsf">BSF</a> supported language. -<p>All items (tasks, targets, etc) of the running project are accessible -from the script. -<h3>Parameters:</h3> -<table border="1" cellpadding="2" cellspacing="0"> - <tr> - <td valign="top"><b>Attribute</b></td> - <td valign="top"><b>Description</b></td> - <td align="center" valign="top"><b>Required</b></td> - </tr> - <tr> - <td valign="top">language</td> - <td valign="top">The programming language the script is written in. - Must be a supported BSF language</td> - <td valign="top" align="center">No</td> - </tr> - <tr> - <td valign="top">src</td> - <td valign="top">The location of the script as a file, if not inline</td> - <td valign="top" align="center">No</td> - </tr> -</table> -<h3>Examples</h3> -<blockquote> - <p>None yet available</p> -</blockquote> - -</body> - -</html> - 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 @@ -<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "strict.dtd"> -<HTML> - <HEAD> - <TITLE>Ant Specification, version 0.5</TITLE> - </HEAD> - <BODY> - <H1>Ant Specification</H1> - <P>Version 0.5 (2000/04/20)</P> - <P>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.</P> - <P>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.</P> - <H2>Design Goals</H2> - <P>The following are the overall design goals of Ant:</P> - <UL> - <LI>Simplicity</LI> - <LI>Understandability</LI> - <LI>Extensibility</LI> - </UL> - <H3>Simplicity</H3> - <P>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.</P> - <H3>Understandability</H3> - <P>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.</P> - <H3>Extensibility</H3> - <P>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.</P> - <H2>Conceptual Overview</H2> - <P>This is a conceptual overview of the components used by Ant. Full APIs - will be defined later.</P> - <H3>Project</H3> - <P>The base unit of work in Ant is the <STRONG>Project</STRONG>. A Project - is defined by an editable text file and is represented by an object of type - <CODE>org.apache.ant.Project</CODE> at runtime.</P> - <P>A Project is a collection of <STRONG>Properties</STRONG> and - <STRONG>Targets</STRONG>.</P> - <H3>Properties</H3> - <P>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 <CODE>java.util.Properties</CODE> or a type that has approximatly - the same contract.</P> - <P>Properties can be defined in a hierarchical manner. The order of - precidence in this hiearchy is:</P> - <UL> - <LI>Properties defined on the command line or via a GUI tool</LI> - <LI>Properties defined in the text file which defines the project.</LI> - <LI>Properties defined in a file in the users <CODE>user.home</CODE> directory</LI> - <LI>Properties defined in the installation directory that can be shared - by multiple users.</LI> - </UL> - <P>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 - <CODE>java.lang.System</CODE> class, this functionality is considered to be confusing and to be - removed.</P> - <P>Note: The current version of Ant allows property substitution to be - performed in the project file. This functionality is being removed.</P> - <H3>Targets</H3> - <P>Targets are ordered collections of <STRONG>Tasks</STRONG>, units of work - to be performed if a Target is executed. </P> - <P>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.</P> - <P>After all dependancies of a Target have been satisfied, all of the Tasks - contained by the target are configured and executed in sequential order. </P> - <H3>Tasks</H3> - <P>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 <CODE>org.apache.ant.Task</CODE> 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.</P> - <P>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.</P> - <H2>Task Jar Layout</H2> - <P>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 - <CODE>"mvdir"</CODE>.</P> - <P><EM>Question: Should we say that tasks belong in a JAR file with the - .tsk extension?</EM></P> - <P>The class within the Jar file that implements the <CODE>org.apache.ant.Task</CODE> interface is - specified by a manifest attribute named <CODE>Ant-Task-Class</CODE> in the Jar manifest. An example - manifest would look like:</P> - <PRE> Manifest-Version: 1.0 - Ant-Task-Class: org.apache.ant.task.javac.JavacTask</PRE> - <P>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.</P> - <H2>Installation</H2> - <P>When Ant is installed on a user system, it installs a directory - structure with the following form:</P> - <PRE><installdir>/ant (unix shell script) - /ant.bat - /ant.jar - /ant.properties - /tasks/[task jar files] - /docs/[documentation] - /README</PRE> - <P>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.</P> - <P>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.</P> - <H3>Ant Properties</H3> - <P>The <CODE>ant.properties</CODE> 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:</P> - <PRE> system.taskdir=tasks/ - user.taskdir=anttasks/</PRE> - <P>The <CODE>system.taskdir</CODE> 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.</P> - <P>The <CODE>user.taskdir</CODE> 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 <CODE>user.home</CODE> - system property). Task JAR files in this directory take precendence of those in - the system directory.</P> - <P>Note: <EM>It has been suggested to add a properties file hook to the - command line to roll in props. Pending investigation.</EM></P> - <H3>User Preferences</H3> - <P>In addition to the Ant installation directory, an <CODE>ant.properties</CODE> file can be - located in the user's home directory (as found by the system property <CODE>user.home</CODE>) - 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 <CODE>ant.properties</CODE> file. Such a file could look like:</P> - <PRE> user.taskdir=anttasks/ - javac.debug=off</PRE> - <P>Properties starting with <CODE>"system."</CODE> in the user's <CODE>ant.properties</CODE> file are not - allowed and must cause a warning to be thrown.</P> - <H2>Project Configuration</H2> - <P>Ant's Project text file is structured using XML and reflects the - structure of the various components described in the Conceptual Overview.</P> - <P>A sample Project file:</P> - <PRE><project name="projectname" defaulttarget="main" taskdir="tasks/"> - <property name="javac.debug" value="on"/> - <target name="main"> - <taskimpl ...> - ... - </taskimpl> - </target> -</project></PRE> - <H3>The Project Element</H3> - <P>The <CODE>project</CODE> element has the following required attributes:</P> - <UL> - <LI><CODE><STRONG>defaulttarget</STRONG></CODE> defining the default target to be executed if no other target - is specified when Ant is run</LI> - </UL> - <P>It also has the following optional allowed attributes:</P> - <UL> - <LI><CODE><CODE><STRONG>name</STRONG></CODE></CODE> defining a name for this project</LI> - <LI><CODE><STRONG>taskdir</STRONG></CODE> 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.</LI> - </UL> - <P>The following elements are allowed as children of the project - element:</P> - <UL> - <LI><CODE><STRONG>property</STRONG></CODE> defining a property scoped to the project</LI> - <LI><CODE><STRONG>target</STRONG></CODE> defining a target</LI> - </UL> - <H3>The Property Element</H3> - <P>asdf</P> - <H3>The Target Element</H3> - <P>asfd</P> - <H2>Configuration of Tasks</H2> - <P>The Task section of the configuration file is structured as such:</P> - <PRE> <[taskname] [attname=value] [attname=value]...]> - [<[elementname] [attname=value] ...> ... </[elementname]>] - </[taskname]></PRE> - <P>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. <EM>(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?)</EM></P> - - <P>Text blocks contained by the element are added to task using an addText - method. <EM>Place an example...</EM></P> - <P>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.</P> - <P>Search order of tasks.... project/user/system</P> - <H2>Command Line</H2> - <P>The command line utility provided with Ant must support the following - allowable syntax:</P> - <P><CODE>ant projectfile [prop=value [prop=value...]] [target]</CODE></P> - <P>Internally, the command line shell scripts should call the <CODE>org.apache.ant.Main</CODE> class - with the following arguments:</P> - <PRE>java -Dant.home=installdir org.apache.ant.Main $*</PRE> - <P>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.</P> - <P>Note: <EM>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.</EM></P> - <H2>File Naming Conventions</H2> - <P>File naming in a cross platform tool is tricky. For maximum portability - and understandiblity it is recommended that project files use the following - conventions:</P> - <UL> - <LI>The '/' character is used as a directory seperator</LI> - <LI>The ':' character is used as a path seperator</LI> - <LI>Only relative paths are used</LI> - </UL> - <P>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:</P> - <UL> - <LI>Directories are seperated by the forward slash ('/') or backwards - slash ('\') character.</LI> - <LI>File names starting with either of the above directory seperators are - considered to be absolute paths.</LI> - <LI>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.</LI> - <LI>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.</LI> - </UL> - <P>Absolute paths are not recommended for build files as they reduce the - ability to share a project between u sers or machines.</P> - <P>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:</P> - <UL> - <LI>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.</LI> - <LI>The character immediately before the colon is a alphabetic character - in the range a-z or A-Z.</LI> - <LI>The character immediately after the colon is either of the allowable - directory seperators ('/' or '\').</LI> - </UL> - <H2>Scripting Model</H2> - <P>Sam, I'm leaving this to you. </P> - <H2>Runtime Requirements</H2> - <P>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.</P> - <UL> - <LI>JDK 1.1 or greater</LI> - <LI>A JAXP compliant parser on the classpath</LI> - </UL> - <P>Note: <EM>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. </EM></P> - <P></P> - <P></P> </BODY> -</HTML> 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 @@ -<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" xmlns:HTML="http://www.w3.org/Profiles/XHTML-transitional"> - -<xsl:template match="/"> - <html> - <body> - <xsl:apply-templates/> - </body> - </html> -</xsl:template> - -<xsl:template match="*"> - <xsl:apply-templates/> -</xsl:template> - -<xsl:template match="build"> - <center> - <table width="100%" bgcolor="#CCCCCC"><tr> - <xsl:if test=".[@error]"> - <td align="left" width="30%"><b>Build Failed</b></td> - <td align="center" width="40%"><b><xsl:value-of select="@error"/></b></td> - </xsl:if> - <xsl:if test=".[not(@error)]"> - <td><b>Build Complete</b></td> - </xsl:if> - <td align="right" width="30%"><b>Total Time: <xsl:value-of select="@time"/></b></td> - </tr></table> - - <br/> - <table > - <xsl:apply-templates/> - </table> - - </center> - -</xsl:template> - -<xsl:template match="message[@priority!='debug']"> - <tr valign="top"> - - <td><b><pre><xsl:value-of select="../@location"/></pre></b></td> - <td><b><pre><xsl:value-of select="../@name"/></pre></b></td> - - <td> - <xsl:attribute name="STYLE">color: - <xsl:choose> - <xsl:when test="@priority[.='error']">red</xsl:when> - <xsl:when test="@priority[.='warn']">brown</xsl:when> - <xsl:when test="@priority[.='info']">gray</xsl:when> - <xsl:when test="@priority[.='debug']">gray</xsl:when> - </xsl:choose> - </xsl:attribute> - <pre><xsl:value-of select="text()"/></pre> - </td> - </tr> -</xsl:template> - -</xsl:stylesheet>
\ 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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -package org.apache.tools.ant; - -import java.io.*; -import java.util.*; - -/** - * Class for scanning a directory for files/directories that match a certain - * criteria. - * <p> - * 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. - * <p> - * 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. - * <p> - * 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. - * <p> - * 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 - * <code>File.separator</code> ('/' 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. - * <p> - * 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. - * <p> - * There are special case regarding the use of <code>File.separator</code>s at - * the beginningof the pattern and the string to match:<br> - * When a pattern starts with a <code>File.separator</code>, the string - * to match must also start with a <code>File.separator</code>. - * When a pattern does not start with a <code>File.separator</code>, the - * string to match may not start with a <code>File.separator</code>. - * When one of these rules is not obeyed, the string will not - * match. - * <p> - * 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. - * <p> - * Examples: - * <p> - * "**\*.class" matches all .class files/dirs in a directory tree. - * <p> - * "test\a??.java" matches all files/dirs which start with an 'a', then two - * more characters and then ".java", in a directory called test. - * <p> - * "**" matches everything in a directory tree. - * <p> - * "**\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"). - * <p> - * Example of usage: - * <pre> - * 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]); - * } - * </pre> - * 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 <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> - */ -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 <code>true</code> when the pattern matches against the string. - * <code>false</code> 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 <code>true</code> when the string matches against the pattern, - * <code>false</code> 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 - * <code>File.separatorChar</code>. So the separator used need not match - * <code>File.separatorChar</code>. - * - * @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 <code>File.separatorChar</code>. So the separator used need - * not match <code>File.separatorChar</code>. - * <p> - * 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 <code>File.separatorChar</code>. So the separator used need - * not match <code>File.separatorChar</code>. - * <p> - * 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 <code>true</code> when the name matches against at least one - * include pattern, <code>false</code> 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 <code>true</code> when the name matches against at least one - * exclude pattern, <code>false</code> 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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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. - * <p> - * 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 <file> use given file for log" + lSep); - msg.append(" -listener <classname> add an instance of class as a project listener" + lSep); - msg.append(" -buildfile <file> use given buildfile" + lSep); - msg.append(" -D<property>=<value> 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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ -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 - * <http://www.apache.org/>. - */ - -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. - * <p> - * 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 <em>new</em> 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 <em>new</em> 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. - <p> - 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 <a href="mailto:jon@clearink.com">jon@clearink.com</a> - */ - 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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -package org.apache.tools.ant; - -import java.util.*; - -/** - * This class implements a target object with required parameters. - * - * @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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("<?xml:stylesheet type=\"text/xsl\" href=\"log.xsl\"?>\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("</"); - out.write(element.getTagName()); - 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 - * <http://www.apache.org/>. - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.*; -import java.io.*; -import java.util.*; - -/** - * Call Ant in a sub-project - * - * <pre> - * <target name="foo" depends="init"> - * <ant antfile="build.xml" target="bar" > - * <property name="property1" value="aaaaa" /> - * <property name="foo" value="baz" /> - * </ant> - * </target> - * - * <target name="bar" depends="init"> - * <echo message="prop is ${property1} ${foo}" /> - * </target> - * </pre> - * - * - * @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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> - */ - -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 - * <http://www.apache.org/>. - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.*; - -import java.io.*; -import java.util.*; - -/** - * Copies a directory. - * - * @author James Davidson <a href="mailto:duncan@x180.com">duncan@x180.com</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ -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 <a href="mailto:tad1@cornell.edu">tad1@cornell.edu</a> - */ -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("<file> or <dir> attribute must be set!"); - } - - // old <delete> 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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a> - */ -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("</log:expand>", 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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ -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 - * <http://www.apache.org/>. - */ - -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. - * <p> - * This task can take the following arguments: - * <ul> - * <li>srcdir - * <li>destdir - * <li>include - * <li>exclude - * <li>cr - * <li>tab - * <li>eof - * </ul> - * Of these arguments, only <b>sourcedir</b> is required. - * <p> - * When this task executes, it will scan the srcdir based on the include - * and exclude properties. - * <p> - * <em>Warning:</em> 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 <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> - */ - -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. - * <ul><li>Unix: cr="remove" tab="asis" eof="remove" - * <li>DOS: cr="add" tab="asis" eof="asis"</ul> - */ - 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: - * <ul> - * <li>add: ensure that there is a CR before every LF - * <li>asis: leave CR characters alone - * <li>remove: remove all CR characters - * </ul> - */ - 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: - * <ul> - * <li>add: convert sequences of spaces which span a tab stop to tabs - * <li>asis: leave tab and space characters alone - * <li>remove: convert tabs to spaces - * </ul> - */ - 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: - * <ul> - * <li>add: ensure that there is an eof at the end of the file - * <li>asis: leave eof characters alone - * <li>remove: remove any eof character found at the end - * </ul> - */ - 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; k<count; k++) { - byte c = indata[k]; - if (c == '\r') cr++; - if (c == '\n') lf++; - if (c == '\t') tab++; - } - - // check for trailing eof - boolean eof = ((count>0) && (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; k<count; k++) { - switch (indata[k]) { - case (byte)' ': - // advance column - if (addtab == 0) outdata[o++]=(byte)' '; - col++; - break; - - case (byte)'\t': - if (addtab == 0) { - // treat like any other character - outdata[o++]=(byte)'\t'; - col++; - } else { - // advance column to next tab stop - col = (col|7)+1; - } - break; - - case (byte)'\r': - if (addcr == 0) { - // treat like any other character - outdata[o++]=(byte)'\r'; - col++; - } - break; - - case (byte)'\n': - // start a new line (optional CR followed by LF) - if (addcr == +1) outdata[o++]=(byte)'\r'; - outdata[o++]=(byte)'\n'; - line=o; - col=0; - break; - - default: - // add tabs if two or more spaces are required - if (addtab>0 && o+1<line+col) { - // determine logical column - int diff=o-line; - - // add tabs until this column would be passed - // note: the start of line is adjusted to match - while ((diff|7)<col) { - outdata[o++]=(byte)'\t'; - line-=7-(diff&7); - diff=o-line; - }; - }; - - // space out to desired column - while (o<line+col) outdata[o++]=(byte)' '; - - // append desired character - outdata[o++]=indata[k]; - col++; - } - } - - // add or remove an eof character as required - if (ctrlz == +1) { - if (outdata[o-1]!=0x1A) outdata[o++]=0x1A; - } else if (ctrlz == -1) { - if (o>2 && 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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:duncan@x180.com">duncan@x180.com</a> - * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 "<CODE>true</CODE>". - * - * @param v if "true" then be verbose - */ - public void setVerbose(String v) { - verbose = v; - } - - /** - * Don't stop if get fails if set to "<CODE>true</CODE>". - * - * @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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:duncan@x180.com">duncan@x180.com</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ -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 - * <http://www.apache.org/>. - */ - -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: - * <ul> - * <li>sourcedir - * <li>destdir - * <li>deprecation - * <li>classpath - * <li>bootclasspath - * <li>extdirs - * <li>optimize - * <li>debug - * <li>target - * </ul> - * Of these arguments, the <b>sourcedir</b> and <b>destdir</b> are required. - * <p> - * 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 <a href="mailto:duncan@x180.com">duncan@x180.com</a> - * @author Robin Green <a href="mailto:greenrd@hotmail.com">greenrd@hotmail.com</a> - */ - -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 - * <http://www.apache.org/>. - * - */ - -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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:jon@clearink.com">jon@clearink.com</a> - * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> - * @author Patrick Chanezon <a href="mailto:chanezon@netscape.com">chanezon@netscape.com</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:jon@clearink.com">jon@clearink.com</a> - */ -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: - <p> - name=value*name2=value - <p> - Names are case sensitive. - <p> - 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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:ajkuiper@wxs.nl">ajkuiper@wxs.nl</a> - * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> - * @author Sam Ruby <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> - * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a> - */ -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 <i>num</i> leading slashes - * from filenames. - * - * <p>patch's <i>-p</i> 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 - * <http://www.apache.org/>. - */ - -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 <rubys@us.ibm.com> - */ -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 - * <http://www.apache.org/>. - */ - -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 <code>on</code>, if an existing file should be replaced. - */ - public void setReplace(String replace) { - this.replace = project.toBoolean(replace); - } - - - /** - * Renames the file <code>src</code> to <code>dest</code> - * @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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ -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<srcs.length; i++) { - File file = new File(dir,srcs[i]); - processFile(file); - } - } - } - - /** - * Perform the replacement on the given file. - * - * The replacement is performed on a temporary file which then replaces the original file. - * - * @param src the source file - */ - private void processFile(File src) throws BuildException { - File temp = new File(src.getPath() + ".temp"); - - if (temp.exists()) { - throw new BuildException("Replace: temporary file " + temp.getPath() + " already exists"); - } - - try { - BufferedReader br = new BufferedReader(new FileReader(src)); - BufferedWriter bw = new BufferedWriter(new FileWriter(temp)); - - String line; - - while (true) { - line = br.readLine(); - if (line == null) break; - if (line.length() != 0) bw.write(replace(line)); - bw.newLine(); - } - - bw.flush(); - bw.close(); - br.close(); - - src.delete(); - temp.renameTo(src); - } catch (IOException ioe) { - ioe.printStackTrace(); - throw new BuildException(ioe); - } - } - - - /** - * Set the source file. - */ - public void setFile(String file) { - this.src = project.resolveFile(file); - } - - /** - * Set the source files path when using matching tasks. - */ - public void setDir(String dirName) { - dir = project.resolveFile(dirName); - } - - /** - * Set the string token to replace. - */ - public void setToken(String token) { - this.token = token; - } - - /** - * Set the string value to use as token replacement. - */ - public void setValue(String value) { - this.value = value; - } - - /** - * Perform the token substitution. - */ - private String replace (String orig) { - StringBuffer buffer = new StringBuffer(); - int start = 0, end = 0; - - while ((end = orig.indexOf(token, start)) > -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 - * <http://www.apache.org/>. - */ - -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: - * <ul> - * <li>base: The base directory for the compiled stubs and skeletons - * <li>class: The name of the class to generate the stubs from - * <li>stubVersion: The version of the stub prototol to use (1.1, 1.2, compat) - * <li>sourceBase: The base directory for the generated stubs and skeletons - * <li>classpath: Additional classpath, appended before the system classpath - * </ul> - * Of these arguments, the <b>base</b> and <b>class</b> are required. - * <p> - * - * @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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ - -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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. - * - * <p>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 <a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a> - */ -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 - * <http://www.apache.org/>. - */ - -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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:stefan.bodewig@megabit.net">stefan.bodewig@megabit.net</a> - */ -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 - * <http://www.apache.org/>. - */ - -package org.apache.tools.ant.taskdefs; - -import org.apache.tools.ant.*; - -/** - * - * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> - * @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 - * <http://www.apache.org/>. - */ - -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: - * <ul> - * <li>basedir - * <li>destdir - * <li>style - * <li>includes - * <li>excludes - * </ul> - * Of these arguments, the <b>sourcedir</b> and <b>destdir</b> are required. - * <p> - * 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 <a href="mailto:kvisco@exoffice.com">Keith Visco</a> - * @author <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> - * @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()); - } - } - } //-- </for> - } //-- 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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:duncan@x180.com">duncan@x180.com</a> - * @author Jon S. Stevens <a href="mailto:jon@clearink.com">jon@clearink.com</a> - */ - -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<files.length && upToDate; i++) - if (new File(baseDir,files[i]).lastModified() > - 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 - * <http://www.apache.org/>. - */ - -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: - * <ul> - * <li>binary</li> - * <li>classpath</li> - * <li>comments</li> - * <li>compile</li> - * <li>console</li> - * <li>crossref</li> - * <li>decimal</li> - * <li>destdir</li> - * <li>diag</li> - * <li>explicit</li> - * <li>format</li> - * <li>keep</li> - * <li>logo</li> - * <li>replace</li> - * <li>savelog</li> - * <li>srcdir</li> - * <li>sourcedir</li> - * <li>strictargs</li> - * <li>strictassign</li> - * <li>strictcase</li> - * <li>strictimport</li> - * <li>symbols</li> - * <li>time</li> - * <li>trace</li> - * <li>utf8</li> - * <li>verbose</li> - * </ul> - * Of these arguments, the <b>srcdir</b> argument is required. - * - * <p>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. - * <p>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: - * <ol> - * <li>The current directory, and,</li> - * <li>The directory the source is in (see sourcedir option) - * </ol> - * - * @author dIon Gillard <a href="mailto:dion@multitask.com.au">dion@multitask.com.au</a> - */ - -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, <b>not</b> .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. <code>aStringVar.getBytes</code> - * vs. <code>aStringVar.getBytes()</code> - * 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 - * <code>import</code> 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 <code>this</code> - * 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 - * <http://www.apache.org/>. - * - * Task to rename files based on extension. This task has the following - * properties which can be set: - * <ul> - * <li>fromExtension: </li> - * <li>toExtension: </li> - * <li>srcDir: </li> - * <li>replace: </li> - * </ul> - * - * @author dIon Gillard <a href="mailto:dion@multitask.com.au">dion@multitask.com.au</a> - * @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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:rubys@us.ibm.com">rubys@us.ibm.com</a> - */ -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<key.length(); i++) - isValid = Character.isJavaIdentifierPart(key.charAt(i)); - - if (isValid) beans.put(key, dictionary.get(key)); - } - } - - /** - * Do the work. - * - * @exception BuildException if someting goes wrong with the build - */ - public void execute() throws BuildException { - try { - addBeans(project.getProperties()); - addBeans(project.getUserProperties()); - addBeans(project.getTargets()); - addBeans(project.getReferences()); - - BSFManager manager = new BSFManager (); - - for (Enumeration e = beans.keys() ; e.hasMoreElements() ;) { - String key = (String)e.nextElement(); - Object value = beans.get(key); - manager.declareBean(key, value, value.getClass()); - } - - // execute the script - manager.exec(language, "<ANT>", 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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> - * @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 - * <http://www.apache.org/>. - */ - -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 <a href="mailto:rubys@us.ibm.com">Sam Ruby</a> - * @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 - * <http://www.apache.org/>. - */ - -/* - * 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. - * <p> - * You should never have a need to access this class directly. - * TarBuffers are created by Tar IO Streams. - * - * @author Timothy Gerard Endres <a href="mailto:time@ice.com">time@ice.com</a> - */ - -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 - * <http://www.apache.org/>. - */ - -/* - * 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 <a href="mailto:time@ice.com">time@ice.com</a> - * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ - -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 - * <http://www.apache.org/>. - */ - -/* - * 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. - * <p> - * 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. - * <p> - * 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. - * <p> - * 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. - * - * <p> - * The C structure for a Tar Entry's header is: - * <pre> - * 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; - * </pre> - * - * @author Timothy Gerard Endres <a href="mailto:time@ice.com">time@ice.com</a> - * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ - -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 - * <http://www.apache.org/>. - */ - -/* - * 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 <a href="mailto:time@ice.com">time@ice.com</a> - * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ -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 - * <http://www.apache.org/>. - */ - -/* - * 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 <a href="mailto:time@ice.com">time@ice.com</a> - */ -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() - * <B>MUST</B> 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 - * <http://www.apache.org/>. - */ - -/* - * 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 <a href="mailto:time@ice.com">time@ice.com</a> - * @author Stefano Mazzocchi <a href="mailto:stefano@apache.org">stefano@apache.org</a> - */ -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; - } -} |