From f0855dc2ad63dc096b1526c258ee77360a9f27ca Mon Sep 17 00:00:00 2001
From: No Author by Version 1.0.8.1 - 2000/06/28 Ant is a Java based build tool. In theory it is kind of like make without
-make's wrinkles. 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 stable version of Ant can be downloaded from http://jakarta.apache.org/builds/tomcat/release/v3.0/ant.zip.
-If you like living on the edge, you can download the latest version from http://jakarta.apache.org/builds/tomcat/nightly/ant.zip. If you prefer the source edition, you can download Ant from http://jakarta.apache.org/builds/tomcat/release/v3.0/src/jakarta-tools.src.zip
-(latest stable) or from http://jakarta.apache.org/from-cvs/jakarta-ant/
-(current). See the section Building Ant on how to
-build Ant from the source code.
- To build and use ant you must have a JAXP compilant XML parser installed and available on your classpath.
-
- If you do not have a JAXP compliant XML parse installed, you may use the reference implementation
- available from Sun. It is available from http://java.sun.com/xml.
- Once installed make sure the "jaxp.jar" and "parser.jar" files are in your classpath.
-
- You will also need the JDK installed on your system, version 1.1 or later.
-
- Go to the directory Make sure the JDK is in you path. Run When finished, use for Windows, and for UNIX, to create a binary distribution of Ant. This distribution can be
-found in the directory you specified. The binary distribution of Ant consists of three directories: Assume Ant is installed in Assume Ant is installed in There are lots of variants that can be used to run Ant. What you need is at
-least the following: The classpath for Ant must contain When you need JDK functionality (like a javac task, or a
-rmic task), then for JDK 1.1, the When you are executing platform specific applications (like the exec task, or the cvs task), the property Running Ant is simple, when you installed it as described in the previous
-section. Just type When nothing is specified, Ant looks for a You can also set properties which override properties specified in the
-buildfile (see the property task).
-This can be done with the -D<property>=<value>
-option, where <property> is the name of the property and <value>
-the value. To more options are -quiet which instructs Ant to print less
-information on the console when running. The option -verbose on the other
-hand makes Ant print more information on the console. It is also possible to specify the target that should be executed. Default
-the target that is mentioned in the default attribute of the project is
-used. This can be overridden by adding the target name to the end of the
-commandline. Commandline option summary: runs Ant using the runs Ant using the runs Ant using the runs Ant using the When you have installed Ant in the do-it-yourself way, Ant can be started
-with: These instructions actually do exactly the same as the The buildfile is written in XML. Each buildfile contains one project. A project has three attributes: 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. A target can depend on other targets. You might have a target for compiling,
-for instance, and a target for creating a distributable. You can only build a
-distributable when you have compiled first, so the distribute target depends on
-the compile target. Ant resolves all these dependencies. Ant tries to execute the targets in the depends attribute in the order
-they appear (from left to right). Keep in mind that it is possible that a target
-can get executed earlier when an earlier target depends on it: Suppose we want to execute target D. From its depends attribute, you
-might think that first target C, then B and then A is executed. Wrong! C depends
-on B, and B depends on A, so first A is executed, then B, then C, and finally D. A target gets executed only once. Even when more targets depend on it (see
-the previous example). A target has also the ability to perform its execution if a property has been
-set. This allows, for example, better control on the building process depending
-on the state of the system (java version, OS, command line properties, etc...).
-To make target sense this property you should add the if attribute
-with the name of the property that the target should react to, for example If no if attribute is present, the target will always be executed. It is a good practice to place your property and tstamp tasks in a so called initialization target, on which
-all other targets depend. Make sure that that target is always the first one in
-the depends list of the other targets. In this manual, most initialization targets
-have the name "init". A target has the following attributes: A task is a piece of code that can be executed. A task can have multiple attributes (or arguments if you prefer). The value
-of an attribute might contain references to a property. These references will be
-resolved before the task is executed. Tasks have a common structure: where name is the name of the task, attribute-x the attribute name, and
-value-x the value of this attribute. There is a set of built in tasks, but it is also very
-easy to write your own. A project can have a set of properties. These might be set in the buildfile
-by the property task, or might be set outside Ant. A
-property has a name and a value. Properties might be used in in the value of
-task attributes. This is done by placing the property name between
-"${" and "}" in the attribute value. If there is a property called "builddir" with the value
-"build", then this could be used in an attribute like this: "${builddir}/classes".
-This is resolved as "build/classes". A project can have a set of tokens that might be automatically expanded if
-found when a file is copied, when the filtering-copy behavior is selected in the
-tasks that support this. These might be set in the buildfile
-by the filter task. Since this can be a very harmful behavior, the tokens in the files must
-be of the form @token@ where token is the token name that is set
-in the filter task. This token syntax matches the syntax of other build systems
-that perform such filtering and remains sufficiently orthogonal to most
-programming and scripting languages, as well with documentation systems. Note: in case a token with the format @token@ if found in a file but no
-filter is associated with that token, no changes take place. So, no escaping
-method is present, but as long as you choose appropriate names for your tokens,
-this should not cause problems. Some tasks use directory trees for the task they perform. For instance, the Javac task which works upon a directory tree with .java files.
-Sometimes it can be very useful to work on a subset of that directory tree. This
-section describes how you can select a subset of such a directory tree. Ant gives you two ways to create a subset, both of which can be used at the same
-time: When both inclusion and exclusion are used, only files/directories that match
-the include patterns, and don't match the exclude patterns are used. Patterns can be specified inside the buildfile via task attributes or
-nested elements and via external files. Each line of the external file
-is taken as pattern that is added to the list of include or exclude
-patterns. As described earlier, patterns are used for the inclusion and exclusion.
-These patterns look very much like the patterns used in DOS and UNIX: '*' matches zero or more characters, '?' matches one character. Examples: '*.java' matches '.java', 'x.java' and 'FooBar.java', but not 'FooBar.xml'
-(does not end with '.java'). '?.java' matches 'x.java', 'A.java', but not '.java' or 'xyz.java' (both
-don't have one character before '.java'). Combinations of '*'s and '?'s are allowed. Matching is done per-directory. This means that first the first directory in
-the pattern is matched against the first directory in the path to match. Then
-the second directories are matched, and so on. E.g. when we have the pattern '/?abc/*/*.java'
-and the path '/xabc/foobar/test.java', then first '?abc' is matched with 'xabc',
-then '*' is matched with 'foobar' and finally '*.java' is matched with 'test.java'.
-They all match so the path matches the pattern. Too make things a bit more flexible, we add one extra feature, which makes it
-possible to match multiple directory levels. This can be used to match a
-complete directory tree, or a file anywhere in the directory tree. To do this, '**'
-must be used as the name of a directory. When '**' is used as the name of a
-directory in the pattern, it matches zero or more directories. For instance:
-'/test/**' matches all files/directories under '/test/', such as '/test/x.java',
-or '/test/foo/bar/xyz.html', but not '/xyz.xml'. There is one "shorthand", if a pattern ends with '/' or '\', then '**'
-is appended. E.g. "mypackage/test/" is interpreted as were it "mypackage/test/**". Examples: Matches: CVS/Repository But not: org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match) Matches: org/apache/jakarta/tools/ant/docs/index.html But not: org/apache/xyz.java ('jakarta'/' part is missing) Matches: org/apache/CVS/Entries But not: org/apache/CVS/foo/bar/Entries ('foo/bar/' part does not match) When these patterns are used in inclusion and exclusion, you have a powerful
-way to select just the files you want. This copies all files in directories called "images", that are
-located in the directory tree "${src}" to the destination "${dist}",
-but excludes all "*.gif" files from the copy. This example can also be expressed using nested elements as
- There are a set of definitions which are excluded by default from all directory based tasks.
-They are:
-Ant User Manual
-
-
-
-
-Table of Contents
-
-
-
-
-Introduction
-Why?
-
-Getting Ant
-Binary edition
-Source edition
-
-System Requirements
-
-Building Ant
-jakarta-ant.bootstrap.bat (Windows) or bootstrap.sh (UNIX)
-to build a bootstrap version of Ant.
-
-build.bat -Dant.dist.dir=<directory to install Ant> dist
-
-build.sh -Dant.dist.dir=<directory to install Ant> dist
-Installing Ant
-bin,
-docs and lib. Only the bin and lib
-directory are crucial for running Ant. To run Ant, the following must be done:
-
-bin directory to your path.bin and lib directory.Windows
-c:\ant\. The following sets up the
-environment:set ANT_HOME=c:\ant
-set JAVA_HOME=c:\jdk1.2.2
-set PATH=%PATH%;%ANT_HOME%\bin
-Unix (bash)
-/usr/local/ant. The following sets up
-the environment:export ANT_HOME=/usr/local/ant
-export JAVA_HOME=/usr/local/jdk-1.2.2
-export PATH=${PATH}:${ANT_HOME}/bin
-Advanced
-ant.jar and any jars/classes
-needed for your chosen JAXP compliant XML parser.classes.zip
-file of the JDK must be added to the classpath; for JDK 1.2, tools.jar
-must be added. The scripts supplied with ant, in the bin directory, will add
-tools.jar automatically if the JAVA_HOME environment variable is set.ant.home
-must be set to the directory containing a bin directory, which contains the antRun shell script necessary to run execs on Unix.
-Running Ant
-ant.build.xml file in the
-current directory. When found, it uses that file as a buildfile. To make Ant use
-another buildfile, use the commandline option -buildfile <file>,
-where <file> is the buildfile you want to use.ant [options] [target]
-Options:
--help print this message
--version print the version information and exit
--quiet be extra quiet
--verbose be extra verbose
--logfile <file> use given file for log
--listener <classname> add an instance of class as a project listener
--buildfile <file> use given buildfile
--D<property>=<value> use value for given property
-Examples
-
-
-ant
-build.xml file in the current directory, on
-the default target.
-
-ant -buildfile test.xml
-test.xml file in the current directory, on
-the default target.
-
-ant -buildfile test.xml dist
-test.xml file in the current directory, on a
-target called dist.
-
-ant -buildfile test.xml -Dbuild=build/classes dist
-test.xml file in the current directory, on a
-target called dist. It also sets the build property to the
-value build/classes.Running Ant by hand
-
-
-
-java -Dant.home=c:\ant org.apache.tools.ant.Main [options] [target]
-ant
-command. The options and target are the same as when running Ant with the ant
-command. This example assumes you have set up your classpath to include
-
-
-
-Writing a simple buildfile
-Projects
-
-
-
-
- Attribute
- Description
- Required
-
-
- name
- the name of the project.
- Yes
-
-
- default
- the default target to use when no target is supplied.
- Yes
-
-
-basedir
- 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.
- Yes
- Targets
-
-
-<target name="A"/>
-<target name="B" depends="A"/>
-<target name="C" depends="B"/>
-<target name="D" depends="C,B,A"/>
-
-
-<target name="build-module-A" if="module-A-present"/>
-
-
-
-
- Attribute
- Description
- Required
-
-
- name
- the name of the project.
- Yes
-
-
- depends
- a comma separated list of names of targets on which this
- target depends.
- No
-
-
-if
- the name of the property that must be set in order for this
- target to execute.
- No
- Tasks
-
-
-<name attribute1="value1" attribute2="value2" ... />
-Properties
-Token Filters
-Examples
-
-
-
-<project name="foo" default="dist" basedir=".">
- <target name="init">
- <tstamp/>
- <property name="build" value="build" />
- <property name="dist" value="dist" />
- <filter token="version" value="1.0.3" />
- <filter token="year" value="2000" />
- </target>
-
- <target name="prepare" depends="init">
- <mkdir dir="${build}" />
- </target>
-
- <target name="compile" depends="prepare">
- <javac srcdir="${src}" destdir="${build}" filtering="on"/>
- </target>
-
- <target name="dist" depends="compile">
- <mkdir dir="${dist}/lib" />
- <jar jarfile="${dist}/lib/foo${DSTAMP}.jar"
- basedir="${build}" items="com"/>
- </target>
-
- <target name="clean" depends="init">
- <deltree dir="${build}" />
- <deltree dir="${dist}" />
- </target>
-</project>
-
-
-Directory based tasks
-
-
-Patterns
-
-
-
-
- **/CVS/*
- Matches all files in CVS directories, that can be located
- anywhere in the directory tree.
-
-
- org/apache/CVS/Entries
- org/apache/jakarta/tools/ant/CVS/Entries
-
- org/apache/jakarta/**
- Matches all files in the org/apache/jakarta directory tree.
-
-
- org/apache/jakarta/test.xml
-
- org/apache/**/CVS/*
- Matches all files in CVS directories, that are located
- anywhere in the directory tree under org/apache.
-
-
- org/apache/jakarta/tools/ant/CVS/Entries
-
-**/test/**
- Matches all files which have a directory 'test' in their
- path, including 'test' as a filename.
- Examples
- <copydir src="${src}"
- dest="${dist}"
- includes="**/images/*"
- excludes="**/*.gif" />
- <copydir src="${src}"
- dest="${dist}">
- <include name="**/images/*"/>
- <exclude name="**/*.gif" />
- </copydir>
-
-
-Default Excludes
- "**/*~",
- "**/#*#",
- "**/%*%",
- "**/CVS",
- "**/CVS/*",
- "**/.cvsignore"
-
-If you do not want these default excludes applied, you may disable them with the
-defaultexcludes="no" attribute.
Runs Ant on a supplied buildfile. This can be used to build subprojects.
-When the antfile attribute is omitted, the file "build.xml" -in the supplied directory (dir attribute) is used.
-If no target attribute is supplied, the default target of the new project is -used.
-The properties of the current project will be available in the new project. -These properties will override the properties that are set in the new project. -(See also the properties task).
-| Attribute | -Description | -Required | -
| antfile | -the buildfile to use. | -No | -
| dir | -the directory to use as a basedir for the new Ant project. | -Yes | -
| target | -the target of the new Ant project that should be executed. | -No | -
| output | -Filename to write the ant output to. - | -No | -
---
<ant antfile="subproject/subbuild.xml" dir="subproject" - target="compile" />-
<ant dir="subproject" />
Sets a property if a resource is available at runtime. This resource can be a -file resource, a class in classpath or a JVM system resource.
-The value part of the properties being set is true if the resource is -present, otherwise, the property is not set.
-Normally, this task is used to set properties that are useful to avoid target -execution depending on system parameters.
-| Attribute | -Description | -Required | -
| property | -the name of the property to set. | -Yes | -
| classname | -the class to look for in classpath. | -Yes | -
| resource | -the resource to look for in the JVM | -|
| file | -the file to look for. | -
<available classname="org.whatever.Myclass" property="Myclass.present" />-
sets the property Myclass.present to the value "true"
-if the org.whatever.Myclass is found in Ant's classpath.
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.
-| Attribute | -Description | -Required | -
| src | -the file of which the permissions must be changed. | -Yes | -
| perm | -the new permissions. | -Yes | -
---
<chmod src="${dist}/start.sh" perm="ugo+rx" - />
makes the "start.sh" file readable and executable for anyone on a -UNIX system.
-Copies a directory tree from the source to the destination.
-It is possible to refine the set of files that are being copied. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the src directory.
-The ignore attribute contains the names of the files/directories that -must be excluded from the copy. The names specified in the ignore -attribute are just names, they do not contain any path information! Note that -this attribute has been replaced by the excludes attribute.
-| Attribute | -Description | -Required | -
| src | -the directory to copy. | -Yes | -
| dest | -the directory to copy to. | -Yes | -
| ignore | -comma separated list of filenames/directorynames to ignore. - No files (except default excludes) are excluded when omitted. (deprecated, - use excludes instead). | -No | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
| filtering | -indicates whether token filtering should take place during - the copy | -No | -
| forceoverwrite | -overwrite existing files even if the destination - files are newer (default is false). | -No | -
<copydir src="${src}/resources"
- dest="${dist}"
- />
-copies the directory ${src}/resources to ${dist}.
<copydir src="${src}/resources"
- dest="${dist}"
- includes="**/*.java"
- excludes="**/Test.java"
- />
-copies the directory ${src}/resources to ${dist}
-recursively. All java files are copied, except for files with the name Test.java.
<copydir src="${src}/resources"
- dest="${dist}"
- includes="**/*.java"
- excludes="mypackage/test/**" />
-copies the directory ${src}/resources to ${dist}
-recursively. All java files are copied, except for the files under the mypackage/test
-directory.
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.
-| Attribute | -Description | -Required | -
| src | -the filename of the file to copy. | -Yes | -
| dest | -the filename of the file where to copy to. | -Yes | -
| filtering | -indicates whether token filtering should take place during - the copy | -No | -
---
<copyfile src="test.java" dest="subdir/test.java" - />-
<copyfile src="${src}/index.html" dest="${dist}/help/index.html" - />
Handles packages/modules retrieved from a -CVS repository.
-When doing automated builds, the get task should be -preferred over the checkout command, because of speed.
-| Attribute | -Description | -Required | -
| command | -the CVS command to execute. | -No, default "checkout" | -
| cvsRoot | -the CVSROOT variable. | -No | -
| dest | -the directory where the checked out files should be placed. | -Yes | -
| package | -the package/module to check out. | -No | -
| tag | -the tag of the package/module to check out. | -No | -
| date | -Use the most recent revision no later than the given date | -No | -
| quiet | -supress informational messages. | -No, default "false" | -
| noexec | -report only, don't change any files. | -No, default "false" | -
<cvs cvsRoot=":pserver:anoncvs@jakarta.apache.org:/home/cvspublic"
- package="jakarta-tools"
- dest="${ws.dir}"
- />
-checks out the package/module "jakarta-tools" from the CVS -repository pointed to by the cvsRoot attribute, and stores the files in "${ws.dir}".
- <cvs dest="${ws.dir}" command="update" />
-updates the package/module that has previously been checked out into -"${ws.dir}".
-Deletes either a single file or -all files in a specified directory and its sub-directories.
-It is possible to refine the set of files that are being deleted. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included in the deletion process by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded from the deletion process. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the dir directory.
-| Attribute | -Description | -Required | -
| file | -The file to delete. | -at least one of the two | -
| dir | -The directory to delete files from. | -|
| includes | -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. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -Comma separated list of patterns of files that must be - excluded from the deletion list. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -Indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
| verbose | -Show name of each deleted file ("true"/"false"). Default is "false" when omitted. | -No | -
<delete file="/lib/ant.jar" />-
deletes the file /lib/ant.jar.
<delete dir="lib" />-
deletes all files in the /lib directory.
<delete dir="." - include="**/*.bak" - /> --
deletes all files with the extension ".bak" from the current directory
-and any sub-directories.
Deletes a directory with all its files and subdirectories.
-| Attribute | -Description | -Required | -
| dir | -the directory to delete. | -Yes | -
<deltree dir="dist" />-
deletes the directory dist, including its files and
-subdirectories.
<deltree dir="${dist}" />
-deletes the directory ${dist}, including its files and
-subdirectories.
Echoes a message to System.out.
-| Attribute | -Description | -Required | -
| message | -the message to echo. | -Yes | -
<echo message="Hello world" />-
Executes a system command. When the os attribute is specified, then -the command is only executed when Ant is run on one of the specified operating -systems.
-| Attribute | -Description | -Required | -
| command | -the command to execute. | -Yes | -
| dir | -the directory in which the command should be executed. | -Yes | -
| os | -list of Operating Systems on which the command may be - executed. | -No | -
| output | -the file to which the output of the command should be - redirected. | -Yes | -
---
<exec dir="${src}" command="dir" os="windows" - output="dir.txt" />
Unzips a zipfile.
-For JDK 1.1 "last modified time" field is set to current time instead of being -carried from zipfile.
-| Attribute | -Description | -Required | -
| src | -zipfile to expand. | -Yes | -
| dest | -directory where to store the expanded files. | -Yes | -
---
<expand src="${tomcat_src}/tools-src.zip" dest="${tools.home}" - />
Sets a token filter for this project. Token filters are used by all tasks -that perform file copying operations through the Project commodity methods.
-Note: the token string must not contain the separators chars (@).
-| Attribute | -Description | -Required | -
| token | -the token string without @ | -Yes | -
| value | -the string that should be put to replace the token when the - file is copied | -Yes | -
<filter token="year" value="2000" />
- <copydir src="${src.dir}" dest="${dest.dir}"/>
-will copy recursively all the files from the src.dir directory into -the dest.dir directory replacing all the occurencies of the string @year@ -with 2000.
-Adjusts a text file to local.
-It is possible to refine the set of files that are being adjusted. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the src directory.
-| Attribute | -Description | -Required | -
| srcDir | -Where to find the files to be fixed up. | -Yes | -
| destDir | -Where to place the corrected files. Defaults to - srcDir (replacing the original file) | -No | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
| cr | -Specifies how carriage return (CR) characters are to
- be handled. Valid values for this property are:
-
- Note: Unless this property is specified as "asis", extra CR characters - which do not preceed a LF will be removed. - |
- No | -
| tab | -Specifies how tab characters are to be handled. Valid
- values for this property are:
-
- Note: Unless this property is specified as "asis", extra spaces and - tabs after the last non-whitespace character on the line will be removed. - |
- No | -
| eof | -Specifies how DOS end of file (control-Z) characters are
- to be handled. Valid values for this property are:
-
|
- No | -
<fixcrlf srcdir="${src}"
- cr="remove" eof="remove"
- includes="**/*.sh"
- />
-Removes carriage return and eof characters from the shell scripts. Tabs and -spaces are left as is. -
<fixcrlf srcdir="${src}"
- cr="add"
- includes="**/*.bat"
- />
-Ensures that there are carriage return characters prior to evey line feed. -Tabs and spaces are left as is. -EOF characters are left alone if run on -DOS systems, and are removed if run on Unix systems.
- <fixcrlf srcdir="${src}"
- tabs="add"
- includes="**/Makefile"
- />
-Adds or removes CR characters to match local OS conventions, and -converts spaces to tabs when appropriate. EOF characters are left alone if -run on DOS systems, and are removed if run on Unix systems. -Many versions of make require tabs prior to commands.
- <fixcrlf srcdir="${src}"
- tabs="remove"
- includes="**/README*"
- />
-Adds or removes CR characters to match local OS conventions, and -converts all tabs to spaces. EOF characters are left alone if run on -DOS systems, and are removed if run on Unix systems. -You never know what editor a user will use to browse README's.
-Gets a file from an URL. When the verbose option is "on", this task -displays a '.' for every 100 Kb retrieved.
-This task should be preferred above the CVS task when -doing automated builds. CVS is significant slower than loading a compressed -archive with http/ftp.
-| Attribute | -Description | -Required | -
| src | -the URL from which to retrieve a file. | -Yes | -
| dest | -the file where to store the retrieved file. | -Yes | -
| verbose | -show verbose information ("on"/"off"). | -No | -
| ignoreerrors | -Log errors but don't treat as fatal. | -No | -
<get src="http://jakarta.apache.org/" dest="help/index.html" />-
gets the index page of http://jakarta.apache.org/, and stores it in the file help/index.html.
Expands a GZip file.
- -If dest is a directory the name of the destination file is -the same as src (with the ".gz" extension removed if -present). If dest is ommited, the parent dir of src is -taken. The file is only expanded if the source file is newer than the -destination file, or when the destination file does not exist.
- -| Attribute | -Description | -Required | -
| src | -the file to expand. | -Yes | -
| dest | -the destination file or directory. | -No | -
---
<gunzip src="test.tar.gz"/>
expands test.tar.gz to test.tar
----
<gunzip src="test.tar.gz" dest="test2.tar"/>
expands test.tar.gz to test2.tar
----
<gunzip src="test.tar.gz" dest="subdir"/>
expands test.tar.gz to subdir/test.tar (assuming -subdir is a directory).
- -GZips a file.
-| Attribute | -Description | -Required | -
| src | -the file to gzip. | -Yes | -
| zipfile | -the destination file. | -Yes | -
---
<gzip src="test.tar" zipfile="test.tar.gz" - />
Jars a set of files.
-The basedir attribute is the reference directory from where to jar.
-It is possible to refine the set of files that are being jarred. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the basedir directory.
-The includes, excludes and defaultexcludes attributes -replace the items and ignore attributes. The following explains -how the deprecated items and ignore attribute behave.
-When "*" is used for items, all files in the basedir, and -its subdirectories, will be jarred. Otherwise all the files and directories -mentioned in the items list will jarred. When a directory is specified, then all -files within it are also jarred.
-With the ignore attribute, you can specify files or directories to -ignore. These files will not be jarred. The items in the ignore attribute -override the items in the items attribute. The names specified in the ignore -attribute are just names, they do not contain any path information!
-| Attribute | -Description | -Required | -
| jarfile | -the jar-file to create. | -Yes | -
| basedir | -the directory from which to jar the files. | -Yes | -
| compress | -Not only store data but also compress them, defaults to true | -No | -
| items | -a comma separated list of the files/directories to jar. All - files are included when omitted. (deprecated, use includes - instead). | -No | -
| ignore | -comma separated list of filenames/directorynames to exclude - from the jar. No files (except default excludes) are excluded when - omitted. (deprecated, use excludes instead). | -No | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
| manifest | -the manifest file to use. | -No | -
<jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" />
-jars all files in the ${build}/classes directory in a file
-called app.jar in the ${dist}/lib directory.
<jar jarfile="${dist}/lib/app.jar"
- basedir="${build}/classes"
- excludes="**/Test.class"
- />
-jars all files in the ${build}/classes directory in a file
-called app.jar in the ${dist}/lib directory. Files
-with the name Test.class are excluded.
<jar jarfile="${dist}/lib/app.jar"
- basedir="${build}/classes"
- includes="mypackage/test/**"
- excludes="**/Test.class"
- />
-jars all files in the ${build}/classes directory in a file
-called app.jar in the ${dist}/lib directory. Only
-files under the directory mypackage/test are used, and files with
-the name Test.class are excluded.
<jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" items="*" />
-jars all files in the ${build}/classes directory in a file
-called app.jar in the ${dist}/lib directory.
<jar jarfile="${dist}/lib/app.jar" basedir="${build}/classes" items="*" ignore="Test.class" />
-jars all files in the ${build}/classes directory in a file
-called app.jar in the ${dist}/lib directory.
-Files/directories with the name Test.class are excluded.
Executes a Java class within the running (Ant) VM or forks another VM if -specified.
-Be careful that the executed class doesn't call System.exit(), because it -will terminate the VM and thus Ant. In case this happens, it's highly suggested -that you set the fork attribute so that System.exit() stops the other VM and not -the one that is currently running Ant.
-| Attribute | -Description | -Required | -
| classname | -the Java class to execute. | -Yes | -
| args | -the arguments for the class that is executed. | -No | -
| classpath | -the classpath to use. | -No | -
| fork | -if enabled triggers the class execution in another VM - (disabled by default) | -No | -
| jvm | -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. - | -No | -
| jvmargs | -the arguments to pass to the forked VM (ignored if fork is - disabled) | -No | -
<java classname="test.Main" />-
<java classname="test.Main" args="-h" />-
<java classname="test.Main" - args="-h" - fork="yes" - jvmargs="-Xrunhprof:cpu=samples,file=log.txt,depth=3" - />-
Compiles a source tree within the running (Ant) VM.
-The source and destination directory will be recursively scanned for Java -source files to compile. Only Java files that have no corresponding class file -or where the class file is older than the java file will be compiled.
-Files in the source tree, that are no java files, are copied to the -destination directory, allowing support files to be located properly in the -classpath.
-The directory structure of the source tree should follow the package -hierarchy.
-It is possible to refine the set of files that are being compiled/copied. -This can be done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the srcdir directory.
-It is possible to use different compilers. This can be selected with the -"build.compiler" property. There are three choices:
-For JDK 1.1/1.2 is classic the default. For JDK 1.3 is modern the default.
-| Attribute | -Description | -Required | -
| srcdir | -location of the java files. | -Yes | -
| destdir | -location where to store the class files. | -Yes | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
| classpath | -the classpath to use. | -No | -
| bootclasspath | -location of bootstrap class files. | -No | -
| extdirs | -location of installed extensions. | -No | -
| debug | -indicates whether there should be compiled with debug - information ("on"). | -No | -
| optimize | -indicates whether there should be compiled with - optimization ("on"). | -No | -
| deprecation | -indicates whether there should be compiled with deprecation - information ("on"). | -No | -
| filtering | -indicates whether token filtering should take place | -No | -
| target | -Generate class files for specific VM version, e.g. "1.1" or "1.2". | -No | -
<javac srcdir="${src}"
- destdir="${build}"
- classpath="xyz.jar"
- debug="on"
- />
-compiles all .java files under the directory ${src}, and stores
-the .class files in the directory ${build}. It also copies the non-java
-files from the tree under ${src} to the tree under ${build}.
-The classpath used contains xyz.jar, and debug information is on.
<javac srcdir="${src}"
- destdir="${build}"
- includes="mypackage/p1/**,mypackage/p2/**"
- excludes="mypackage/p1/testpackage/**"
- classpath="xyz.jar"
- debug="on"
- />
-compiles .java files under the directory ${src}, and stores the
-.class files in the directory ${build}. It also copies the non-java
-files from the tree under ${src} to the tree under ${build}.
-The classpath used contains xyz.jar, and debug information is on.
-Only files under mypackage/p1 and mypackage/p2 are
-used. Files in the mypackage/p1/testpackage directory are excluded
-form compilation and copy.
Generates code documentation using the javadoc tool.
-The source directory will be recursively scanned for Java source files to process -but only those matching the inclusion rules will be passed to the javadoc tool. This -allows wildcards to be used to choose between package names, reducing verbosity -and management costs over time. This task, however, has no notion of -"changed" files, unlike the javac task. This means -all packages will be processed each time this task is run. In general, however, -this task is used much less frequently.
-This task works seamlessly between different javadoc versions (1.1 and 1.2), -with the obvious restriction that the 1.2 attributes will be ignored if run in a -1.1 VM.
-NOTE: since javadoc calls System.exit(), javadoc cannot be run inside the -same VM as ant without breaking functionality. For this reason, this task -always forks the VM. This overhead is not significant since javadoc is normally a heavy -application and will be called infrequently.
-NOTE: the packagelist attribute allows you to specify the list of packages to -document outside of the Ant file. It's a much better practice to include everything -inside the build.xml file. This option was added in order to make it easier to -migrate from regular makefiles, where you would use this option of javadoc. -The packages listed in packagelist are not checked, so the task performs even -if some packages are missing or broken. Use this option if you wish to convert from -an existing makefile. Once things are running you should then switch to the regular -notation. - -
DEPRECATION: the javadoc2 task simply points to the javadoc task and it's -there for back compatibility reasons. Since this task will be removed in future -versions, you are strongly encouraged to use javadoc -instead.
-| Attribute | -Description | -Availability | -Required | -
| sourcepath | -Specify where to find source files | -all | -Yes | -
| destdir | -Destination directory for output files | -all | -Yes | -
| maxmemory | -Max amount of memory to allocate to the javadoc VM | -all | -No | -
| sourcefiles | -Space separated list of source files | -all | -at least one of the two | -
| packagenames | -Space separated list of package files (with terminating - wildcard) | -all | -|
| packageList | -The name of a file containing the packages to process | -all | -No | -
| classpath | -Specify where to find user class files | -all | -No | -
| Bootclasspath | -Override location of class files loaded by the bootstrap - class loader | -1.2 | -No | -
| Extdirs | -Override location of installed extensions | -1.2 | -No | -
| Overview | -Read overview documentation from HTML file | -1.2 | -No | -
| Public | -Show only public classes and members | -all | -No | -
| Protected | -Show protected/public classes and members (default) | -all | -No | -
| Package | -Show package/protected/public classes and members | -all | -No | -
| Private | -Show all classes and members | -all | -No | -
| Old | -Generate output using JDK 1.1 emulating doclet | -1.2 | -No | -
| Verbose | -Output messages about what Javadoc is doing | -1.2 | -No | -
| Locale | -Locale to be used, e.g. en_US or en_US_WIN | -1.2 | -No | -
| Encoding | -Source file encoding name | -all | -No | -
| Version | -Include @version paragraphs | -all | -No | -
| Use | -Create class and package usage pages | -1.2 | -No | -
| Author | -Include @author paragraphs | -all | -No | -
| Splitindex | -Split index into one file per letter | -1.2 | -No | -
| Windowtitle | -Browser window title for the documenation (text) | -1.2 | -No | -
| Doctitle | -Include title for the package index(first) page (html-code) | -1.2 | -No | -
| Header | -Include header text for each page (html-code) | -1.2 | -No | -
| Footer | -Include footer text for each page (html-code) | -1.2 | -No | -
| bottom | -Include bottom text for each page (html-code) | -1.2 | -No | -
| link | -Create links to javadoc output at the given URL | -1.2 | -No | -
| linkoffline | -Link to docs at <url> using package list at - <url2> | -1.2 | -No | -
| group | -Group specified packages together in overview page | -1.2 | -No | -
| nodeprecated | -Do not include @deprecated information | -all | -No | -
| nodeprecatedlist | -Do not generate deprecated list | -1.2 | -No | -
| notree | -Do not generate class hierarchy | -all | -No | -
| noindex | -Do not generate index | -all | -No | -
| nohelp | -Do not generate help link | -1.2 | -No | -
| nonavbar | -Do not generate navigation bar | -1.2 | -No | -
| serialwarn | -FUTURE: Generate warning about @serial tag | -1.2 | -No | -
| helpfile | -FUTURE: Specifies the HTML help file to use | -1.2 | -No | -
| stylesheetfile | -Specifies the CSS stylesheet to use | -1.2 | -No | -
| charset | -FUTURE: Charset for cross-platform viewing of generated - documentation | -1.2 | -No | -
| docencoding | -Output file encoding name | -1.1 | -No | -
| doclet | -Specifies the class file that starts the doclet used in generating the documentation. | -1.2 | -No | -
| docletpath | -Specifies the path to the doclet class file that is specified with the -doclet option. | -1.2 | -No | -
| additionalparam | -Lets you add additional parameters to the javadoc command line. Useful for doclets | -1.2 | -No | -
| Attribute | -Description | -Required | -
| href | -The URL for the external documentation you wish to link to | -Yes | -
| offline | -True if this link is not available online at the time of - generating the documentation | -No | -
| packagelistLoc | -The location to the directory containing the package-list file for - the external documentation | -Only if the offline attribute is true | -
| Attribute | -Description | -Required | -
| title | -Title of the group | -Yes | -
| packages | -List of packages to include in that group | -Yes | -
<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 © 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>- -
Performs keyword substitution in the source file, and writes the result to -the destination file.
-Keys in the source file are of the form ${keyname}. The keys attribute -contains key/value pairs. When a key is found in the keys attribute, then -"${keyname}" is replaced by the corresponding value.
-The keys attribute is of the form -"name1=value1*name2=value2*name3=value3". The '*' is called the -separator, which might we changed with the sep attribute.
-Note: the source file and destination file may not be the same.
-| Attribute | -Description | -Required | -
| src | -the source file. | -Yes | -
| dest | -the destination file. | -Yes | -
| sep | -the separator for the name/value pairs. | -No | -
| keys | -name/value pairs for replacement. | -Yes | -
<keysubst src="abc.txt" dest="def.txt" keys="VERSION=1.0.3*DATE=2000-01-10" />-
Creates a directory. Also non-existent parent directories are created, when -necessary.
-| Attribute | -Description | -Required | -
| dir | -the directory to create. | -Yes | -
<mkdir dir="${dist}" />
-creates a directory ${dist}.
<mkdir dir="${dist}/lib" />
-creates a directory ${dist}/lib.
Applies a diff file to originals. -
| Attribute | -Description | -Required | -
| dir | -the directory in which the command should be executed. | -Yes | -
| os | -list of Operating Systems on which the command may be - executed. | -No | -
| output | -the file to which the output of the patch command - should be redirected. | -No | -
| patchfile | -the file that includes the diff output | -Yes | -
| originalfile | -the file to patch | -No, tries to guess it from the diff - file | -
| backups | -Keep backups of the unpatched files | -No | -
| quiet | -Work silently unless an error occurs | -No | -
| reverse | -Assume patch was created with old and new files - swapped. | -No | -
| ignorewhitespace | -Ignore whitespace differences. | -No | -
| strip | -Strip the smallest prefix containing num leading - slashes from filenames. | -No | -
<patch patchfile="module.1.0-1.1.patch" />-
applies the diff included in module.1.0-1.1.patch to the -files in base directory guessing the filename(s) from the diff output. -
<patch patchfile="module.1.0-1.1.patch" strip="1" />-
like above but one leading directory part will be removed. i.e. if -the diff output looked like -
---- a/mod1.0/A Mon Jun 5 17:28:41 2000 -+++ a/mod1.1/A Mon Jun 5 17:28:49 2000 --the leading a/ will be stripped. -
Sets a property (by name and value), or set of properties (from file or -resource) in the project.
-When a property was set by the user, or was a property in a parent project -(that started this project with the ant task), then this -property cannot be set, and will be ignored. This means that properties set -outside the current project always override the properties of the current -project.
-There are three ways to set properties:
-Although combinations of the three ways are possible, only one should be used -at a time. Problems might occur with the order in which properties are set, for -instance.
-The value part of the properties being set, might contain references to other -properties. These references are resolved at the time these properties are set. -This also holds for properties loaded from a property file.
-| Attribute | -Description | -Required | -
| name | -the name of the property to set. | -Yes | -
| value | -the value of the property. | -Yes | -
| resource | -the resource name of the property file. | -|
| file | -the filename of the property file . | -
<property name="foo.dist" value="dist" />-
sets the property foo.dist to the value "dist".
<property file="foo.properties" />-
reads a set of properties from a file called "foo.properties".
-<property resource="foo.properties" />-
reads a set of properties from a resource called "foo.properties".
-Note that you can reference a global properties file for all of your Ant -builds using the following: -
<property file="${user.home}/.ant-global.properties" />
-since the "user.home" property is defined by the Java virtual machine -to be your home directory. This technique is more appropriate for Unix than -Windows since the notion of a home directory doesn't exist on Windows. On the -JVM that I tested, the home directory on Windows is "C:\". Different JVM -implementations may use other values for the home directory on Windows. -
Renames a given file.
-| Attribute | -Description | -Required | -
| src | -file to rename. | -Yes | -
| dest | -new name of the file. | -Yes | -
| replace | -Enable replacing of existing file (default: on). | -No | -
<rename src="foo.jar" dest="${name}-${version}.jar" />
-Renames the file foo.jar to ${name}-${version}.jar (assuming name
- and version being predefined properties). If a file named ${name}-${version}.jar
- already exists, it will be removed prior to renameing foo.jar.
Replace is a directory based task for replacing the occurrence of a given string with another string -in selected file.
-| Attribute | -Description | -Required | -
| file | -file for which the token should be replaced. If not present the dir attribute - must be specified | -No | -
| dir | -The base directory to use when replacing a token in multiple files. If not present the file attribute - must be specified | -No | -
| token | -the token which must be replaced. | -Yes | -
| value | -the new value for the token. When omitted, an empty string - ("") is used. | -No | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
<replace file="${src}/index.html" token="@@@" value="wombat" />
-replaces occurrences of the string "@@@" with the string
-"wombat", in the file ${src}/index.html.
Runs the rmic compiler for a certain class.
-| Attribute | -Description | -Required | -
| base | -the location to store the compiled files. | -Yes | -
| classname | -the class for which to run rmic. |
- Yes | -
| filtering | -indicates whether token filtering should take place | -No | -
| sourcebase | -Pass the "-keepgenerated" flag to rmic and - move the generated source file to the base directory. | -No | -
| stubversion | -Specify the JDK version for the generated stub code. - Specify "1.1" to pass the "-v1.1" option to rmic. | -No | -
| classpath | -The classpath to use during compilation | -No | -
<rmic classname="com.xyz.FooBar" base="${build}/classes" />
-runs the rmic compiler for the class com.xyz.FooBar. The
-compiled files will be stored in the directory ${build}/classes.
Creates a tar archive.
-The basedir attribute is the reference directory from where to tar.
-It is possible to refine the set of files that are being tarred. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the basedir directory.
-The includes, excludes and defaultexcludes attributes -replace the items and ignore attributes. The following explains -how the deprecated items and ignore attribute behave.
-When "*" is used for items, all files in the basedir, and -its subdirectories, will be tarred. Otherwise all the files and directories -mentioned in the items list will tarred. When a directory is specified, then all -files within it are also tarred.
-With the ignore attribute, you can specify files or directories to -ignore. These files will not be tarred. The items in the ignore attribute -override the items in the items attribute. The names specified in the ignore -attribute are just names, they do not contain any path information!
-Note that this task does not perform compression. You might want to use the GZip -task to come up with a .tar.gz package.
-| Attribute | -Description | -Required | -
| tarfile | -the tar-file to create. | -Yes | -
| basedir | -the directory from which to zip the files. | -Yes | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
<tar tarfile="${dist}/manual.tar" basedir="htdocs/manual" />
- <gzip zipfile="${dist}/manual.tar.gz" src="${dist}/manual.tar" />
-tars all files in the htdocs/manual directory in a file called manual.tar
-in the ${dist} directory, then applies the gzip task to compress
-it.
<tar tarfile="${dist}/manual.tar"
- basedir="htdocs/manual"
- excludes="mydocs/**, **/todo.html"
- />
-tars all files in the htdocs/manual directory in a file called manual.tar
-in the ${dist} directory. Files in the directory mydocs,
-or files with the name todo.html are excluded.
Adds a task definition to the current project, such that this new task can be -used in the current project. Two attributes are needed, the name that identifies -this task uniquely, and the full name of the class (including the packages) that -implements this task.
-Taskdef should be used to add your own tasks to the system. See also "Writing your own task".
-| Attribute | -Description | -Required | -
| name | -the name of the task | -Yes | -
| classname | -the full class name implementing the task | -Yes | -
<taskdef name="myjavadoc" classname="com.mydomain.JavadocTask" />-
makes a task called myjavadoc available to Ant. The class com.mydomain.JavadocTask
-implements the task.
Changes the modification time of a file and possibly creates it at -the same time.
-For JDK 1.1 only the creation of new files with a modification time -of now works, all other cases will emit a warning.
-| Attribute | -Description | -Required | -
| file | -the name of the file | -Yes | -
| millis | -specifies the new modification time of the file - in milliseconds since midnight Jan 1 1970 | -No | -
| datetime | -specifies the new modification time of the file - in the format MM/DD/YYYY HH:MM AM_or_PM. | -No | -
If both millis and datetime are ommited
-the current time is assumed.
<touch file="myfile" />-
creates myfile if it doesn't exist and changes the
-modification time to the current time.
<touch file="myfile" datetime="06/28/2000 2:02 pm" />-
creates myfile if it doesn't exist and changes the
-modification time to Jun, 28 2000 2:02 pm (14:02 for those used to 24
-hour times).
Sets the DSTAMP, TSTAMP and TODAY properties in the current project. The -DSTAMP is in the "yyyymmdd" format, the TSTAMP is in the "hhmm" -format and TODAY is "month day year".
-These properties can be used in the buildfile, for instance, to create -timestamped filenames or used to replace placeholder tags inside documents to -indicate, for example, the release date. The best place for this task is in your -initialization target.
-| Attribute | -Description | -Required | -
<tstamp/>-
Process a set of documents via XSLT.
-This is useful for building views of XML based documentation, -or in generating code.
-It is possible to refine the set of files that are being copied. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the basedir directory.
-| Attribute | -Description | -Required | -
| basedir | -where to find the source xml file. | -Yes | -
| destdir | -directory where to store the results. | -Yes | -
| extention | -desired file extension to be used for the targets. - If not specified, the default is "html". | -No | -
| style | -name of the stylesheet to use. | -Yes | -
| processor | -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 | -No | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
---<style basedir="doc" destdir="build/doc" - extension="html" style="style/apache.xml"/> --
Untars a tarfile.
-For JDK 1.1 "last modified time" field is set to current time instead of being -carried from tarfile.
-| Attribute | -Description | -Required | -
| src | -tarfile to expand. | -Yes | -
| dest | -directory where to store the expanded files. | -Yes | -
---
-<gunzip src="tools.tar.gz"/>
-<untar src="tools.tar" dest="${tools.home}"/> -
Creates a zipfile.
-The basedir attribute is the reference directory from where to zip.
-It is possible to refine the set of files that are being zipped. This can be -done with the includes, includesfile, excludes, excludesfile and defaultexcludes -attributes. With the includes or includesfile attribute you specify the files you want to -have included by using patterns. The exclude or excludesfile attribute is used to specify -the files you want to have excluded. This is also done with patterns. And -finally with the defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The patterns are -relative to the basedir directory.
-The includes, excludes and defaultexcludes attributes -replace the items and ignore attributes. The following explains -how the deprecated items and ignore attribute behave.
-When "*" is used for items, all files in the basedir, and -its subdirectories, will be zipped. Otherwise all the files and directories -mentioned in the items list will zipped. When a directory is specified, then all -files within it are also zipped.
-With the ignore attribute, you can specify files or directories to -ignore. These files will not be zipped. The items in the ignore attribute -override the items in the items attribute. The names specified in the ignore -attribute are just names, they do not contain any path information!
-| Attribute | -Description | -Required | -
| zipfile | -the zip-file to create. | -Yes | -
| basedir | -the directory from which to zip the files. | -Yes | -
| compress | -Not only store data but also compress them, defaults to true | -No | -
| items | -a comma separated list of the files/directories to zip. All - files are included when omitted. (deprecated, use includes - instead). | -No | -
| ignore | -comma separated list of filenames/directorynames to exclude - from the zip. No files (except default excludes) are excluded when - omitted. (deprecated, use excludes instead). | -No | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when omitted. | -No | -
<zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- />
-zips all files in the htdocs/manual directory in a file called manual.zip
-in the ${dist} directory.
<zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- excludes="mydocs/**, **/todo.html"
- />
-zips all files in the htdocs/manual directory in a file called manual.zip
-in the ${dist} directory. Files in the directory mydocs,
-or files with the name todo.html are excluded.
<zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- includes="api/**/*.html"
- excludes="**/todo.html"
- />
-zips all files in the htdocs/manual directory in a file called manual.zip
-in the ${dist} directory. Only html files under the directory api
-are zipped, and files with the name todo.html are excluded.
<zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- items="*"
- />
-zips all files in the htdocs/manual directory in a file called manual.zip
-in the ${dist} directory.
<zip zipfile="${dist}/manual.zip"
- basedir="htdocs/manual"
- items="*"
- ignore="mydocs, todo.html"
- />
-zips all files in the htdocs/manual directory in a file called manual.zip
-in the ${dist} directory. Files/directories with the names mydocs
-and todo.html are excluded.
To use build events you need to create an ant Project object. You can then call the
-addBuildListener method to add your listener to the project. Your listener must implement
-the org.apache.tools.antBuildListener interface. The listener will receive BuildEvents
-for the following events
-
--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. - - -ant -listener org.apache.tools.ant.XmlLogger-
It is very easy to write your own task:
-org.apache.tools.ant.Task.public
- void method that takes one String as an argument. The
- name of the method must begin with "set", followed by the
- attribute name, with the first character in uppercase, and the rest in
- lowercase.public void execute method, with no arguments, that
- throws a BuildException. This method implements the task
- itself.It is important to know that Ant first calls the setters for the attributes -it encounters for a specific task in the buildfile, before it executes is.
-Let's write our own task, that prints a message on the System.out stream. The -task has one attribute called "message".
-
- package com.mydomain;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-public class MyVeryOwnTask extends Task {
- private String msg;
-
- // The method executing the task
- public void execute() throws BuildException {
- System.out.println(msg);
- }
-
- // The setter for the "message" attribute
- public void setMessage(String msg) {
- this.msg = msg;
- }
-}
-
-It's really this simple;-)
-Adding your task to the system is rather simple too:
---<?xml version="1.0"?> - -<project name="OwnTaskExample" default="main" basedir="."> - <target name="init"> - <taskdef name="mytask" classname="com.mydomain.MyVeryOwnTask"/> - </target> - - <target name="main" depends="init"> - <mytask message="Hello World! MyVeryOwnTask works!" /> - </target> -</project> --
Another way to add a task (more permanently), is to add the task name and
-implementing class name to the default.properties file in the org.apache.tools.ant.taskdefs
-package. Then you can use it as if it were a built in task.
To provide feedback on this software, please subscribe to the Ant Development -Mail List (ant-dev-subscribe@jakarta.apache.org)
-Copyright © 2000 Apache Software Foundation. All rights -Reserved.
- -Compiles a NetRexx -source tree within the running (Ant) VM.
-The source and destination directory will be recursively scanned for -NetRexx source files to compile. Only NetRexx files that have no corresponding -class file or where the class file is older than the java file will be compiled.
-Files in the source tree are copied to the destination directory, -allowing support files to be located properly in the classpath. The source -files are copied because the NetRexx compiler cannot produce class files in a -specific directory via parameters
-The directory structure of the source tree should follow the package -hierarchy.
-It is possible to refine the set of files that are being compiled/copied. -This can be done with the includes, includesfile, excludes, excludesfile and -defaultexcludes attributes. With the includes or includesfile attribute you -specify the files you want to have included by using patterns. The -exclude or excludesfile attribute is used to specify the files you want to have -excluded. This is also done with patterns. And finally with the -defaultexcludes attribute, you can specify whether you -want to use default exclusions or not. See the section on directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The -patterns are relative to the srcDir directory.
- -| Attribute | -Description | -Required | -
| binary | -Whether literals are treated as the java binary - type rather than the NetRexx types | -No | -
| classpath | -The classpath to use during compilation | -No | -
| comments | -Whether comments are passed through to the - generated java source | -No | -
| compact | -Whether error messages come out in compact or - verbose format | -No | -
| compile | -Whether the NetRexx compiler should compile the - generated java code | -No | -
| console | -Whether or not messages should be displayed on the - 'console' | -No | -
| crossref | -Whether variable cross references are generated | -No | -
| decimal | -Whether decimal arithmetic should be used for the - NetRexx code | -No | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when - omitted. | -No | -
| destDir | -the destination directory into which the NetRexx - source files should be copied and then compiled | -Yes | -
| diag | -Whether diagnostic information about the compile is - generated | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when - omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| explicit | -Whether variables must be declared explicitly - before use | -No | -
| format | -Whether the generated java code is formatted nicely - or left to match NetRexx line numbers for call stack debugging | -No | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| java | -Whether the generated java code is produced | -No | -
| keep | -Sets whether the generated java source file should be kept - after compilation. The generated files will have an extension of - .java.keep, not .java | -No | -
| logo | -Whether the compiler text logo is displayed when - compiling | -No | -
| replace | -Whether the generated .java file should be replaced - when compiling | -No | -
| savelog | -Whether the compiler messages will be written to - NetRexxC.log as well as to the console | -No | -
| sourcedir | -Tells the NetRexx compiler to store the class files in the - same directory as the source files. The alternative is the working - directory | -No | -
| srcDir | -Set the source dir to find the source Netrexx - files | -Yes | -
| strictargs | -Tells the NetRexx compiler that method calls always
- need parentheses, even if no arguments are needed, e.g.
- aStringVar.getBytes vs.
- aStringVar.getBytes() |
- No | -
| strictassign | -Tells the NetRexx compile that assignments must - match exactly on type | -No | -
| strictcase | -Specifies whether the NetRexx compiler should be - case sensitive or not | -No | -
| strictimport | -Whether classes need to be imported explicitly using an
- import statement. By default the NetRexx compiler will
- import certain packages automatically |
- No | -
| strictprops | -Whether local properties need to be qualified
- explicitly using this |
- No | -
| strictsignal | -Whether the compiler should force catching of - exceptions by explicitly named types | -No | -
| symbols | -Whether debug symbols should be generated into the - class file | -No | -
| time | -Asks the NetRexx compiler to print compilation - times to the console | -No | -
| trace | -Turns on or off tracing and directs the resultant - trace output | -No | -
| utf8 | -Tells the NetRexx compiler that the source is in UTF8 | -No | -
| verbose | -Whether lots of warnings and error messages should - be generated | -Yes | -
---
<netrexxc srcDir="/source/project" - includes="vnr/util/*" - destDir="/source/project/build" - classpath="/source/project2/proj.jar" - comments="true" - crossref="false" replace="true" - keep="true" />-
Renames files in the srcDir directory ending with the
-fromExtension string so that they end with the
-toExtension string. Files are only replaced if
-replace is true
-
See the section on -directory based tasks, on how the -inclusion/exclusion of files works, and how to write patterns. The -patterns are relative to the srcDir directory.
-| Attribute | -Description | -Required | -
| defaultexcludes | -indicates whether default excludes should be used or not - ("yes"/"no"). Default excludes are used when - omitted. | -No | -
| excludes | -comma separated list of patterns of files that must be - excluded. No files (except default excludes) are excluded when - omitted. | -No | -
| excludesfile | -the name of a file. Each line of this file is - taken to be an exclude pattern | -No | -
| fromExtention | -The string that files must end in to be renamed | -Yes | -
| includes | -comma separated list of patterns of files that must be - included. All files are included when omitted. | -No | -
| includesfile | -the name of a file. Each line of this file is - taken to be an include pattern | -No | -
| replace | -Whether the file being renamed to should be - replaced if it already exists | -No | -
| srcDir | -The starting directory for files to search in | -Yes | -
| toExtension | -The string that renamed files will end with on - completion | -Yes | -
-- --
<renameext srcDir="/source/project1" - includes="**" - excludes="**/samples/*" - fromExtension=".java.keep" - toExtension=".java" - replace="true" /> --
Execute a script in a - BSF supported language. -
All items (tasks, targets, etc) of the running project are accessible -from the script. -
| Attribute | -Description | -Required | -
| language | -The programming language the script is written in. - Must be a supported BSF language | -No | -
| src | -The location of the script as a file, if not inline | -No | -
-- - - - - diff --git a/spec/core.html b/spec/core.html deleted file mode 100644 index 882659efc0..0000000000 --- a/spec/core.html +++ /dev/null @@ -1,278 +0,0 @@ - - - -None yet available
-
Version 0.5 (2000/04/20)
-This document specifies the behavior of Ant. At this time, this is a - working document with no implementation. It is hoped that this specification - will lead to a simplier and more consistent implementation of Ant.
-This document is not intended to be used as an end user manual or user - guide to Ant. To adequatly explain the concepts herein in a way appropriate to - such a use would potentially complicate this document.
-The following are the overall design goals of Ant:
-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.
-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.
-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.
-This is a conceptual overview of the components used by Ant. Full APIs - will be defined later.
-The base unit of work in Ant is the Project. A Project
- is defined by an editable text file and is represented by an object of type
- org.apache.ant.Project at runtime.
A Project is a collection of Properties and - Targets.
-Properties are mutable name-value pairs that are scoped to the Project
- and held in a table. Only one pair is allowed per name. It is anticipated that
- this data structure would be of type java.util.Properties or a type that has approximatly
- the same contract.
Properties can be defined in a hierarchical manner. The order of - precidence in this hiearchy is:
-user.home directoryNote: The current version of Ant allows the System property list to be
- consulted for a return value if the property list doesn't satisfy the requested
- property name. As all Java code has access to the system property list via the
- java.lang.System class, this functionality is considered to be confusing and to be
- removed.
Note: The current version of Ant allows property substitution to be - performed in the project file. This functionality is being removed.
-Targets are ordered collections of Tasks, units of work - to be performed if a Target is executed.
-Targets can define dependancies on other Targets within the Project. If - a Target is deemed to be executed, either directly on the command line, or via - a dependancy from some other Target, then all of its dependencies must first be - executed. Circular depenancies are resolved by examination of the dependancy - stack when a Target is evaluated. If a dependancy is already on the stack of - targets to be executed, then the dependancy is considered to have been - satisfied.
-After all dependancies of a Target have been satisfied, all of the Tasks - contained by the target are configured and executed in sequential order.
-A Task is a unit of work. When a Task is to be executed, an instance of
- the class that defines the behavior of the particular task specified is
- instantiated and then configured. This class implements the org.apache.ant.Task interface.
- It is then executed so that it may be able to perform its function. It is
- important to note that this configuration occurs just before execution of the
- task, and after execution of any previous tasks, so that configuration
- information that was modified by any other Task can be properly set.
When a Task is executed, it is provided access to the object - representing the Project it is running in allowing it to examine the Property - list of the project and access to various methods needed to operate.
-Tasks are defined within Java Archive files. The name of the JAR
- determines the name under which the task is known by in the system. For
- example, if a Task JAR is named mvdir.jar, the task is known to the system as
- "mvdir".
Question: Should we say that tasks belong in a JAR file with the - .tsk extension?
-The class within the Jar file that implements the org.apache.ant.Task interface is
- specified by a manifest attribute named Ant-Task-Class in the Jar manifest. An example
- manifest would look like:
Manifest-Version: 1.0 - Ant-Task-Class: org.apache.ant.task.javac.JavacTask-
When the task is used by Ant, a class loader is created that reads - classes from the JAR file. This ensures that there is no chance of namespace - collision in the classes of various task JAR files.
-When Ant is installed on a user system, it installs a directory - structure with the following form:
-<installdir>/ant (unix shell script) - /ant.bat - /ant.jar - /ant.properties - /tasks/[task jar files] - /docs/[documentation] - /README-
Note: Current Jakarta practice is to name the Unix shell script with a - .sh extension. This goes against Unix conventions and is unecessary. Testing - has shown that the leaving the extension off on Unix will not interfere with - the working of the Windows batch file.
-Note: The ant.jar file has been moved from the lib/ directory and placed - alongside the shell startup scripts (which have also been moved out of the bin/ - directory). This is because on windows platforms, the .jar file is an - executable file of sorts.
-The ant.properties file contains a list of all the properties that should be
- set by default when ant is run. In addition there are a few special properties
- that are used directly by ant. An example of these properties in use is:
system.taskdir=tasks/ - user.taskdir=anttasks/-
The system.taskdir property sets where the system looks for Java ARchive files
- containing tasks. If this property defines a relative path, then the path is
- taken as relative from the installation directory.
The user.taskdir property defines where users can locate Java Archive files
- containing tasks. If this property defines a realtive path, then the path is
- taken as relative from the users home directory (as defined by the user.home
- system property). Task JAR files in this directory take precendence of those in
- the system directory.
Note: It has been suggested to add a properties file hook to the - command line to roll in props. Pending investigation.
-In addition to the Ant installation directory, an ant.properties file can be
- located in the user's home directory (as found by the system property user.home)
- which can define user preferences such as the location of a user tasks
- directory. Properties defined in this file take precidence over those set in
- the installation's ant.properties file. Such a file could look like:
user.taskdir=anttasks/ - javac.debug=off-
Properties starting with "system." in the user's ant.properties file are not
- allowed and must cause a warning to be thrown.
Ant's Project text file is structured using XML and reflects the - structure of the various components described in the Conceptual Overview.
-A sample Project file:
-<project name="projectname" defaulttarget="main" taskdir="tasks/"> - <property name="javac.debug" value="on"/> - <target name="main"> - <taskimpl ...> - ... - </taskimpl> - </target> -</project>-
The project element has the following required attributes:
defaulttarget defining the default target to be executed if no other target
- is specified when Ant is runIt also has the following optional allowed attributes:
-name defining a name for this projecttaskdir defining a directory in which project specific tasks can be
- located. Tasks in this directory take precedence over those in the either the
- user taskdir or the installation taskdir.The following elements are allowed as children of the project - element:
-property defining a property scoped to the projecttarget defining a targetasdf
-asfd
-The Task section of the configuration file is structured as such:
-<[taskname] [attname=value] [attname=value]...]> - [<[elementname] [attname=value] ...> ... </[elementname]>] - </[taskname]>-
The taskname is used to find the class of the Task. Once the class has - been located and an instance of it created, all of the attributes of the Task - are reflected into the task instance using bean patterns. For example, if a - Task contains an attribute named "directory", the method named - setDirectory would be called with the attribute value cast to the appropriate - type desired by the method. (What to do if the type isn't a file or a - simple type, look for the class and see if it has a setString method?)
- -Text blocks contained by the element are added to task using an addText - method. Place an example...
-For each element contained in the Task definition, an addElementname - method is found on the task. The parameter type of the method defines an object - that will be loaded and instantiated. The attributes of the element are - reflected into the object using bean methods. Any text is set using the addText - method. Any elements are recursed in the same fashion.
-Search order of tasks.... project/user/system
-The command line utility provided with Ant must support the following - allowable syntax:
-ant projectfile [prop=value [prop=value...]] [target]
Internally, the command line shell scripts should call the org.apache.ant.Main class
- with the following arguments:
java -Dant.home=installdir org.apache.ant.Main $*-
or its equivalent on the host platform. Note that the ant installation - directory is a System property. The above syntax results in ant.home being - placed in the System property list.
-Note: On unix, finding the directory of the script that was launched - is relatively easy. However on Windows, I'm not sure the best way of handling - this.
-File naming in a cross platform tool is tricky. For maximum portability - and understandiblity it is recommended that project files use the following - conventions:
-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:
-Absolute paths are not recommended for build files as they reduce the - ability to share a project between u sers or machines.
-In situtations where a set of filenames need to be specified, such as - defining a classpath, both the colon (':') andsemicolon (';') are allowable - characters to seperate each filename. The only case that has to be - disambiguated is if a user specifies paths that contain windows style absolute - paths. In this case, the colon is not treated as a path seperator if the - following rules are met:
-Sam, I'm leaving this to you.
-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.
-Note: When running on JDK 1.2 or greater, the tools.jar isn't on the - classpath by default. There's a few different ways we can take care of this. - One is to put it on the classpath in the execute script (I don't like this - one). Another is to find the location of tools.jar at runtime and put it on the - classpath of class loaders that load in task.jars so that, at least in the - scope of the Tasks, the relevant classes are there.
- - - diff --git a/src/bin/ant b/src/bin/ant deleted file mode 100644 index ab91889d37..0000000000 --- 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 de92c90317..0000000000 --- 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 4c38b18038..0000000000 --- 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 7bd0c8c2e2..0000000000 --- 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 4b4407e3c5..0000000000 --- a/src/etc/log.xsl +++ /dev/null @@ -1,57 +0,0 @@ -| Build Failed | -Build Complete | -Total Time: |
-
-
- * These criteria consist of a set of include and exclude patterns. With these - * patterns, you can select which files you want to have included, and which - * files you want to have excluded. - *
- * The idea is simple. A given directory is recursively scanned for all files - * and directories. Each file/directory is matched against a set of include - * and exclude patterns. Only files/directories that match at least one - * pattern of the include pattern list, and don't match a pattern of the - * exclude pattern list will be placed in the list of files/directories found. - *
- * When no list of include patterns is supplied, "**" will be used, which - * means that everything will be matched. When no list of exclude patterns is - * supplied, an empty list is used, such that nothing will be excluded. - *
- * The pattern matching is done as follows:
- * The name to be matched is split up in path segments. A path segment is the
- * name of a directory or file, which is bounded by
- * File.separator ('/' under UNIX, '\' under Windows).
- * E.g. "abc/def/ghi/xyz.java" is split up in the segments "abc", "def", "ghi"
- * and "xyz.java".
- * The same is done for the pattern against which should be matched.
- *
- * Then the segments of the name and the pattern will be matched against each - * other. When '**' is used for a path segment in the pattern, then it matches - * zero or more path segments of the name. - *
- * There are special case regarding the use of File.separators at
- * the beginningof the pattern and the string to match:
- * When a pattern starts with a File.separator, the string
- * to match must also start with a File.separator.
- * When a pattern does not start with a File.separator, the
- * string to match may not start with a File.separator.
- * When one of these rules is not obeyed, the string will not
- * match.
- *
- * When a name path segment is matched against a pattern path segment, the - * following special characters can be used: - * '*' matches zero or more characters, - * '?' matches one character. - *
- * Examples: - *
- * "**\*.class" matches all .class files/dirs in a directory tree. - *
- * "test\a??.java" matches all files/dirs which start with an 'a', then two - * more characters and then ".java", in a directory called test. - *
- * "**" matches everything in a directory tree. - *
- * "**\test\**\XYZ*" matches all files/dirs that start with "XYZ" and where - * there is a parent directory called test (e.g. "abc\test\def\ghi\XYZ123"). - *
- * Example of usage: - *
- * String[] includes = {"**\\*.class"};
- * String[] excludes = {"modules\\*\\**"};
- * ds.setIncludes(includes);
- * ds.setExcludes(excludes);
- * ds.setBasedir(new File("test"));
- * ds.scan();
- *
- * System.out.println("FILES:");
- * String[] files = ds.getIncludedFiles();
- * for (int i = 0; i < files.length;i++) {
- * System.out.println(files[i]);
- * }
- *
- * This will scan a directory called test for .class files, but excludes all
- * .class files in all directories under a directory called "modules"
- *
- * @author Arnout J. Kuiper ajkuiper@wxs.nl
- */
-public class DirectoryScanner {
-
- /**
- * Patterns that should be excluded by default.
- *
- * @see #addDefaultExcludes()
- */
- private final static String[] DEFAULTEXCLUDES = {
- "**/*~",
- "**/#*#",
- "**/%*%",
- "**/CVS",
- "**/CVS/*",
- "**/.cvsignore"
- };
-
- /**
- * The base directory which should be scanned.
- */
- private File basedir;
-
- /**
- * The patterns for the files that should be included.
- */
- private String[] includes;
-
- /**
- * The patterns for the files that should be excluded.
- */
- private String[] excludes;
-
- /**
- * The files that where found and matched at least one includes, and matched
- * no excludes.
- */
- private Vector filesIncluded;
-
- /**
- * The files that where found and did not match any includes.
- */
- private Vector filesNotIncluded;
-
- /**
- * The files that where found and matched at least one includes, and also
- * matched at least one excludes.
- */
- private Vector filesExcluded;
-
- /**
- * The directories that where found and matched at least one includes, and
- * matched no excludes.
- */
- private Vector dirsIncluded;
-
- /**
- * The directories that where found and did not match any includes.
- */
- private Vector dirsNotIncluded;
-
- /**
- * The files that where found and matched at least one includes, and also
- * matched at least one excludes.
- */
- private Vector dirsExcluded;
-
-
-
- /**
- * Constructor.
- */
- public DirectoryScanner() {
- }
-
-
-
- /**
- * Matches a path against a pattern.
- *
- * @param pattern the (non-null) pattern to match against
- * @param str the (non-null) string (path) to match
- *
- * @return true when the pattern matches against the string.
- * false otherwise.
- */
- private static boolean matchPath(String pattern, String str) {
- // When str starts with a File.separator, pattern has to start with a
- // File.separator.
- // When pattern starts with a File.separator, str has to start with a
- // File.separator.
- if (str.startsWith(File.separator) !=
- pattern.startsWith(File.separator)) {
- return false;
- }
-
- Vector patDirs = new Vector();
- StringTokenizer st = new StringTokenizer(pattern,File.separator);
- while (st.hasMoreTokens()) {
- patDirs.addElement(st.nextToken());
- }
-
- Vector strDirs = new Vector();
- st = new StringTokenizer(str,File.separator);
- while (st.hasMoreTokens()) {
- strDirs.addElement(st.nextToken());
- }
-
- int patIdxStart = 0;
- int patIdxEnd = patDirs.size()-1;
- int strIdxStart = 0;
- int strIdxEnd = strDirs.size()-1;
-
- // up to first '**'
- while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
- String patDir = (String)patDirs.elementAt(patIdxStart);
- if (patDir.equals("**")) {
- break;
- }
- if (!match(patDir,(String)strDirs.elementAt(strIdxStart))) {
- return false;
- }
- patIdxStart++;
- strIdxStart++;
- }
- if (strIdxStart > strIdxEnd) {
- // String is exhausted
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (!patDirs.elementAt(i).equals("**")) {
- return false;
- }
- }
- return true;
- } else {
- if (patIdxStart > patIdxEnd) {
- // String not exhausted, but pattern is. Failure.
- return false;
- }
- }
-
- // up to last '**'
- while (patIdxStart <= patIdxEnd && strIdxStart <= strIdxEnd) {
- String patDir = (String)patDirs.elementAt(patIdxEnd);
- if (patDir.equals("**")) {
- break;
- }
- if (!match(patDir,(String)strDirs.elementAt(strIdxEnd))) {
- return false;
- }
- patIdxEnd--;
- strIdxEnd--;
- }
- if (strIdxStart > strIdxEnd) {
- // String is exhausted
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (!patDirs.elementAt(i).equals("**")) {
- return false;
- }
- }
- return true;
- }
-
- while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
- int patIdxTmp = -1;
- for (int i = patIdxStart+1; i <= patIdxEnd; i++) {
- if (patDirs.elementAt(i).equals("**")) {
- patIdxTmp = i;
- break;
- }
- }
- if (patIdxTmp == patIdxStart+1) {
- // '**/**' situation, so skip one
- patIdxStart++;
- continue;
- }
- // Find the pattern between padIdxStart & padIdxTmp in str between
- // strIdxStart & strIdxEnd
- int patLength = (patIdxTmp-patIdxStart-1);
- int strLength = (strIdxEnd-strIdxStart+1);
- int foundIdx = -1;
-strLoop:
- for (int i = 0; i <= strLength - patLength; i++) {
- for (int j = 0; j < patLength; j++) {
- String subPat = (String)patDirs.elementAt(patIdxStart+j+1);
- String subStr = (String)strDirs.elementAt(strIdxStart+i+j);
- if (!match(subPat,subStr)) {
- continue strLoop;
- }
- }
-
- foundIdx = strIdxStart+i;
- break;
- }
-
- if (foundIdx == -1) {
- return false;
- }
-
- patIdxStart = patIdxTmp;
- strIdxStart = foundIdx+patLength;
- }
-
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (!patDirs.elementAt(i).equals("**")) {
- return false;
- }
- }
-
- return true;
- }
-
-
-
- /**
- * Matches a string against a pattern. The pattern contains two special
- * characters:
- * '*' which means zero or more characters,
- * '?' which means one and only one character.
- *
- * @param pattern the (non-null) pattern to match against
- * @param str the (non-null) string that must be matched against the
- * pattern
- *
- * @return true when the string matches against the pattern,
- * false otherwise.
- */
- private static boolean match(String pattern, String str) {
- char[] patArr = pattern.toCharArray();
- char[] strArr = str.toCharArray();
- int patIdxStart = 0;
- int patIdxEnd = patArr.length-1;
- int strIdxStart = 0;
- int strIdxEnd = strArr.length-1;
- char ch;
-
- boolean containsStar = false;
- for (int i = 0; i < patArr.length; i++) {
- if (patArr[i] == '*') {
- containsStar = true;
- break;
- }
- }
-
- if (!containsStar) {
- // No '*'s, so we make a shortcut
- if (patIdxEnd != strIdxEnd) {
- return false; // Pattern and string do not have the same size
- }
- for (int i = 0; i <= patIdxEnd; i++) {
- ch = patArr[i];
- if (ch != '?' && ch != strArr[i]) {
- return false; // Character mismatch
- }
- }
- return true; // String matches against pattern
- }
-
- if (patIdxEnd == 0) {
- return true; // Pattern contains only '*', which matches anything
- }
-
- // Process characters before first star
- while((ch = patArr[patIdxStart]) != '*' && strIdxStart <= strIdxEnd) {
- if (ch != '?' && ch != strArr[strIdxStart]) {
- return false;
- }
- patIdxStart++;
- strIdxStart++;
- }
- if (strIdxStart > strIdxEnd) {
- // All characters in the string are used. Check if only '*'s are
- // left in the pattern. If so, we succeeded. Otherwise failure.
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (patArr[i] != '*') {
- return false;
- }
- }
- return true;
- }
-
- // Process characters after last star
- while((ch = patArr[patIdxEnd]) != '*' && strIdxStart <= strIdxEnd) {
- if (ch != '?' && ch != strArr[strIdxEnd]) {
- return false;
- }
- patIdxEnd--;
- strIdxEnd--;
- }
- if (strIdxStart > strIdxEnd) {
- // All characters in the string are used. Check if only '*'s are
- // left in the pattern. If so, we succeeded. Otherwise failure.
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (patArr[i] != '*') {
- return false;
- }
- }
- return true;
- }
-
- // process pattern between stars. padIdxStart and patIdxEnd point
- // always to a '*'.
- while (patIdxStart != patIdxEnd && strIdxStart <= strIdxEnd) {
- int patIdxTmp = -1;
- for (int i = patIdxStart+1; i <= patIdxEnd; i++) {
- if (patArr[i] == '*') {
- patIdxTmp = i;
- break;
- }
- }
- if (patIdxTmp == patIdxStart+1) {
- // Two stars next to each other, skip the first one.
- patIdxStart++;
- continue;
- }
- // Find the pattern between padIdxStart & padIdxTmp in str between
- // strIdxStart & strIdxEnd
- int patLength = (patIdxTmp-patIdxStart-1);
- int strLength = (strIdxEnd-strIdxStart+1);
- int foundIdx = -1;
-strLoop:
- for (int i = 0; i <= strLength - patLength; i++) {
- for (int j = 0; j < patLength; j++) {
- ch = patArr[patIdxStart+j+1];
- if (ch != '?' && ch != strArr[strIdxStart+i+j]) {
- continue strLoop;
- }
- }
-
- foundIdx = strIdxStart+i;
- break;
- }
-
- if (foundIdx == -1) {
- return false;
- }
-
- patIdxStart = patIdxTmp;
- strIdxStart = foundIdx+patLength;
- }
-
- // All characters in the string are used. Check if only '*'s are left
- // in the pattern. If so, we succeeded. Otherwise failure.
- for (int i = patIdxStart; i <= patIdxEnd; i++) {
- if (patArr[i] != '*') {
- return false;
- }
- }
- return true;
- }
-
-
-
- /**
- * Sets the basedir for scanning. This is the directory that is scanned
- * recursively. All '/' and '\' characters are replaced by
- * File.separatorChar. So the separator used need not match
- * File.separatorChar.
- *
- * @param basedir the (non-null) basedir for scanning
- */
- public void setBasedir(String basedir) {
- setBasedir(new File(basedir.replace('/',File.separatorChar).replace('\\',File.separatorChar)));
- }
-
-
-
- /**
- * Sets the basedir for scanning. This is the directory that is scanned
- * recursively.
- *
- * @param basedir the basedir for scanning
- */
- public void setBasedir(File basedir) {
- this.basedir = basedir;
- }
-
-
-
- /**
- * Gets the basedir that is used for scanning. This is the directory that
- * is scanned recursively.
- *
- * @return the basedir that is used for scanning
- */
- public File getBasedir() {
- return basedir;
- }
-
-
-
- /**
- * Sets the set of include patterns to use. All '/' and '\' characters are
- * replaced by File.separatorChar. So the separator used need
- * not match File.separatorChar.
- *
- * When a pattern ends with a '/' or '\', "**" is appended.
- *
- * @param includes list of include patterns
- */
- public void setIncludes(String[] includes) {
- if (includes == null) {
- this.includes = null;
- } else {
- this.includes = new String[includes.length];
- for (int i = 0; i < includes.length; i++) {
- String pattern;
- pattern = includes[i].replace('/',File.separatorChar).replace('\\',File.separatorChar);
- if (pattern.endsWith(File.separator)) {
- pattern += "**";
- }
- this.includes[i] = pattern;
- }
- }
- }
-
-
-
- /**
- * Sets the set of exclude patterns to use. All '/' and '\' characters are
- * replaced by File.separatorChar. So the separator used need
- * not match File.separatorChar.
- *
- * When a pattern ends with a '/' or '\', "**" is appended.
- *
- * @param excludes list of exclude patterns
- */
- public void setExcludes(String[] excludes) {
- if (excludes == null) {
- this.excludes = null;
- } else {
- this.excludes = new String[excludes.length];
- for (int i = 0; i < excludes.length; i++) {
- String pattern;
- pattern = excludes[i].replace('/',File.separatorChar).replace('\\',File.separatorChar);
- if (pattern.endsWith(File.separator)) {
- pattern += "**";
- }
- this.excludes[i] = pattern;
- }
- }
- }
-
-
-
- /**
- * Scans the base directory for files that match at least one include
- * pattern, and don't match any exclude patterns.
- *
- * @exception IllegalStateException when basedir was set incorrecly
- */
- public void scan() {
- if (basedir == null) {
- throw new IllegalStateException("No basedir set");
- }
- if (!basedir.exists()) {
- throw new IllegalStateException("basedir does not exist");
- }
- if (!basedir.isDirectory()) {
- throw new IllegalStateException("basedir is not a directory");
- }
-
- if (includes == null) {
- // No includes supplied, so set it to 'matches all'
- includes = new String[1];
- includes[0] = "**";
- }
- if (excludes == null) {
- excludes = new String[0];
- }
-
- filesIncluded = new Vector();
- filesNotIncluded = new Vector();
- filesExcluded = new Vector();
- dirsIncluded = new Vector();
- dirsNotIncluded = new Vector();
- dirsExcluded = new Vector();
-
- scandir(basedir,"");
- }
-
-
-
- /**
- * Scans the passed dir for files and directories. Found files and
- * directories are placed in their respective collections, based on the
- * matching of includes and excludes. When a directory is found, it is
- * scanned recursively.
- *
- * @param dir the directory to scan
- * @param vpath the path relative to the basedir (needed to prevent
- * problems with an absolute path when using dir)
- *
- * @see #filesIncluded
- * @see #filesNotIncluded
- * @see #filesExcluded
- * @see #dirsIncluded
- * @see #dirsNotIncluded
- * @see #dirsExcluded
- */
- private void scandir(File dir, String vpath) {
- String[] newfiles = dir.list();
- for (int i = 0; i < newfiles.length; i++) {
- String name = vpath+newfiles[i];
- File file = new File(dir,newfiles[i]);
- if (file.isDirectory()) {
- if (isIncluded(name)) {
- if (!isExcluded(name)) {
- dirsIncluded.addElement(name);
- } else {
- dirsExcluded.addElement(name);
- }
- } else {
- dirsNotIncluded.addElement(name);
- }
- scandir(file, name+File.separator);
- } else if (file.isFile()) {
- if (isIncluded(name)) {
- if (!isExcluded(name)) {
- filesIncluded.addElement(name);
- } else {
- filesExcluded.addElement(name);
- }
- } else {
- filesNotIncluded.addElement(name);
- }
- }
- }
- }
-
-
-
- /**
- * Tests whether a name matches against at least one include pattern.
- *
- * @param name the name to match
- * @return true when the name matches against at least one
- * include pattern, false otherwise.
- */
- private boolean isIncluded(String name) {
- for (int i = 0; i < includes.length; i++) {
- if (matchPath(includes[i],name)) {
- return true;
- }
- }
- return false;
- }
-
-
-
- /**
- * Tests whether a name matches against at least one exclude pattern.
- *
- * @param name the name to match
- * @return true when the name matches against at least one
- * exclude pattern, false otherwise.
- */
- private boolean isExcluded(String name) {
- for (int i = 0; i < excludes.length; i++) {
- if (matchPath(excludes[i],name)) {
- return true;
- }
- }
- return false;
- }
-
-
-
- /**
- * Get the names of the files that matched at least one of the include
- * patterns, an matched none of the exclude patterns.
- * The names are relative to the basedir.
- *
- * @return the names of the files
- */
- public String[] getIncludedFiles() {
- int count = filesIncluded.size();
- String[] files = new String[count];
- for (int i = 0; i < count; i++) {
- files[i] = (String)filesIncluded.elementAt(i);
- }
- return files;
- }
-
-
-
- /**
- * Get the names of the files that matched at none of the include patterns.
- * The names are relative to the basedir.
- *
- * @return the names of the files
- */
- public String[] getNotIncludedFiles() {
- int count = filesNotIncluded.size();
- String[] files = new String[count];
- for (int i = 0; i < count; i++) {
- files[i] = (String)filesNotIncluded.elementAt(i);
- }
- return files;
- }
-
-
-
- /**
- * Get the names of the files that matched at least one of the include
- * patterns, an matched also at least one of the exclude patterns.
- * The names are relative to the basedir.
- *
- * @return the names of the files
- */
- public String[] getExcludedFiles() {
- int count = filesExcluded.size();
- String[] files = new String[count];
- for (int i = 0; i < count; i++) {
- files[i] = (String)filesExcluded.elementAt(i);
- }
- return files;
- }
-
-
-
- /**
- * Get the names of the directories that matched at least one of the include
- * patterns, an matched none of the exclude patterns.
- * The names are relative to the basedir.
- *
- * @return the names of the directories
- */
- public String[] getIncludedDirectories() {
- int count = dirsIncluded.size();
- String[] directories = new String[count];
- for (int i = 0; i < count; i++) {
- directories[i] = (String)dirsIncluded.elementAt(i);
- }
- return directories;
- }
-
-
-
- /**
- * Get the names of the directories that matched at none of the include
- * patterns.
- * The names are relative to the basedir.
- *
- * @return the names of the directories
- */
- public String[] getNotIncludedDirectories() {
- int count = dirsNotIncluded.size();
- String[] directories = new String[count];
- for (int i = 0; i < count; i++) {
- directories[i] = (String)dirsNotIncluded.elementAt(i);
- }
- return directories;
- }
-
-
-
- /**
- * Get the names of the directories that matched at least one of the include
- * patterns, an matched also at least one of the exclude patterns.
- * The names are relative to the basedir.
- *
- * @return the names of the directories
- */
- public String[] getExcludedDirectories() {
- int count = dirsExcluded.size();
- String[] directories = new String[count];
- for (int i = 0; i < count; i++) {
- directories[i] = (String)dirsExcluded.elementAt(i);
- }
- return directories;
- }
-
-
-
- /**
- * Adds the array with default exclusions to the current exclusions set.
- *
- */
- public void addDefaultExcludes() {
- int excludesLength = excludes == null ? 0 : excludes.length;
- String[] newExcludes;
- newExcludes = new String[excludesLength + DEFAULTEXCLUDES.length];
- if (excludesLength > 0) {
- System.arraycopy(excludes,0,newExcludes,0,excludesLength);
- }
- for (int i = 0; i < DEFAULTEXCLUDES.length; i++) {
- newExcludes[i+excludesLength] = DEFAULTEXCLUDES[i].replace('/',File.separatorChar).replace('\\',File.separatorChar);
- }
- excludes = newExcludes;
- }
-
-
-
-}
diff --git a/src/main/org/apache/tools/ant/Location.java b/src/main/org/apache/tools/ant/Location.java
deleted file mode 100644
index dcd14a5879..0000000000
--- 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
- *
- * 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
- * This class also encapsulates methods which allow Files to be refered
- * to using abstract path names which are translated to native system
- * file paths at runtime as well as defining various project properties.
- *
- * @author duncan@x180.com
- */
-
-public class Project {
-
- public static final int MSG_ERR = 0;
- public static final int MSG_WARN = 1;
- public static final int MSG_INFO = 2;
- public static final int MSG_VERBOSE = 3;
-
- // private set of constants to represent the state
- // of a DFS of the Target dependencies
- private static final String VISITING = "VISITING";
- private static final String VISITED = "VISITED";
-
- private static String javaVersion;
-
- public static final String JAVA_1_0 = "1.0";
- public static final String JAVA_1_1 = "1.1";
- public static final String JAVA_1_2 = "1.2";
- public static final String JAVA_1_3 = "1.3";
-
- public static final String TOKEN_START = "@";
- public static final String TOKEN_END = "@";
-
- private String name;
-
- private Hashtable properties = new Hashtable();
- private Hashtable userProperties = new Hashtable();
- private Hashtable references = new Hashtable();
- private String defaultTarget;
- private Hashtable taskClassDefinitions = new Hashtable();
- private Hashtable targets = new Hashtable();
- private Hashtable filters = new Hashtable();
- private File baseDir;
-
- private Vector listeners = new Vector();
- protected Target currentTarget = null;
- protected Task currentTask = null;
-
- public Project() {
- }
-
- /**
- * Initialise the project.
- *
- * This involves setting the default task definitions and loading the
- * system properties.
- */
- public void init() throws BuildException {
- detectJavaVersion();
-
- String defs = "/org/apache/tools/ant/taskdefs/defaults.properties";
-
- try {
- Properties props = new Properties();
- InputStream in = this.getClass().getResourceAsStream(defs);
- props.load(in);
- in.close();
-
- Enumeration enum = props.propertyNames();
- while (enum.hasMoreElements()) {
- String key = (String) enum.nextElement();
- String value = props.getProperty(key);
- try {
- Class taskClass = Class.forName(value);
- addTaskDefinition(key, taskClass);
- } catch (NoClassDefFoundError ncdfe) {
- // ignore...
- } catch (ClassNotFoundException cnfe) {
- // ignore...
- }
- }
-
- Properties systemP = System.getProperties();
- Enumeration e = systemP.keys();
- while (e.hasMoreElements()) {
- String name = (String) e.nextElement();
- String value = (String) systemP.get(name);
- this.setProperty(name, value);
- }
- } catch (IOException ioe) {
- throw new BuildException("Can't load default task list");
- }
- }
-
- public void addBuildListener(BuildListener listener) {
- listeners.addElement(listener);
- }
-
- public void removeBuildListener(BuildListener listener) {
- listeners.removeElement(listener);
- }
-
- public Vector getBuildListeners() {
- return listeners;
- }
-
- public void log(String msg) {
- log(msg, MSG_INFO);
- }
-
- public void log(String msg, int msgLevel) {
- fireMessageLogged(msg, msgLevel);
- }
-
- public void log(String msg, String tag, int msgLevel) {
- fireMessageLogged(msg, msgLevel);
- }
-
- public void setProperty(String name, String value) {
- // command line properties take precedence
- if (null != userProperties.get(name))
- return;
- log("Setting project property: " + name + " -> " +
- value, MSG_VERBOSE);
- properties.put(name, value);
- }
-
- public void setUserProperty(String name, String value) {
- log("Setting ro project property: " + name + " -> " +
- value, MSG_VERBOSE);
- userProperties.put(name, value);
- properties.put(name, value);
- }
-
- public String getProperty(String name) {
- if (name == null) return null;
- String property = (String) properties.get(name);
- return property;
- }
-
- public String getUserProperty(String name) {
- if (name == null) return null;
- String property = (String) userProperties.get(name);
- return property;
- }
-
- public Hashtable getProperties() {
- return properties;
- }
-
- public Hashtable getUserProperties() {
- return userProperties;
- }
-
- public void setDefaultTarget(String defaultTarget) {
- this.defaultTarget = defaultTarget;
- }
-
- // deprecated, use setDefault
- public String getDefaultTarget() {
- return defaultTarget;
- }
-
- // match the attribute name
- public void setDefault(String defaultTarget) {
- this.defaultTarget = defaultTarget;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getName() {
- return name;
- }
-
- public void addFilter(String token, String value) {
- if (token == null) return;
- log("Setting token to filter: " + token + " -> "
- + value, MSG_VERBOSE);
- this.filters.put(token, value);
- }
-
- public Hashtable getFilters() {
- return filters;
- }
-
- // match basedir attribute in xml
- public void setBasedir(String baseD) throws BuildException {
- try {
- setBaseDir(new File(new File(baseD).getCanonicalPath()));
- } catch (IOException ioe) {
- String msg = "Can't set basedir " + baseDir + " due to " +
- ioe.getMessage();
- throw new BuildException(msg);
- }
- }
-
- public void setBaseDir(File baseDir) {
- this.baseDir = baseDir;
- setProperty( "basedir", baseDir.getAbsolutePath());
- String msg = "Project base dir set to: " + baseDir;
- log(msg, MSG_INFO);
- }
-
- public File getBaseDir() {
- if (baseDir == null) {
- try {
- setBasedir(".");
- } catch (BuildException ex) {
- ex.printStackTrace();
- }
- }
- return baseDir;
- }
-
- public static String getJavaVersion() {
- return javaVersion;
- }
-
- private void detectJavaVersion() {
-
- // Determine the Java version by looking at available classes
- // java.lang.StrictMath was introduced in JDK 1.3
- // java.lang.ThreadLocal was introduced in JDK 1.2
- // java.lang.Void was introduced in JDK 1.1
- // Count up version until a NoClassDefFoundError ends the try
-
- try {
- javaVersion = JAVA_1_0;
- Class.forName("java.lang.Void");
- javaVersion = JAVA_1_1;
- Class.forName("java.lang.ThreadLocal");
- javaVersion = JAVA_1_2;
- Class.forName("java.lang.StrictMath");
- javaVersion = JAVA_1_3;
- } catch (ClassNotFoundException cnfe) {
- // swallow as we've hit the max class version that
- // we have
- }
- setProperty("ant.java.version", javaVersion);
-
- // sanity check
- if (javaVersion == JAVA_1_0) {
- throw new BuildException("Ant cannot work on Java 1.0");
- }
-
- log("Detected Java Version: " + javaVersion, MSG_VERBOSE);
-
- log("Detected OS: " + System.getProperty("os.name"), MSG_VERBOSE);
- }
-
- public void addTaskDefinition(String taskName, Class taskClass) {
- String msg = " +User task: " + taskName + " " + taskClass.getName();
- log(msg, MSG_VERBOSE);
- taskClassDefinitions.put(taskName, taskClass);
- }
-
- /**
- * This call expects to add a new Target.
- * @param target is the Target to be added to the current
- * Project.
- * @exception BuildException if the Target already exists
- * in the project.
- * @see Project#addOrReplaceTarget to replace existing Targets.
- */
- public void addTarget(Target target) {
- String name = target.getName();
- if (targets.get(name) != null) {
- throw new BuildException("Duplicate target: `"+name+"'");
- }
- addOrReplaceTarget(name, target);
- }
-
- /**
- * This call expects to add a new Target.
- * @param target is the Target to be added to the current
- * Project.
- * @param targetName is the name to use for the Target
- * @exception BuildException if the Target already exists
- * in the project.
- * @see Project#addOrReplaceTarget to replace existing Targets.
- */
- public void addTarget(String targetName, Target target)
- throws BuildException {
- if (targets.get(targetName) != null) {
- throw new BuildException("Duplicate target: `"+targetName+"'");
- }
- addOrReplaceTarget(targetName, target);
- }
-
- /**
- * @param target is the Target to be added or replaced in
- * the current Project.
- */
- public void addOrReplaceTarget(Target target) {
- addOrReplaceTarget(target.getName(), target);
- }
-
- /**
- * @param target is the Target to be added/replaced in
- * the current Project.
- * @param targetName is the name to use for the Target
- */
- public void addOrReplaceTarget(String targetName, Target target) {
- String msg = " +Target: " + targetName;
- log(msg, MSG_VERBOSE);
- target.setProject(this);
- targets.put(targetName, target);
- }
-
- public Hashtable getTargets() {
- return targets;
- }
-
- public Task createTask(String taskType) throws BuildException {
- Class c = (Class) taskClassDefinitions.get(taskType);
-
- if (c == null)
- throw new BuildException("Could not create task of type: "+taskType+
- " because I can't find it in the list of task"+
- " class definitions");
- try {
- Object o = c.newInstance();
- Task task = null;
- if( o instanceof Task ) {
- task=(Task)o;
- } else {
- // "Generic" Bean - use the setter pattern
- // and an Adapter
- TaskAdapter taskA=new TaskAdapter();
- taskA.setProxy( o );
- task=taskA;
- }
- task.setProject(this);
- String msg = " +Task: " + taskType;
- log (msg, MSG_VERBOSE);
- return task;
- } catch (Exception e) {
- String msg = "Could not create task of type: "
- + taskType + " due to " + e;
- throw new BuildException(msg);
- }
- }
-
- public void executeTargets(Vector targetNames) throws BuildException {
- Throwable error = null;
-
- try {
- for (int i = 0; i < targetNames.size(); i++) {
- executeTarget((String)targetNames.elementAt(i));
- }
- }
- catch(RuntimeException exc) {
- error = exc;
- throw exc;
- }
- finally {
- fireBuildFinished(error);
- }
- }
-
- public void executeTarget(String targetName) throws BuildException {
-
- // sanity check ourselves, if we've been asked to build nothing
- // then we should complain
-
- if (targetName == null) {
- String msg = "No target specified";
- throw new BuildException(msg);
- }
-
- // Sort the dependency tree, and run everything from the
- // beginning until we hit our targetName.
- // Sorting checks if all the targets (and dependencies)
- // exist, and if there is any cycle in the dependency
- // graph.
- Vector sortedTargets = topoSort(targetName, targets);
-
- int curidx = 0;
- String curtarget;
-
- do {
- curtarget = (String) sortedTargets.elementAt(curidx++);
- runTarget(curtarget, targets);
- } while (!curtarget.equals(targetName));
- }
-
- public File resolveFile(String fileName) {
- // deal with absolute files
- if (fileName.startsWith("/")) return new File( fileName );
- if (fileName.startsWith(System.getProperty("file.separator")))
- return new File( fileName );
-
- // Eliminate consecutive slashes after the drive spec
- if (fileName.length() >= 2 &&
- Character.isLetter(fileName.charAt(0)) &&
- fileName.charAt(1) == ':') {
- char[] ca = fileName.replace('/', '\\').toCharArray();
- char c;
- StringBuffer sb = new StringBuffer();
-
- for (int i = 0; i < ca.length; i++) {
- if ((ca[i] != '\\') ||
- (ca[i] == '\\' &&
- i > 0 &&
- ca[i - 1] != '\\')) {
- if (i == 0 &&
- Character.isLetter(ca[i]) &&
- i < ca.length - 1 &&
- ca[i + 1] == ':') {
- c = Character.toUpperCase(ca[i]);
- } else {
- c = ca[i];
- }
-
- sb.append(c);
- }
- }
-
- return new File(sb.toString());
- }
-
- File file = new File(baseDir.getAbsolutePath());
- StringTokenizer tok = new StringTokenizer(fileName, "/", false);
- while (tok.hasMoreTokens()) {
- String part = tok.nextToken();
- if (part.equals("..")) {
- file = new File(file.getParent());
- } else if (part.equals(".")) {
- // Do nothing here
- } else {
- file = new File(file, part);
- }
- }
-
- try {
- return new File(file.getCanonicalPath());
- }
- catch (IOException e) {
- log("IOException getting canonical path for " + file + ": " +
- e.getMessage(), MSG_ERR);
- return new File(file.getAbsolutePath());
- }
- }
-
- /**
- Translate a path into its native (platform specific)
- path. This should be extremely fast, code is
- borrowed from ECS project.
-
- All it does is translate the : into ; and / into \
- if needed. In other words, it isn't perfect.
-
- @returns translated string or empty string if to_process is null or empty
- @author Jon S. Stevens jon@clearink.com
- */
- public String translatePath(String to_process) {
- if ( to_process == null || to_process.length() == 0 ) return "";
-
- StringBuffer bs = new StringBuffer(to_process.length() + 50);
- StringCharacterIterator sci = new StringCharacterIterator(to_process);
- String path = System.getProperty("path.separator");
- String file = System.getProperty("file.separator");
- String tmp = null;
- for (char c = sci.first(); c != CharacterIterator.DONE; c = sci.next()) {
- tmp = String.valueOf(c);
-
- if (tmp.equals(":")) {
- // could be a DOS drive or a Unix path separator...
- // if followed by a backslash, assume it is a drive
- c = sci.next();
- tmp = String.valueOf(c);
- bs.append( tmp.equals("\\") ? ":" : path );
- if (c == CharacterIterator.DONE) break;
- }
-
- if (tmp.equals(":") || tmp.equals(";"))
- tmp = path;
- else if (tmp.equals("/") || tmp.equals ("\\"))
- tmp = file;
- bs.append(tmp);
- }
- return(bs.toString());
- }
-
- /**
- * Convienence method to copy a file from a source to a destination.
- * No filtering is performed.
- *
- * @throws IOException
- */
- public void copyFile(String sourceFile, String destFile) throws IOException {
- copyFile(new File(sourceFile), new File(destFile), false);
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used.
- *
- * @throws IOException
- */
- public void copyFile(String sourceFile, String destFile, boolean filtering)
- throws IOException
- {
- copyFile(new File(sourceFile), new File(destFile), filtering);
- }
-
- /**
- * Convienence method to copy a file from a source to a destination.
- * No filtering is performed.
- *
- * @throws IOException
- */
- public void copyFile(File sourceFile, File destFile) throws IOException {
- copyFile(sourceFile, destFile, false);
- }
-
- /**
- * Convienence method to copy a file from a source to a destination
- * specifying if token filtering must be used.
- *
- * @throws IOException
- */
- public void copyFile(File sourceFile, File destFile, boolean filtering)
- throws IOException
- {
-
- if (destFile.lastModified() < sourceFile.lastModified()) {
- log("Copy: " + sourceFile.getAbsolutePath() + " > "
- + destFile.getAbsolutePath(), MSG_VERBOSE);
-
- // ensure that parent dir of dest file exists!
- // not using getParentFile method to stay 1.1 compat
- File parent = new File(destFile.getParent());
- if (!parent.exists()) {
- parent.mkdirs();
- }
-
- if (filtering) {
- BufferedReader in = new BufferedReader(new FileReader(sourceFile));
- BufferedWriter out = new BufferedWriter(new FileWriter(destFile));
-
- int length;
- String newline = null;
- String line = in.readLine();
- while (line != null) {
- if (line.length() == 0) {
- out.newLine();
- } else {
- newline = replace(line, filters);
- out.write(newline);
- out.newLine();
- }
- line = in.readLine();
- }
-
- out.close();
- in.close();
- } else {
- FileInputStream in = new FileInputStream(sourceFile);
- FileOutputStream out = new FileOutputStream(destFile);
-
- byte[] buffer = new byte[8 * 1024];
- int count = 0;
- do {
- out.write(buffer, 0, count);
- count = in.read(buffer, 0, buffer.length);
- } while (count != -1);
-
- in.close();
- out.close();
- }
- }
- }
-
- /**
- * Does replacement on the given string using the given token table.
- *
- * @returns the string with the token replaced.
- */
- private String replace(String s, Hashtable tokens) {
- int index = s.indexOf(TOKEN_START);
-
- if (index > -1) {
- try {
- StringBuffer b = new StringBuffer();
- int i = 0;
- String token = null;
- String value = null;
-
- do {
- token = s.substring(index + TOKEN_START.length(), s.indexOf(TOKEN_END, index + TOKEN_START.length() + 1));
- b.append(s.substring(i, index));
- if (tokens.containsKey(token)) {
- value = (String) tokens.get(token);
- log("Replacing: " + TOKEN_START + token + TOKEN_END + " -> " + value, MSG_VERBOSE);
- b.append(value);
- } else {
- b.append(TOKEN_START);
- b.append(token);
- b.append(TOKEN_END);
- }
- i = index + TOKEN_START.length() + token.length() + TOKEN_END.length();
- } while ((index = s.indexOf(TOKEN_START, i)) > -1);
-
- b.append(s.substring(i));
- return b.toString();
- } catch (StringIndexOutOfBoundsException e) {
- return s;
- }
- } else {
- return s;
- }
- }
-
- /**
- * returns the boolean equivalent of a string, which is considered true
- * if either "on", "true", or "yes" is found, ignoring case.
- */
- public static boolean toBoolean(String s) {
- return (s.equalsIgnoreCase("on") ||
- s.equalsIgnoreCase("true") ||
- s.equalsIgnoreCase("yes"));
- }
-
- // Given a string defining a target name, and a Hashtable
- // containing the "name to Target" mapping, pick out the
- // Target and execute it.
- private final void runTarget(String target, Hashtable targets)
- throws BuildException {
-
- currentTarget = (Target)targets.get(target);
- if (currentTarget == null) {
- throw new RuntimeException("Unexpected missing target `"+target+
- "' in this project.");
- }
-
- try {
- fireTargetStarted();
- currentTarget.execute();
- fireTargetFinished(null);
- }
- catch(RuntimeException exc) {
- fireTargetFinished(exc);
- throw exc;
- }
- finally {
- currentTarget = null;
- }
- }
-
- /**
- * Topologically sort a set of Targets.
- * @param root is the (String) name of the root Target. The sort is
- * created in such a way that the sequence of Targets uptil the root
- * target is the minimum possible such sequence.
- * @param targets is a Hashtable representing a "name to Target" mapping
- * @return a Vector of Strings with the names of the targets in
- * sorted order.
- * @exception BuildException if there is a cyclic dependency among the
- * Targets, or if a Target does not exist.
- */
- private final Vector topoSort(String root, Hashtable targets)
- throws BuildException {
- Vector ret = new Vector();
- Hashtable state = new Hashtable();
- Stack visiting = new Stack();
-
- // We first run a DFS based sort using the root as the starting node.
- // This creates the minimum sequence of Targets to the root node.
- // We then do a sort on any remaining unVISITED targets.
- // This is unnecessary for doing our build, but it catches
- // circular dependencies or missing Targets on the entire
- // dependency tree, not just on the Targets that depend on the
- // build Target.
-
- tsort(root, targets, state, visiting, ret);
- log("Build sequence for target `"+root+"' is "+ret, MSG_VERBOSE);
- for (Enumeration en=targets.keys(); en.hasMoreElements();) {
- String curTarget = (String)(en.nextElement());
- String st = (String) state.get(curTarget);
- if (st == null) {
- tsort(curTarget, targets, state, visiting, ret);
- }
- else if (st == VISITING) {
- throw new RuntimeException("Unexpected node in visiting state: "+curTarget);
- }
- }
- log("Complete build sequence is "+ret, MSG_VERBOSE);
- return ret;
- }
-
- // one step in a recursive DFS traversal of the Target dependency tree.
- // - The Hashtable "state" contains the state (VISITED or VISITING or null)
- // of all the target names.
- // - The Stack "visiting" contains a stack of target names that are
- // currently on the DFS stack. (NB: the target names in "visiting" are
- // exactly the target names in "state" that are in the VISITING state.)
- // 1. Set the current target to the VISITING state, and push it onto
- // the "visiting" stack.
- // 2. Throw a BuildException if any child of the current node is
- // in the VISITING state (implies there is a cycle.) It uses the
- // "visiting" Stack to construct the cycle.
- // 3. If any children have not been VISITED, tsort() the child.
- // 4. Add the current target to the Vector "ret" after the children
- // have been visited. Move the current target to the VISITED state.
- // "ret" now contains the sorted sequence of Targets upto the current
- // Target.
-
- private final void tsort(String root, Hashtable targets,
- Hashtable state, Stack visiting,
- Vector ret)
- throws BuildException {
- state.put(root, VISITING);
- visiting.push(root);
-
- Target target = (Target)(targets.get(root));
-
- // Make sure we exist
- if (target == null) {
- StringBuffer sb = new StringBuffer("Target `");
- sb.append(root);
- sb.append("' does not exist in this project. ");
- visiting.pop();
- if (!visiting.empty()) {
- String parent = (String)visiting.peek();
- sb.append("It is used from target `");
- sb.append(parent);
- sb.append("'.");
- }
-
- throw new BuildException(new String(sb));
- }
-
- for (Enumeration en=target.getDependencies(); en.hasMoreElements();) {
- String cur = (String) en.nextElement();
- String m=(String)state.get(cur);
- if (m == null) {
- // Not been visited
- tsort(cur, targets, state, visiting, ret);
- }
- else if (m == VISITING) {
- // Currently visiting this node, so have a cycle
- throw makeCircularException(cur, visiting);
- }
- }
-
- String p = (String) visiting.pop();
- if (root != p) {
- throw new RuntimeException("Unexpected internal error: expected to pop "+root+" but got "+p);
- }
- state.put(root, VISITED);
- ret.addElement(root);
- }
-
- private static BuildException makeCircularException(String end, Stack stk) {
- StringBuffer sb = new StringBuffer("Circular dependency: ");
- sb.append(end);
- String c;
- do {
- c = (String)stk.pop();
- sb.append(" <- ");
- sb.append(c);
- } while(!c.equals(end));
- return new BuildException(new String(sb));
- }
-
- public void addReference(String name, Object value) {
- references.put(name,value);
- }
-
- public Hashtable getReferences() {
- return references;
- }
-
- protected void fireBuildStarted() {
- BuildEvent event = createBuildEvent();
- for (int i = 0; i < listeners.size(); i++) {
- BuildListener listener = (BuildListener) listeners.elementAt(i);
- listener.buildStarted(event);
- }
- }
-
- protected void fireBuildFinished(Throwable exception) {
- BuildEvent event = createBuildEvent(exception);
- for (int i = 0; i < listeners.size(); i++) {
- BuildListener listener = (BuildListener) listeners.elementAt(i);
- listener.buildFinished(event);
- }
- }
-
- protected void fireTargetStarted() {
- BuildEvent event = createBuildEvent();
- for (int i = 0; i < listeners.size(); i++) {
- BuildListener listener = (BuildListener) listeners.elementAt(i);
- listener.targetStarted(event);
- }
- }
-
- protected void fireTargetFinished(Throwable exception) {
- BuildEvent event = createBuildEvent(exception);
- for (int i = 0; i < listeners.size(); i++) {
- BuildListener listener = (BuildListener) listeners.elementAt(i);
- listener.targetFinished(event);
- }
- }
-
- protected void fireTaskStarted() {
- BuildEvent event = createBuildEvent();
- for (int i = 0; i < listeners.size(); i++) {
- BuildListener listener = (BuildListener) listeners.elementAt(i);
- listener.taskStarted(event);
- }
- }
-
- protected void fireTaskFinished(Throwable exception) {
- BuildEvent event = createBuildEvent(exception);
- for (int i = 0; i < listeners.size(); i++) {
- BuildListener listener = (BuildListener) listeners.elementAt(i);
- listener.taskFinished(event);
- }
- }
-
- protected void fireMessageLogged(String message, int priority) {
- BuildEvent event = createBuildEvent(message, priority);
- for (int i = 0; i < listeners.size(); i++) {
- BuildListener listener = (BuildListener) listeners.elementAt(i);
- listener.messageLogged(event);
- }
- }
-
- public BuildEvent createBuildEvent() {
- return new BuildEvent(this, currentTarget, currentTask, null, MSG_VERBOSE, null);
- }
-
- public BuildEvent createBuildEvent(String msg, int priority) {
- return new BuildEvent(this, currentTarget, currentTask, msg, priority, null);
- }
-
- public BuildEvent createBuildEvent(Throwable exception) {
- return new BuildEvent(this, currentTarget, currentTask, null, MSG_VERBOSE, exception);
- }
-}
diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java
deleted file mode 100644
index 31909892d9..0000000000
--- 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
- *
- * This task can take the following arguments:
- *
- * When this task executes, it will scan the srcdir based on the include
- * and exclude properties.
- *
- * Warning: do not run on binary or carefully formatted files.
- * this may sound obvious, but if you don't specify asis, presume that
- * your files are going to be modified. If you want tabs to be fixed,
- * whitespace characters may be added or removed as necessary. Similarly,
- * for CR's - in fact cr="add" can result in cr characters being removed.
- * (to handle cases where other programs have converted CRLF into CRCRLF).
- *
- * @author Sam Ruby rubys@us.ibm.com
- */
-
-public class FixCRLF extends MatchingTask {
-
- private int addcr; // cr: -1 => remove, 0 => asis, +1 => add
- private int addtab; // tab: -1 => remove, 0 => asis, +1 => add
- private int ctrlz; // eof: -1 => remove, 0 => asis, +1 => add
-
- private File srcDir;
- private File destDir = null;
-
- /**
- * Defaults the properties based on the system type.
- *
- * When this task executes, it will recursively scan the sourcedir and
- * destdir looking for Java source files to compile. This task makes its
- * compile decision based on timestamp. Any other file in the
- * sourcedir will be copied to the destdir allowing support files to be
- * located properly in the classpath.
- *
- * @author James Davidson duncan@x180.com
- * @author Robin Green greenrd@hotmail.com
- */
-
-public class Javac extends MatchingTask {
-
- /**
- * Integer returned by the "Modern" jdk1.3 compiler to indicate success.
- */
- private static final int
- MODERN_COMPILER_SUCCESS = 0;
-
- private File srcDir;
- private File destDir;
- private String compileClasspath;
- private boolean debug = false;
- private boolean optimize = false;
- private boolean deprecation = false;
- private boolean filtering = false;
- private String target;
- private String bootclasspath;
- private String extdirs;
-
- protected Vector compileList = new Vector();
- protected Hashtable filecopyList = new Hashtable();
-
- /**
- * Set the source dir to find the source Java files.
- */
- public void setSrcdir(String srcDirName) {
- srcDir = project.resolveFile(srcDirName);
- }
-
- /**
- * Set the destination directory into which the Java source
- * files should be compiled.
- */
- public void setDestdir(String destDirName) {
- destDir = project.resolveFile(destDirName);
- }
-
- /**
- * Set the classpath to be used for this compilation.
- */
- public void setClasspath(String classpath) {
- compileClasspath = project.translatePath(classpath);
- }
-
- /**
- * Sets the bootclasspath that will be used to compile the classes
- * against.
- */
- public void setBootclasspath(String bootclasspath) {
- this.bootclasspath = project.translatePath(bootclasspath);
- }
-
- /**
- * Sets the extension directories that will be used during the
- * compilation.
- */
- public void setExtdirs(String extdirs) {
- this.extdirs = project.translatePath(extdirs);
- }
-
- /**
- * Set the deprecation flag.
- */
- public void setDeprecation(String deprecationString) {
- this.deprecation = Project.toBoolean(deprecationString);
- }
-
- /**
- * Set the debug flag.
- */
- public void setDebug(String debugString) {
- this.debug = Project.toBoolean(debugString);
- }
-
- /**
- * Set the optimize flag.
- */
- public void setOptimize(String optimizeString) {
- this.optimize = Project.toBoolean(optimizeString);
- }
-
- /**
- * Sets the target VM that the classes will be compiled for. Valid
- * strings are "1.1", "1.2", and "1.3".
- */
- public void setTarget(String target) {
- this.target = target;
- }
-
- /**
- * Set the filtering flag.
- */
- public void setFiltering(String filter) {
- filtering = Project.toBoolean(filter);
- }
-
- /**
- * Executes the task.
- */
- public void execute() throws BuildException {
- // first off, make sure that we've got a srcdir and destdir
-
- if (srcDir == null) {
- throw new BuildException("srcdir attribute must be set!");
- }
- if (!srcDir.exists()) {
- throw new BuildException("srcdir does not exist!");
- }
- if (destDir == null) {
- throw new BuildException("destdir attribute must be set!");
- }
-
- // scan source and dest dirs to build up both copy lists and
- // compile lists
-
- DirectoryScanner ds = this.getDirectoryScanner(srcDir);
-
- String[] files = ds.getIncludedFiles();
-
- scanDir(srcDir, destDir, files);
-
- // compile the source files
-
- String compiler = project.getProperty("build.compiler");
- if (compiler == null) {
- if (Project.getJavaVersion().startsWith("1.3")) {
- compiler = "modern";
- } else {
- compiler = "classic";
- }
- }
-
- if (compileList.size() > 0) {
- project.log("Compiling " + compileList.size() +
- " source files to " + destDir);
-
- if (compiler.equalsIgnoreCase("classic")) {
- doClassicCompile();
- } else if (compiler.equalsIgnoreCase("modern")) {
- doModernCompile();
- } else if (compiler.equalsIgnoreCase("jikes")) {
- doJikesCompile();
- } else {
- String msg = "Don't know how to use compiler " + compiler;
- throw new BuildException(msg);
- }
- }
-
- // copy the support files
-
- if (filecopyList.size() > 0) {
- project.log("The implicit copying of support files by javac has been deprecated. " +
- "Use the copydir task to copy support files explicitly.",
- Project.MSG_WARN);
-
- project.log("Copying " + filecopyList.size() +
- " support files to " + destDir.getAbsolutePath());
- Enumeration enum = filecopyList.keys();
- while (enum.hasMoreElements()) {
- String fromFile = (String) enum.nextElement();
- String toFile = (String) filecopyList.get(fromFile);
- try {
- project.copyFile(fromFile, toFile, filtering);
- } catch (IOException ioe) {
- String msg = "Failed to copy " + fromFile + " to " + toFile
- + " due to " + ioe.getMessage();
- throw new BuildException(msg);
- }
- }
- }
- }
-
- /**
- * Scans the directory looking for source files to be compiled and
- * support files to be copied. The results are returned in the
- * class variables compileList and filecopyList.
- */
-
- protected void scanDir(File srcDir, File destDir, String files[]) {
-
- compileList.removeAllElements();
- filecopyList.clear();
-
- long now = (new Date()).getTime();
-
- for (int i = 0; i < files.length; i++) {
- File srcFile = new File(srcDir, files[i]);
- if (files[i].endsWith(".java")) {
- File classFile = new File(destDir, files[i].substring(0,
- files[i].indexOf(".java")) + ".class");
-
- if (srcFile.lastModified() > now) {
- project.log("Warning: file modified in the future: " +
- files[i], project.MSG_WARN);
- }
-
- if (srcFile.lastModified() > classFile.lastModified()) {
- compileList.addElement(srcFile.getAbsolutePath());
- }
- } else {
- File destFile = new File(destDir, files[i]);
- if (srcFile.lastModified() > destFile.lastModified()) {
- filecopyList.put(srcFile.getAbsolutePath(),
- destFile.getAbsolutePath());
- }
- }
- }
- }
-
- /**
- * Builds the compilation classpath.
- */
-
- // XXX
- // we need a way to not use the current classpath.
-
- private String getCompileClasspath() {
- StringBuffer classpath = new StringBuffer();
-
- // add dest dir to classpath so that previously compiled and
- // untouched classes are on classpath
-
- //classpath.append(sourceDir.getAbsolutePath());
- //classpath.append(File.pathSeparator);
- classpath.append(destDir.getAbsolutePath());
-
- // add our classpath to the mix
-
- if (compileClasspath != null) {
- addExistingToClasspath(classpath,compileClasspath);
- }
-
- // add the system classpath
-
- addExistingToClasspath(classpath,System.getProperty("java.class.path"));
- return classpath.toString();
- }
-
-
- /**
- * Takes a classpath-like string, and adds each element of
- * this string to a new classpath, if the components exist.
- * Components that don't exist, aren't added.
- * We do this, because jikes issues warnings for non-existant
- * files/dirs in his classpath, and these warnings are pretty
- * annoying.
- * @param target - target classpath
- * @param source - source classpath
- * to get file objects.
- */
- private void addExistingToClasspath(StringBuffer target,String source) {
- StringTokenizer tok = new StringTokenizer(source,
- System.getProperty("path.separator"), false);
- while (tok.hasMoreTokens()) {
- File f = project.resolveFile(tok.nextToken());
-
- if (f.exists()) {
- target.append(File.pathSeparator);
- target.append(f.getAbsolutePath());
- } else {
- project.log("Dropping from classpath: "+
- f.getAbsolutePath(),project.MSG_VERBOSE);
- }
- }
-
- }
-
- /**
- * Peforms a copmile using the classic compiler that shipped with
- * JDK 1.1 and 1.2.
- */
-
- private void doClassicCompile() throws BuildException {
- project.log("Using classic compiler", project.MSG_VERBOSE);
- String classpath = getCompileClasspath();
- Vector argList = new Vector();
-
- if (deprecation == true)
- argList.addElement("-deprecation");
-
- argList.addElement("-d");
- argList.addElement(destDir.getAbsolutePath());
- argList.addElement("-classpath");
- // Just add "sourcepath" to classpath ( for JDK1.1 )
- if (Project.getJavaVersion().startsWith("1.1")) {
- argList.addElement(classpath + File.pathSeparator +
- srcDir.getAbsolutePath());
- } else {
- argList.addElement(classpath);
- argList.addElement("-sourcepath");
- argList.addElement(srcDir.getAbsolutePath());
- if (target != null) {
- argList.addElement("-target");
- argList.addElement(target);
- }
- }
- if (debug) {
- argList.addElement("-g");
- }
- if (optimize) {
- argList.addElement("-O");
- }
- if (bootclasspath != null) {
- argList.addElement("-bootclasspath");
- argList.addElement(bootclasspath);
- }
- if (extdirs != null) {
- argList.addElement("-extdirs");
- argList.addElement(extdirs);
- }
-
- project.log("Compilation args: " + argList.toString(),
- project.MSG_VERBOSE);
-
- String[] args = new String[argList.size() + compileList.size()];
- int counter = 0;
-
- for (int i = 0; i < argList.size(); i++) {
- args[i] = (String)argList.elementAt(i);
- counter++;
- }
-
- // XXX
- // should be using system independent line feed!
-
- StringBuffer niceSourceList = new StringBuffer("Files to be compiled:"
- + "\r\n");
-
- Enumeration enum = compileList.elements();
- while (enum.hasMoreElements()) {
- args[counter] = (String)enum.nextElement();
- niceSourceList.append(" " + args[counter] + "\r\n");
- counter++;
- }
-
- project.log(niceSourceList.toString(), project.MSG_VERBOSE);
-
- // XXX
- // provide the compiler a different message sink - namely our own
-
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- sun.tools.javac.Main compiler = new sun.tools.javac.Main(out, "javac");
-
- if (compiler.compile(args)) {
- String output = out.toString().trim();
- if (output.length() > 0) {
- project.log(output, Project.MSG_WARN);
- }
- }
- else {
- project.log(out.toString().trim(), Project.MSG_ERR);
-
- throw new BuildException("Compile failed");
- }
- }
-
- /**
- * Performs a compile using the newer compiler that ships with JDK 1.3
- */
-
- private void doModernCompile() throws BuildException {
- project.log("Using modern compiler", project.MSG_VERBOSE);
- String classpath = getCompileClasspath();
- Vector argList = new Vector();
-
- if (deprecation == true)
- argList.addElement("-deprecation");
-
- argList.addElement("-d");
- argList.addElement(destDir.getAbsolutePath());
- argList.addElement("-classpath");
- argList.addElement(classpath);
- argList.addElement("-sourcepath");
- argList.addElement(srcDir.getAbsolutePath());
- if (target != null) {
- argList.addElement("-target");
- argList.addElement(target);
- }
- if (debug) {
- argList.addElement("-g");
- }
- if (optimize) {
- argList.addElement("-O");
- }
- if (bootclasspath != null) {
- argList.addElement("-bootclasspath");
- argList.addElement(bootclasspath);
- }
- if (extdirs != null) {
- argList.addElement("-extdirs");
- argList.addElement(extdirs);
- }
-
- project.log("Compilation args: " + argList.toString(),
- project.MSG_VERBOSE);
-
- String[] args = new String[argList.size() + compileList.size()];
- int counter = 0;
-
- for (int i = 0; i < argList.size(); i++) {
- args[i] = (String)argList.elementAt(i);
- counter++;
- }
-
- // XXX
- // should be using system independent line feed!
-
- StringBuffer niceSourceList = new StringBuffer("Files to be compiled:"
- + "\r\n");
-
- Enumeration enum = compileList.elements();
- while (enum.hasMoreElements()) {
- args[counter] = (String)enum.nextElement();
- niceSourceList.append(" " + args[counter] + "\r\n");
- counter++;
- }
-
- project.log(niceSourceList.toString(), project.MSG_VERBOSE);
-
- // This won't build under JDK1.2.2 because the new compiler
- // doesn't exist there.
- //com.sun.tools.javac.Main compiler = new com.sun.tools.javac.Main();
- //if (compiler.compile(args) != 0) {
-
- // Use reflection to be able to build on all JDKs >= 1.1:
- try {
- Class c = Class.forName ("com.sun.tools.javac.Main");
- Object compiler = c.newInstance ();
- Method compile = c.getMethod ("compile",
- new Class [] {(new String [] {}).getClass ()});
- int result = ((Integer) compile.invoke
- (compiler, new Object [] {args})) .intValue ();
- if (result != MODERN_COMPILER_SUCCESS) {
- String msg =
- "Compile failed, messages should have been provided.";
- throw new BuildException(msg);
- }
- } catch (Exception ex) {
- throw new BuildException (ex);
- }
-
- }
-
- /**
- * Performs a compile using the Jikes compiler from IBM..
- * Mostly of this code is identical to doClassicCompile()
- * However, it does not support all options like
- * bootclasspath, extdirs, deprecation and so on, because
- * there is no option in jikes and I don't understand
- * what they should do.
- *
- * It has been successfully tested with jikes 1.10
- *
- * @author skanthak@muehlheim.de
- */
-
- private void doJikesCompile() throws BuildException {
- project.log("Using jikes compiler",project.MSG_VERBOSE);
-
- StringBuffer classpath = new StringBuffer();
- classpath.append(getCompileClasspath());
-
- // Jikes doesn't support an extension dir (-extdir)
- // so we'll emulate it for compatibility and convenience.
- addExtdirsToClasspath(classpath);
-
- // Jikes has no option for source-path so we
- // will add it to classpath.
- classpath.append(File.pathSeparator);
- classpath.append(srcDir.getAbsolutePath());
-
- Vector argList = new Vector();
-
- if (deprecation == true)
- argList.addElement("-deprecation");
-
- // We want all output on stdout to make
- // parsing easier
- argList.addElement("-Xstdout");
-
- argList.addElement("-d");
- argList.addElement(destDir.getAbsolutePath());
- argList.addElement("-classpath");
- argList.addElement(classpath.toString());
-
- if (debug) {
- argList.addElement("-g");
- }
- if (optimize) {
- argList.addElement("-O");
- }
-
- /**
- * XXX
- * Perhaps we shouldn't use properties for these
- * two options (emacs mode and warnings),
- * but include it in the javac directive?
- */
-
- /**
- * Jikes has the nice feature to print error
- * messages in a form readable by emacs, so
- * that emcas can directly set the cursor
- * to the place, where the error occured.
- */
- boolean emacsMode = false;
- String emacsProperty = project.getProperty("build.compiler.emacs");
- if (emacsProperty != null &&
- (emacsProperty.equalsIgnoreCase("on") ||
- emacsProperty.equalsIgnoreCase("true"))
- ) {
- emacsMode = true;
- }
-
- /**
- * Jikes issues more warnings that javac, for
- * example, when you have files in your classpath
- * that don't exist. As this is often the case, these
- * warning can be pretty annoying.
- */
- boolean warnings = true;
- String warningsProperty = project.getProperty("build.compiler.warnings");
- if (warningsProperty != null &&
- (warningsProperty.equalsIgnoreCase("off") ||
- warningsProperty.equalsIgnoreCase("false"))
- ) {
- warnings = false;
- }
-
- if (emacsMode)
- argList.addElement("+E");
-
- if (!warnings)
- argList.addElement("-nowarn");
-
- project.log("Compilation args: " + argList.toString(),
- project.MSG_VERBOSE);
-
- String[] args = new String[argList.size() + compileList.size()];
- int counter = 0;
-
- for (int i = 0; i < argList.size(); i++) {
- args[i] = (String)argList.elementAt(i);
- counter++;
- }
-
- // XXX
- // should be using system independent line feed!
-
- StringBuffer niceSourceList = new StringBuffer("Files to be compiled:"
- + "\r\n");
-
- Enumeration enum = compileList.elements();
- while (enum.hasMoreElements()) {
- args[counter] = (String)enum.nextElement();
- niceSourceList.append(" " + args[counter] + "\r\n");
- counter++;
- }
-
- project.log(niceSourceList.toString(), project.MSG_VERBOSE);
-
- // XXX
- // provide the compiler a different message sink - namely our own
-
- JikesOutputParser jop = new JikesOutputParser(project,emacsMode);
-
- Jikes compiler = new Jikes(jop,"jikes");
- compiler.compile(args);
- if (jop.getErrorFlag()) {
- String msg = "Compile failed, messages should have been provided.";
- throw new BuildException(msg);
- }
- }
-
- class JarFilenameFilter implements FilenameFilter {
- public boolean accept(File dir,String name) {
- return name.endsWith(".jar");
- }
- }
-
- /**
- * Emulation of extdirs feature in java >= 1.2.
- * This method adds all jar archives in the given
- * directories (but not in sub-directories!) to the classpath,
- * so that you don't have to specify them all one by one.
- * @param classpath - stringbuffer to append jar files to
- */
- private void addExtdirsToClasspath(StringBuffer classpath) {
- // FIXME
- // Should we scan files recursively? How does
- // javac handle this?
-
- if (extdirs != null) {
- StringTokenizer tok = new StringTokenizer(extdirs,
- File.pathSeparator,
- false);
- while (tok.hasMoreTokens()) {
- File dir = project.resolveFile(tok.nextToken());
- String[] files = dir.list(new JarFilenameFilter());
- for (int i=0 ; i < files.length ; i++) {
- File f = new File(dir,files[i]);
- if (f.exists() && f.isFile()) {
- classpath.append(File.pathSeparator);
- classpath.append(f.getAbsolutePath());
- }
- }
- }
- }
- }
-}
-
diff --git a/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java b/src/main/org/apache/tools/ant/taskdefs/JavacOutputStream.java
deleted file mode 100644
index 5fdd11e01a..0000000000
--- 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
- *
- name=value*name2=value
-
- Names are case sensitive.
-
- Use the setSep() method to change the * to something else
- if you need to use * as a name or value.
- */
- public void setKeys(String keys) {
- if (keys != null && keys.length() > 0) {
- StringTokenizer tok =
- new StringTokenizer(keys, this.sep, false);
- while (tok.hasMoreTokens()) {
- String token = tok.nextToken().trim();
- StringTokenizer itok =
- new StringTokenizer(token, "=", false);
-
- String name = itok.nextToken();
- String value = itok.nextToken();
-// project.log ( "Name: " + name );
-// project.log ( "Value: " + value );
- replacements.put ( name, value );
- }
- }
- }
-
-
- public static void main(String[] args)
- {
- try{
- Hashtable hash = new Hashtable();
- hash.put ( "VERSION", "1.0.3" );
- hash.put ( "b", "ffff" );
- System.out.println ( KeySubst.replace ( "$f ${VERSION} f ${b} jj $", hash ) );
- }catch ( Exception e)
- {
- e.printStackTrace();
- }
- }
-
- /**
- Does replacement on text using the hashtable of keys.
-
- @returns the string with the replacements in it.
- */
- public static String replace ( String origString, Hashtable keys )
- throws BuildException
- {
- StringBuffer finalString=new StringBuffer();
- int index=0;
- int i = 0;
- String key = null;
- while ((index = origString.indexOf("${", i)) > -1) {
- key = origString.substring(index + 2, origString.indexOf("}", index+3));
- finalString.append (origString.substring(i, index));
- if ( keys.containsKey ( key ) ) {
- finalString.append (keys.get(key));
- } else {
- finalString.append ( "${" );
- finalString.append ( key );
- finalString.append ( "}" );
- }
- i = index + 3 + key.length();
- }
- finalString.append (origString.substring(i));
- return finalString.toString();
- }
-}
\ No newline at end of file
diff --git a/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java b/src/main/org/apache/tools/ant/taskdefs/MatchingTask.java
deleted file mode 100644
index 0be2f72611..0000000000
--- 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
- * patch's -p option.
- */
- public void setStrip(String num) {
- strip = Integer.parseInt(num);
- }
-
- /**
- * Work silently unless an error occurs.
- */
- public void setQuiet(String q) {
- quiet = Project.toBoolean(q);
- }
-
- /**
- * Assume patch was created with old and new files swapped.
- */
- public void setReverse(String r) {
- reverse = Project.toBoolean(r);
- }
-
- public void execute() throws BuildException {
- if (patchFile == null) {
- throw new BuildException("patchfile argument is required");
- }
-
- StringBuffer command = new StringBuffer("patch -i "+patchFile+" ");
-
- if (backup) {
- command.append("-b ");
- }
-
- if (ignoreWhitespace) {
- command.append("-l ");
- }
-
- if (strip >= 0) {
- command.append("-p"+strip+" ");
- }
-
- if (quiet) {
- command.append("-s ");
- }
-
- if (reverse) {
- command.append("-R ");
- }
-
- if (originalFile != null) {
- command.append(originalFile);
- }
-
- run(command.toString());
- }
-
-}// Patch
diff --git a/src/main/org/apache/tools/ant/taskdefs/Property.java b/src/main/org/apache/tools/ant/taskdefs/Property.java
deleted file mode 100644
index 6bcfe03ed7..0000000000
--- 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
- *
- *
- * @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 df9243f9b2..0000000000
--- 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
- * If the file to touch doesn't exist, an empty one is
- * created. Setting the modification time of files is not supported in
- * JDK 1.1.
- *
- * @author Stefan Bodewig stefan.bodewig@megabit.net
- */
-public class Touch extends Task {
-
- private File file; // required
- private long millis = -1;
- private String dateTime;
-
- private static Method setLastModified = null;
- private static Object lockReflection = new Object();
-
- /**
- * The name of the file to touch.
- */
- public void setFile(String name) {
- file = project.resolveFile(name);
- }
-
- /**
- * Milliseconds since 01/01/1970 00:00 am.
- */
- public void setMillis(long millis) {
- this.millis = millis;
- }
-
- /**
- * Date in the format MM/DD/YYYY HH:MM AM_PM.
- */
- public void setDatetime(String dateTime) {
- this.dateTime = dateTime;
- }
-
- /**
- * Do the work.
- *
- * @exception BuildException Thrown in unrecoverable error.
- */
- public void execute() throws BuildException {
- if (file.exists() && project.getJavaVersion() == Project.JAVA_1_1) {
- project.log("Cannot change the modification time of "
- + file + " in JDK 1.1",
- Project.MSG_WARN);
- return;
- }
-
- if (dateTime != null) {
- DateFormat df = DateFormat.getDateTimeInstance(DateFormat.SHORT,
- DateFormat.SHORT,
- Locale.US);
- try {
- setMillis(df.parse(dateTime).getTime());
- } catch (ParseException pe) {
- throw new BuildException(pe.getMessage(), pe, location);
- }
- }
-
- if (millis >= 0 && project.getJavaVersion() == Project.JAVA_1_1) {
- project.log(file +
- " will be created but its modification time cannot be set in JDK 1.1",
- Project.MSG_WARN);
- }
-
- touch();
- }
-
- /**
- * Does the actual work. Entry point for Untar and Expand as well.
- */
- void touch() throws BuildException {
- if (!file.exists()) {
- project.log("Creating "+file, Project.MSG_INFO);
- try {
- FileOutputStream fos = new FileOutputStream(file);
- fos.write(new byte[0]);
- fos.close();
- } catch (IOException ioe) {
- throw new BuildException("Could not create "+file, ioe,
- location);
- }
- }
-
- if (project.getJavaVersion() == Project.JAVA_1_1) {
- return;
- }
-
- if (setLastModified == null) {
- synchronized (lockReflection) {
- if (setLastModified == null) {
- try {
- setLastModified =
- java.io.File.class.getMethod("setLastModified",
- new Class[] {Long.TYPE});
- } catch (NoSuchMethodException nse) {
- throw new BuildException("File.setlastModified not in JDK > 1.1?",
- nse, location);
- }
- }
- }
- }
-
- Long[] times = new Long[1];
- if (millis < 0) {
- times[0] = new Long(System.currentTimeMillis());
- } else {
- times[0] = new Long(millis);
- }
-
- try {
- project.log("Setting modification time for "+file,
- Project.MSG_VERBOSE);
-
- setLastModified.invoke(file, times);
- } catch (InvocationTargetException ite) {
- Throwable nested = ite.getTargetException();
- throw new BuildException("Exception setting the modification time of "
- + file, nested, location);
- } catch (Throwable other) {
- throw new BuildException("Exception setting the modification time of "
- + file, other, location);
- }
- }
-
-}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Tstamp.java b/src/main/org/apache/tools/ant/taskdefs/Tstamp.java
deleted file mode 100644
index c77028b1fd..0000000000
--- 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
- *
- * This task will recursively scan the sourcedir and destdir
- * looking for XML documents to process via XSLT. Any other files,
- * such as images, or html files in the source directory will be
- * copied into the destination directory.
- *
- * @author Keith Visco
- * @author Sam Ruby
- * @version $Revision$ $Date$
- */
-public class XSLTProcess extends MatchingTask {
-
- private File destDir = null;
-
- private File baseDir = null;
-
- private File xslFile = null;
-
- private String targetExtension = "html";
-
- private XSLTLiaison liaison;
-
- /**
- * Creates a new XSLTProcess Task.
- **/
- public XSLTProcess() {
- } //-- XSLTProcess
-
- /**
- * Executes the task.
- */
-
- public void execute() throws BuildException {
- DirectoryScanner scanner;
- String[] list;
- String[] dirs;
-
- if (baseDir == null)
- baseDir = project.resolveFile(".");
- //-- make sure Source directory exists...
- if (destDir == null ) {
- String msg = "destdir attributes must be set!";
- throw new BuildException(msg);
- }
- scanner = getDirectoryScanner(baseDir);
- project.log("Transforming into "+destDir,project.MSG_INFO);
-
- // if processor wasn't specified, default it to xslp or xalan,
- // depending on which is in the classpath
- if (liaison == null) {
- try {
- setProcessor("xslp");
- } catch (Throwable e1) {
- try {
- setProcessor("xalan");
- } catch (Throwable e2) {
- throw new BuildException(e2);
- }
- }
- }
-
- project.log("Using "+liaison.getClass().toString(),project.MSG_VERBOSE);
-
- try {
- // Create a new XSL processor with the specified stylesheet
- if (xslFile != null) {
- String file = new File(baseDir,xslFile.toString()).toString();
- project.log("Loading stylesheet " + file, project.MSG_INFO);
- liaison.setStylesheet( file );
- }
- } catch (Exception ex) {
- project.log("Failed to read stylesheet " + xslFile,project.MSG_INFO);
- throw new BuildException(ex);
- }
-
- // Process all the files marked for styling
- list = scanner.getIncludedFiles();
- for (int i = 0;i < list.length; ++i) {
- process(baseDir,list[i],destDir);
- }
-
- // Process all the directoried marked for styling
- dirs = scanner.getIncludedDirectories();
- for (int j = 0;j < dirs.length;++j){
- list=new File(baseDir,dirs[j]).list();
- for (int i = 0;i < list.length;++i)
- process(baseDir,list[i],destDir);
- }
- } //-- execute
-
- /**
- * Set the base directory.
- **/
- public void setBasedir(String dirName) {
- baseDir = project.resolveFile(dirName);
- } //-- setSourceDir
-
- /**
- * Set the destination directory into which the XSL result
- * files should be copied to
- * @param dirName the name of the destination directory
- **/
- public void setDestdir(String dirName) {
- destDir = project.resolveFile(dirName);
- } //-- setDestDir
-
- /**
- * Set the desired file extension to be used for the target
- * @param name the extension to use
- **/
- public void setExtension(String name) {
- targetExtension = name;
- } //-- setDestDir
-
- /**
- * Sets the file to use for styling relative to the base directory.
- */
- public void setStyle(String xslFile) {
- this.xslFile = new File(xslFile);
- }
-
- /**
- * Sets the file to use for styling relative to the base directory.
- */
- public void setProcessor(String processor) throws Exception {
-
- if (processor.equals("xslp")) {
- liaison = (XSLTLiaison) Class.forName("org.apache.tools.ant.taskdefs.optional.XslpLiaison").newInstance();
- } else if (processor.equals("xalan")) {
- liaison = (XSLTLiaison) Class.forName("org.apache.tools.ant.taskdefs.optional.XalanLiaison").newInstance();
- } else {
- liaison = (XSLTLiaison) Class.forName(processor).newInstance();
- }
-
- }
-
- /*
- private void process(File sourceDir, File destDir)
- throws BuildException
- {
-
-
- if (!sourceDir.isDirectory()) {
- throw new BuildException(sourceDir.getName() +
- " is not a directory!");
- }
- else if (!destDir.isDirectory()) {
- throw new BuildException(destDir.getName() +
- " is not a directory!");
- }
-
- String[] list = sourceDir.list(new DesirableFilter());
-
- if (list == null) {
- return; //-- nothing to do
- }
-
- for (int i = 0; i < list.length; i++) {
-
- String filename = list[i];
-
- File inFile = new File(sourceDir, filename);
-
- //-- if inFile is a directory, recursively process it
- if (inFile.isDirectory()) {
- if (!excluded(filename)) {
- new File(destDir, filename).mkdir();
- process(inFile, new File(destDir, filename));
- }
- }
- //-- process XML files
- else if (hasXMLFileExtension(filename) && ! excluded(filename)) {
-
- //-- replace extension with the target extension
- int idx = filename.lastIndexOf('.');
-
- File outFile = new File(destDir,
- filename.substring(0,idx) + targetExt);
-
- if ((inFile.lastModified() > outFile.lastModified()) ||
- (xslFile != null && xslFile.lastModified() > outFile.lastModified()))
- {
- processXML(inFile, outFile);
- }
- }
- else {
- File outFile = new File(destDir, filename);
- if (inFile.lastModified() > outFile.lastModified()) {
- try {
- copyFile(inFile, outFile);
- }
- catch(java.io.IOException ex) {
- String err = "error copying file: ";
- err += inFile.getAbsolutePath();
- err += "; " + ex.getMessage();
- throw new BuildException(err, ex);
- }
- //filecopyList.put(srcFile.getAbsolutePath(),
- //destFile.getAbsolutePath());
- }
- }
- } //--
- } //-- process(File, File)
- */
-
- /**
- * Processes the given input XML file and stores the result
- * in the given resultFile.
- **/
- private void process(File baseDir,String xmlFile,File destDir)
- throws BuildException
- {
- String fileExt=targetExtension;
- File outFile=null;
- File inFile=null;
-
- try {
- inFile = new File(baseDir,xmlFile);
- outFile = new File(destDir,xmlFile.substring(0,xmlFile.lastIndexOf('.'))+fileExt);
- if (inFile.lastModified() > outFile.lastModified()) {
- //-- command line status
- project.log("Processing " + xmlFile + " to " + outFile,project.MSG_VERBOSE);
-
- liaison.transform(inFile.toString(), outFile.toString());
- }
- }
- catch (Exception ex) {
- // If failed to process document, must delete target document,
- // or it will not attempt to process it the second time
- project.log("Failed to process " + inFile,project.MSG_INFO);
- outFile.delete();
- throw new BuildException(ex);
- }
-
- } //-- processXML
-
-} //-- XSLTProcess
diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java
deleted file mode 100644
index 1af5fc920e..0000000000
--- 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
- * When this task executes, it will recursively scan the srcdir
- * looking for NetRexx source files to compile. This task makes its
- * compile decision based on timestamp.
- * Before files are compiled they and any other file in the
- * srcdir will be copied to the destdir allowing support files to be
- * located properly in the classpath. The reason for copying the source files
- * before the compile is that NetRexxC has only two destinations for classfiles:
- *
- * You should never have a need to access this class directly.
- * TarBuffers are created by Tar IO Streams.
- *
- * @author Timothy Gerard Endres time@ice.com
- */
-
-public class TarBuffer {
-
- public static final int DEFAULT_RCDSIZE = (512);
- public static final int DEFAULT_BLKSIZE = (DEFAULT_RCDSIZE * 20);
-
- private InputStream inStream;
- private OutputStream outStream;
- private byte[] blockBuffer;
- private int currBlkIdx;
- private int currRecIdx;
- private int blockSize;
- private int recordSize;
- private int recsPerBlock;
- private boolean debug;
-
- public TarBuffer(InputStream inStream) {
- this(inStream, TarBuffer.DEFAULT_BLKSIZE);
- }
-
- public TarBuffer(InputStream inStream, int blockSize) {
- this(inStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
- }
-
- public TarBuffer(InputStream inStream, int blockSize, int recordSize) {
- this.inStream = inStream;
- this.outStream = null;
-
- this.initialize(blockSize, recordSize);
- }
-
- public TarBuffer(OutputStream outStream) {
- this(outStream, TarBuffer.DEFAULT_BLKSIZE);
- }
-
- public TarBuffer(OutputStream outStream, int blockSize) {
- this(outStream, blockSize, TarBuffer.DEFAULT_RCDSIZE);
- }
-
- public TarBuffer(OutputStream outStream, int blockSize, int recordSize) {
- this.inStream = null;
- this.outStream = outStream;
-
- this.initialize(blockSize, recordSize);
- }
-
- /**
- * Initialization common to all constructors.
- */
- private void initialize(int blockSize, int recordSize) {
- this.debug = false;
- this.blockSize = blockSize;
- this.recordSize = recordSize;
- this.recsPerBlock = (this.blockSize / this.recordSize);
- this.blockBuffer = new byte[this.blockSize];
-
- if (this.inStream != null) {
- this.currBlkIdx = -1;
- this.currRecIdx = this.recsPerBlock;
- } else {
- this.currBlkIdx = 0;
- this.currRecIdx = 0;
- }
- }
-
- /**
- * Get the TAR Buffer's block size. Blocks consist of multiple records.
- */
- public int getBlockSize() {
- return this.blockSize;
- }
-
- /**
- * Get the TAR Buffer's record size.
- */
- public int getRecordSize() {
- return this.recordSize;
- }
-
- /**
- * Set the debugging flag for the buffer.
- *
- * @param debug If true, print debugging output.
- */
- public void setDebug(boolean debug) {
- this.debug = debug;
- }
-
- /**
- * Determine if an archive record indicate End of Archive. End of
- * archive is indicated by a record that consists entirely of null bytes.
- *
- * @param record The record data to check.
- */
- public boolean isEOFRecord(byte[] record) {
- for (int i = 0, sz = this.getRecordSize(); i < sz; ++i) {
- if (record[i] != 0) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Skip over a record on the input stream.
- */
- public void skipRecord() throws IOException {
- if (this.debug) {
- System.err.println("SkipRecord: recIdx = " + this.currRecIdx
- + " blkIdx = " + this.currBlkIdx);
- }
-
- if (this.inStream == null) {
- throw new IOException("reading (via skip) from an output buffer");
- }
-
- if (this.currRecIdx >= this.recsPerBlock) {
- if (!this.readBlock()) {
- return; // UNDONE
- }
- }
-
- this.currRecIdx++;
- }
-
- /**
- * Read a record from the input stream and return the data.
- *
- * @return The record data.
- */
- public byte[] readRecord() throws IOException {
- if (this.debug) {
- System.err.println("ReadRecord: recIdx = " + this.currRecIdx
- + " blkIdx = " + this.currBlkIdx);
- }
-
- if (this.inStream == null) {
- throw new IOException("reading from an output buffer");
- }
-
- if (this.currRecIdx >= this.recsPerBlock) {
- if (!this.readBlock()) {
- return null;
- }
- }
-
- byte[] result = new byte[this.recordSize];
-
- System.arraycopy(this.blockBuffer,
- (this.currRecIdx * this.recordSize), result, 0,
- this.recordSize);
-
- this.currRecIdx++;
-
- return result;
- }
-
- /**
- * @return false if End-Of-File, else true
- */
- private boolean readBlock() throws IOException {
- if (this.debug) {
- System.err.println("ReadBlock: blkIdx = " + this.currBlkIdx);
- }
-
- if (this.inStream == null) {
- throw new IOException("reading from an output buffer");
- }
-
- this.currRecIdx = 0;
-
- int offset = 0;
- int bytesNeeded = this.blockSize;
-
- while (bytesNeeded > 0) {
- long numBytes = this.inStream.read(this.blockBuffer, offset,
- bytesNeeded);
-
- //
- // NOTE
- // We have fit EOF, and the block is not full!
- //
- // This is a broken archive. It does not follow the standard
- // blocking algorithm. However, because we are generous, and
- // it requires little effort, we will simply ignore the error
- // and continue as if the entire block were read. This does
- // not appear to break anything upstream. We used to return
- // false in this case.
- //
- // Thanks to 'Yohann.Roussel@alcatel.fr' for this fix.
- //
- if (numBytes == -1) {
- break;
- }
-
- offset += numBytes;
- bytesNeeded -= numBytes;
-
- if (numBytes != this.blockSize) {
- if (this.debug) {
- System.err.println("ReadBlock: INCOMPLETE READ "
- + numBytes + " of " + this.blockSize
- + " bytes read.");
- }
- }
- }
-
- this.currBlkIdx++;
-
- return true;
- }
-
- /**
- * Get the current block number, zero based.
- *
- * @return The current zero based block number.
- */
- public int getCurrentBlockNum() {
- return this.currBlkIdx;
- }
-
- /**
- * Get the current record number, within the current block, zero based.
- * Thus, current offset = (currentBlockNum * recsPerBlk) + currentRecNum.
- *
- * @return The current zero based record number.
- */
- public int getCurrentRecordNum() {
- return this.currRecIdx - 1;
- }
-
- /**
- * Write an archive record to the archive.
- *
- * @param record The record data to write to the archive.
- */
- public void writeRecord(byte[] record) throws IOException {
- if (this.debug) {
- System.err.println("WriteRecord: recIdx = " + this.currRecIdx
- + " blkIdx = " + this.currBlkIdx);
- }
-
- if (this.outStream == null) {
- throw new IOException("writing to an input buffer");
- }
-
- if (record.length != this.recordSize) {
- throw new IOException("record to write has length '"
- + record.length
- + "' which is not the record size of '"
- + this.recordSize + "'");
- }
-
- if (this.currRecIdx >= this.recsPerBlock) {
- this.writeBlock();
- }
-
- System.arraycopy(record, 0, this.blockBuffer,
- (this.currRecIdx * this.recordSize),
- this.recordSize);
-
- this.currRecIdx++;
- }
-
- /**
- * Write an archive record to the archive, where the record may be
- * inside of a larger array buffer. The buffer must be "offset plus
- * record size" long.
- *
- * @param buf The buffer containing the record data to write.
- * @param offset The offset of the record data within buf.
- */
- public void writeRecord(byte[] buf, int offset) throws IOException {
- if (this.debug) {
- System.err.println("WriteRecord: recIdx = " + this.currRecIdx
- + " blkIdx = " + this.currBlkIdx);
- }
-
- if (this.outStream == null) {
- throw new IOException("writing to an input buffer");
- }
-
- if ((offset + this.recordSize) > buf.length) {
- throw new IOException("record has length '" + buf.length
- + "' with offset '" + offset
- + "' which is less than the record size of '"
- + this.recordSize + "'");
- }
-
- if (this.currRecIdx >= this.recsPerBlock) {
- this.writeBlock();
- }
-
- System.arraycopy(buf, offset, this.blockBuffer,
- (this.currRecIdx * this.recordSize),
- this.recordSize);
-
- this.currRecIdx++;
- }
-
- /**
- * Write a TarBuffer block to the archive.
- */
- private void writeBlock() throws IOException {
- if (this.debug) {
- System.err.println("WriteBlock: blkIdx = " + this.currBlkIdx);
- }
-
- if (this.outStream == null) {
- throw new IOException("writing to an input buffer");
- }
-
- this.outStream.write(this.blockBuffer, 0, this.blockSize);
- this.outStream.flush();
-
- this.currRecIdx = 0;
- this.currBlkIdx++;
- }
-
- /**
- * Flush the current data block if it has any data in it.
- */
- private void flushBlock() throws IOException {
- if (this.debug) {
- System.err.println("TarBuffer.flushBlock() called.");
- }
-
- if (this.outStream == null) {
- throw new IOException("writing to an input buffer");
- }
-
- if (this.currRecIdx > 0) {
- this.writeBlock();
- }
- }
-
- /**
- * Close the TarBuffer. If this is an output buffer, also flush the
- * current block before closing.
- */
- public void close() throws IOException {
- if (this.debug) {
- System.err.println("TarBuffer.closeBuffer().");
- }
-
- if (this.outStream != null) {
- this.flushBlock();
-
- if (this.outStream != System.out
- && this.outStream != System.err) {
- this.outStream.close();
-
- this.outStream = null;
- }
- } else if (this.inStream != null) {
- if (this.inStream != System.in) {
- this.inStream.close();
-
- this.inStream = null;
- }
- }
- }
-}
diff --git a/src/main/org/apache/tools/tar/TarConstants.java b/src/main/org/apache/tools/tar/TarConstants.java
deleted file mode 100644
index 41b76c3271..0000000000
--- 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
- *
- * TarEntries that are created from the header bytes read from
- * an archive are instantiated with the TarEntry( byte[] )
- * constructor. These entries will be used when extracting from
- * or listing the contents of an archive. These entries have their
- * header filled in using the header bytes. They also set the File
- * to null, since they reference an archive entry not a file.
- *
- * TarEntries that are created from Files that are to be written
- * into an archive are instantiated with the TarEntry( File )
- * constructor. These entries have their header filled in using
- * the File's information. They also keep a reference to the File
- * for convenience when writing entries.
- *
- * Finally, TarEntries can be constructed from nothing but a name.
- * This allows the programmer to construct the entry by hand, for
- * instance when only an InputStream is available for writing to
- * the archive, and the header information is constructed from
- * other information. In this case the header fields are set to
- * defaults and the File is set to null.
- *
- *
- * The C structure for a Tar Entry's header is:
- *
- *
- *
- *
- * @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 470270d136..0000000000
--- 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
- *
- *
- * Of these arguments, only sourcedir is required.
- *
- */
- 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:
- *
- *
- */
- 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:
- *
- *
- */
- 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:
- *
- *
- */
- 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; ktrue".
- *
- * @param v if "true" then be verbose
- */
- public void setVerbose(String v) {
- verbose = v;
- }
-
- /**
- * Don't stop if get fails if set to "true".
- *
- * @param v if "true" then be verbose
- */
- public void setIgnoreErrors(String v) {
- ignoreErrors = v;
- }
-}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Jar.java b/src/main/org/apache/tools/ant/taskdefs/Jar.java
deleted file mode 100644
index 37a30402be..0000000000
--- 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
- *
- *
- * Of these arguments, the sourcedir and destdir are required.
- * on, if an existing file should be replaced.
- */
- public void setReplace(String replace) {
- this.replace = project.toBoolean(replace);
- }
-
-
- /**
- * Renames the file src to dest
- * @exception org.apache.tools.ant.BuildException The exception is
- * thrown, if the rename operation fails.
- */
- public void execute() throws BuildException {
- if (replace && dest.exists()) {
- if (!dest.delete()) {
- throw new BuildException("Unable to remove existing file " +
- dest);
- }
- }
- if (!src.renameTo(dest)) {
- throw new BuildException("Unable to rename " + src + " to " +
- dest);
- }
- }
-}
diff --git a/src/main/org/apache/tools/ant/taskdefs/Replace.java b/src/main/org/apache/tools/ant/taskdefs/Replace.java
deleted file mode 100644
index ae9a1fc8ca..0000000000
--- 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
- *
- *
- * Of these arguments, the base and class are required.
- *
- *
- * Of these arguments, the sourcedir and destdir are required.
- *
- *
- * Of these arguments, the srcdir argument is required.
- *
- *
- *
- *
- * @author dIon Gillard dion@multitask.com.au
- */
-
-public class NetRexxC extends MatchingTask {
-
- // variables to hold arguments
- private boolean binary;
- private String classpath;
- private boolean comments;
- private boolean compact;
- private boolean compile = true;
- private boolean console;
- private boolean crossref;
- private boolean decimal = true;
- private File destDir;
- private boolean diag;
- private boolean explicit;
- private boolean format;
- private boolean java;
- private boolean keep;
- private boolean logo = true;
- private boolean replace;
- private boolean savelog;
- private File srcDir;
- private boolean sourcedir = true; // ?? Should this be the default for ant?
- private boolean strictargs;
- private boolean strictassign;
- private boolean strictcase;
- private boolean strictimport;
- private boolean strictprops;
- private boolean strictsignal;
- private boolean symbols;
- private boolean time;
- private String trace = "trace2";
- private boolean utf8;
- private String verbose = "verbose3";
-
- // other implementation variables
- private Vector compileList = new Vector();
- private Hashtable filecopyList = new Hashtable();
- private String oldClasspath = System.getProperty("java.class.path");
-
-
- /**
- * Set whether literals are treated as binary, rather than NetRexx types
- */
- public void setBinary(String binary) {
- this.binary = Project.toBoolean(binary);
- }
-
- /**
- * Set the classpath used for NetRexx compilation
- */
- public void setClasspath(String classpath) {
- this.classpath = classpath;
- }
-
- /**
- * Set whether comments are passed through to the generated java source.
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false
- */
- public void setComments(String comments) {
- this.comments = Project.toBoolean(comments);
- }
-
- /**
- * Set whether error messages come out in compact or verbose format.
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false
- */
- public void setCompact(String compact) {
- this.compact = Project.toBoolean(compact);
- }
-
- /**
- * Set whether the NetRexx compiler should compile the generated java code
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is true.
- * Setting this flag to false, will automatically set the keep flag to true.
- */
- public void setCompile(String compile) {
- this.compile = Project.toBoolean(compile);
- if (!this.compile && !this.keep) this.keep = true;
- }
-
- /**
- * Set whether or not messages should be displayed on the 'console'
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is true.
- */
- public void setConsole(String console) {
- this.console = Project.toBoolean(console);
- }
-
- /**
- * Whether variable cross references are generated
- */
- public void setCrossref(String crossref) {
- this.crossref = Project.toBoolean(crossref);
- }
-
- /**
- * Set whether decimal arithmetic should be used for the netrexx code.
- * Binary arithmetic is used when this flag is turned off.
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is true.
- */
- public void setDecimal(String decimal) {
- this.decimal = Project.toBoolean(decimal);
- }
-
- /**
- * Set the destination directory into which the NetRexx source
- * files should be copied and then compiled.
- */
- public void setDestDir(String destDirName) {
- destDir = project.resolveFile(destDirName);
- }
-
- /**
- * Whether diagnostic information about the compile is generated
- */
- public void setDiag(String diag) {
- this.diag = Project.toBoolean(diag);
- }
-
- /**
- * Sets whether variables must be declared explicitly before use.
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setExplicit(String explicit) {
- this.explicit = Project.toBoolean(explicit);
- }
-
- /**
- * Whether the generated java code is formatted nicely or left to match NetRexx
- * line numbers for call stack debugging
- */
- public void setFormat(String format) {
- this.format = Project.toBoolean(format);
- }
-
- /**
- * Whether the generated java code is produced
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setJava(String java) {
- this.java = Project.toBoolean(java);
- }
-
-
- /**
- * Sets whether the generated java source file should be kept after compilation.
- * The generated files will have an extension of .java.keep, not .java
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setKeep(String keep) {
- this.keep = Project.toBoolean(keep);
- }
-
- /**
- * Whether the compiler text logo is displayed when compiling
- */
- public void setLogo(String logo) {
- this.logo = Project.toBoolean(logo);
- }
-
- /**
- * Whether the generated .java file should be replaced when compiling
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setReplace(String replace) {
- this.replace = Project.toBoolean(replace);
- }
-
- /**
- * Sets whether the compiler messages will be written to NetRexxC.log as
- * well as to the console
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setSavelog(String savelog) {
- this.savelog = Project.toBoolean(savelog);
- }
-
- /**
- * Tells the NetRexx compiler to store the class files in the same directory
- * as the source files. The alternative is the working directory
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is true.
- */
- public void setSourcedir(String sourcedir) {
- this.sourcedir = Project.toBoolean(sourcedir);
- }
-
- /**
- * Set the source dir to find the source Java files.
- */
- public void setSrcDir(String srcDirName) {
- srcDir = project.resolveFile(srcDirName);
- }
-
- /**
- * Tells the NetRexx compiler that method calls always need parentheses,
- * even if no arguments are needed, e.g. aStringVar.getBytes
- * vs. aStringVar.getBytes()
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setStrictargs(String strictargs) {
- this.strictargs = Project.toBoolean(strictargs);
- }
-
- /**
- * Tells the NetRexx compile that assignments must match exactly on type
- */
- public void setStrictassign(String strictassign) {
- this.strictassign = Project.toBoolean(strictassign);
- }
-
- /**
- * Specifies whether the NetRexx compiler should be case sensitive or not
- */
- public void setStrictcase(String strictcase) {
- this.strictcase = Project.toBoolean(strictcase);
- }
-
- /**
- * Sets whether classes need to be imported explicitly using an
- * import statement. By default the NetRexx compiler will import
- * certain packages automatically
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setStrictimport(String strictimport) {
- this.strictimport = Project.toBoolean(strictimport);
- }
-
- /**
- * Sets whether local properties need to be qualified explicitly using this
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setStrictprops(String strictprops) {
- this.strictprops = Project.toBoolean(strictprops);
- }
-
-
- /**
- * Whether the compiler should force catching of exceptions by explicitly named types
- */
- public void setStrictsignal(String strictsignal) {
- this.strictsignal = Project.toBoolean(strictsignal);
- }
-
- /**
- * Sets whether debug symbols should be generated into the class file
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setSymbols(String symbols) {
- this.symbols = Project.toBoolean(symbols);
- }
-
- /**
- * Asks the NetRexx compiler to print compilation times to the console
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setTime(String time) {
- this.time = Project.toBoolean(time);
- }
-
- /**
- * Turns on or off tracing and directs the resultant trace output
- * Valid values are: "trace", "trace1", "trace2" and "notrace".
- * "trace" and "trace2"
- */
- public void setTrace(String trace) {
- if (trace.equalsIgnoreCase("trace")
- || trace.equalsIgnoreCase("trace1")
- || trace.equalsIgnoreCase("trace2")
- || trace.equalsIgnoreCase("notrace")) {
- this.trace = trace;
- } else {
- throw new BuildException("Unknown trace value specified: '" + trace + "'");
- }
- }
-
- /**
- * Tells the NetRexx compiler that the source is in UTF8
- * Valid true values are "on" or "true". Anything else sets the flag to false.
- * The default value is false.
- */
- public void setUtf8(String utf8) {
- this.utf8 = Project.toBoolean(utf8);
- }
-
- /**
- * Whether lots of warnings and error messages should be generated
- */
- public void setVerbose(String verbose) {
- this.verbose = verbose;
- }
-
- /**
- * Executes the task, i.e. does the actual compiler call
- */
- public void execute() throws BuildException {
-
- // first off, make sure that we've got a srcdir and destdir
- if (srcDir == null || destDir == null ) {
- throw new BuildException("srcDir and destDir attributes must be set!");
- }
-
- // scan source and dest dirs to build up both copy lists and
- // compile lists
- // scanDir(srcDir, destDir);
- DirectoryScanner ds = getDirectoryScanner(srcDir);
-
- String[] files = ds.getIncludedFiles();
-
- scanDir(srcDir, destDir, files);
-
- // copy the source and support files
- copyFilesToDestination();
-
- // compile the source files
- if (compileList.size() > 0) {
- project.log("Compiling " + compileList.size() + " source files to " + destDir);
- doNetRexxCompile();
- }
- }
-
- /**
- * Scans the directory looking for source files to be compiled and
- * support files to be copied.
- */
- private void scanDir(File srcDir, File destDir, String[] files) {
- for (int i = 0; i < files.length; i++) {
- File srcFile = new File(srcDir, files[i]);
- File destFile = new File(destDir, files[i]);
- String filename = files[i];
- // if it's a non source file, copy it if a later date than the
- // dest
- // if it's a source file, see if the destination class file
- // needs to be recreated via compilation
- if (filename.toLowerCase().endsWith(".nrx")) {
- File classFile = new File(destDir, filename.substring(0, filename.lastIndexOf('.')) + ".class");
- if (!compile || srcFile.lastModified() > classFile.lastModified()) {
- filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath());
- compileList.addElement(destFile.getAbsolutePath());
- }
- } else {
- if (srcFile.lastModified() > destFile.lastModified()) {
- filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath());
- }
- }
- }
- }
-
- /**
- * Copy eligible files from the srcDir to destDir
- */
- private void copyFilesToDestination() {
- if (filecopyList.size() > 0) {
- project.log("Copying " + filecopyList.size() + " files to " + destDir.getAbsolutePath());
- Enumeration enum = filecopyList.keys();
- while (enum.hasMoreElements()) {
- String fromFile = (String)enum.nextElement();
- String toFile = (String)filecopyList.get(fromFile);
- try {
- project.copyFile(fromFile, toFile);
- } catch (IOException ioe) {
- String msg = "Failed to copy " + fromFile + " to " + toFile
- + " due to " + ioe.getMessage();
- throw new BuildException(msg, ioe);
- }
- }
- }
- }
-
- /**
- * Peforms a copmile using the NetRexx 1.1.x compiler
- */
- private void doNetRexxCompile() throws BuildException {
- project.log("Using NetRexx compiler", project.MSG_VERBOSE);
- String classpath = getCompileClasspath();
- StringBuffer compileOptions = new StringBuffer();
- StringBuffer fileList = new StringBuffer();
-
- // create an array of strings for input to the compiler: one array
- // comes from the compile options, the other from the compileList
- String[] compileOptionsArray = getCompileOptionsAsArray();
- String[] fileListArray = new String[compileList.size()];
- Enumeration e = compileList.elements();
- int j = 0;
- while (e.hasMoreElements()) {
- fileListArray[j] = (String)e.nextElement();
- j++;
- }
- // create a single array of arguments for the compiler
- String compileArgs[] = new String[compileOptionsArray.length + fileListArray.length];
- for (int i = 0; i < compileOptionsArray.length; i++) {
- compileArgs[i] = compileOptionsArray[i];
- }
- for (int i = 0; i < fileListArray.length; i++) {
- compileArgs[i+compileOptionsArray.length] = fileListArray[i];
- }
-
- // print nice output about what we are doing for the log
- compileOptions.append("Compilation args: ");
- for (int i = 0; i < compileOptionsArray.length; i++) {
- compileOptions.append(compileOptionsArray[i]);
- compileOptions.append(" ");
- }
- project.log(compileOptions.toString(), project.MSG_VERBOSE);
-
- String eol = System.getProperty("line.separator");
- StringBuffer niceSourceList = new StringBuffer("Files to be compiled:" + eol);
-
- for (int i = 0; i < compileList.size(); i++) {
- niceSourceList.append(" ");
- niceSourceList.append(compileList.elementAt(i).toString());
- niceSourceList.append(eol);
- }
-
- project.log(niceSourceList.toString(), project.MSG_VERBOSE);
-
- // need to set java.class.path property and restore it later
- // since the NetRexx compiler has no option for the classpath
- String currentClassPath = System.getProperty("java.class.path");
- Properties currentProperties = System.getProperties();
- currentProperties.put("java.class.path", classpath);
-
- try {
- StringWriter out = new StringWriter();
- int rc = COM.ibm.netrexx.process.NetRexxC.main(
- new Rexx(compileArgs), new PrintWriter(out));
-
- if (rc > 1) { // 1 is warnings from real NetRexxC
- project.log(out.toString(), Project.MSG_ERR);
- String msg = "Compile failed, messages should have been provided.";
- throw new BuildException(msg);
- }
- else if (rc == 1) {
- project.log(out.toString(), Project.MSG_WARN);
- }
- else {
- project.log(out.toString(), Project.MSG_INFO);
- }
- } finally {
- // need to reset java.class.path property
- // since the NetRexx compiler has no option for the classpath
- currentProperties = System.getProperties();
- currentProperties.put("java.class.path", currentClassPath);
- }
- }
-
- /**
- * Builds the compilation classpath.
- */
- private String getCompileClasspath() {
- StringBuffer classpath = new StringBuffer();
-
- // add dest dir to classpath so that previously compiled and
- // untouched classes are on classpath
- classpath.append(destDir.getAbsolutePath());
-
- // add our classpath to the mix
- if (this.classpath != null) {
- addExistingToClasspath(classpath, this.classpath);
- }
-
- // add the system classpath
- // addExistingToClasspath(classpath,System.getProperty("java.class.path"));
- return classpath.toString();
- }
-
- /**
- * This
- */
- private String[] getCompileOptionsAsArray() {
- Vector options = new Vector();
- options.addElement(binary ? "-binary" : "-nobinary");
- options.addElement(comments ? "-comments" : "-nocomments");
- options.addElement(compile ? "-compile" : "-nocompile");
- options.addElement(compact ? "-compact" : "-nocompact");
- options.addElement(console ? "-console" : "-noconsole");
- options.addElement(crossref ? "-crossref" : "-nocrossref");
- options.addElement(decimal ? "-decimal" : "-nodecimal");
- options.addElement(diag ? "-diag" : "-nodiag");
- options.addElement(explicit ? "-explicit": "-noexplicit");
- options.addElement(format ? "-format" : "-noformat");
- options.addElement(keep ? "-keep" : "-nokeep");
- options.addElement(logo ? "-logo" : "-nologo");
- options.addElement(replace ? "-replace" : "-noreplace");
- options.addElement(savelog ? "-savelog" : "-nosavelog");
- options.addElement(sourcedir ? "-sourcedir" : "-nosourcedir");
- options.addElement(strictargs ? "-strictargs" : "-nostrictargs");
- options.addElement(strictassign ? "-strictassign" : "-nostrictassign");
- options.addElement(strictcase ? "-strictcase": "-nostrictcase");
- options.addElement(strictimport ? "-strictimport" : "-nostrictimport");
- options.addElement(strictprops ? "-strictprops" : "-nostrictprops");
- options.addElement(strictsignal ? "-strictsignal" : "-nostrictsignal");
- options.addElement(symbols ? "-symbols" : "-nosymbols");
- options.addElement(time ? "-time" : "-notime");
- options.addElement("-" + trace);
- options.addElement(utf8 ? "-utf8" : "-noutf8");
- options.addElement("-" + verbose);
- String[] results = new String[options.size()];
- options.copyInto(results);
- return results;
- }
- /**
- * Takes a classpath-like string, and adds each element of
- * this string to a new classpath, if the components exist.
- * Components that don't exist, aren't added.
- * We do this, because jikes issues warnings for non-existant
- * files/dirs in his classpath, and these warnings are pretty
- * annoying.
- * @param target - target classpath
- * @param source - source classpath
- * to get file objects.
- */
- private void addExistingToClasspath(StringBuffer target,String source) {
- StringTokenizer tok = new StringTokenizer(source,
- System.getProperty("path.separator"), false);
- while (tok.hasMoreTokens()) {
- File f = project.resolveFile(tok.nextToken());
-
- if (f.exists()) {
- target.append(File.pathSeparator);
- target.append(f.getAbsolutePath());
- } else {
- project.log("Dropping from classpath: "+
- f.getAbsolutePath(),project.MSG_VERBOSE);
- }
- }
-
- }
-}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java b/src/main/org/apache/tools/ant/taskdefs/optional/RenameExtensions.java
deleted file mode 100644
index bcd2df1aee..0000000000
--- 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
- *
- *
- *
- * @author dIon Gillard dion@multitask.com.au
- * @version 1.2
- */
-
-package org.apache.tools.ant.taskdefs.optional;
-
-import java.io.*;
-import java.util.*;
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
-
-/**
- *
- * @author dion
- */
-public class RenameExtensions extends MatchingTask {
-
- private String fromExtension = "";
- private String toExtension = "";
- private boolean replace = false;
- private File srcDir;
-
-
- /** Creates new RenameExtensions */
- public RenameExtensions() {
- super();
- }
-
- /** store fromExtension **/
- public void setFromExtension(String from) {
- fromExtension = from;
- }
-
- /** store toExtension **/
- public void setToExtension(String to) {
- toExtension = to;
- }
-
- /**
- * store replace attribute - this determines whether the target file
- * should be overwritten if present
- */
- public void setReplace(String replaceString) {
- replace = Project.toBoolean(replaceString);
- }
-
- /**
- * Set the source dir to find the files to be renamed.
- */
- public void setSrcDir(String srcDirName) {
- srcDir = project.resolveFile(srcDirName);
- }
-
- /**
- * Executes the task, i.e. does the actual compiler call
- */
- public void execute() throws BuildException {
-
- // first off, make sure that we've got a from and to extension
- if (fromExtension == null || toExtension == null || srcDir == null) {
- throw new BuildException("srcDir, fromExtension and toExtension attributes must be set!");
- }
-
- // scan source and dest dirs to build up rename list
- DirectoryScanner ds = getDirectoryScanner(srcDir);
-
- String[] files = ds.getIncludedFiles();
-
- Hashtable renameList = scanDir(srcDir, files);
-
- Enumeration e = renameList.keys();
- File fromFile = null;
- File toFile = null;
- while (e.hasMoreElements()) {
- fromFile = (File)e.nextElement();
- toFile = (File)renameList.get(fromFile);
- if (toFile.exists() && replace) toFile.delete();
- if (!fromFile.renameTo(toFile)) throw new BuildException("Rename from: '" + fromFile + "' to '" + toFile + "' failed.");
- }
-
- }
- private Hashtable scanDir(File srcDir, String[] files) {
- Hashtable list = new Hashtable();
- for (int i = 0; i < files.length; i++) {
- File srcFile = new File(srcDir, files[i]);
- String filename = files[i];
- // if it's a file that ends in the fromExtension, copy to the rename list
- if (filename.toLowerCase().endsWith(fromExtension)) {
- File destFile = new File(srcDir, filename.substring(0, filename.lastIndexOf(fromExtension)) + toExtension);
- if (replace || !destFile.exists()) {
- list.put(srcFile, destFile);
- } else {
- project.log("Rejecting file: '" + srcFile + "' for rename as replace is false and file exists", Project.MSG_VERBOSE);
- }
- } else {
- project.log("File '"+ filename + "' doesn't match fromExtension: '" + fromExtension + "'", Project.MSG_VERBOSE);
- }
- }
- return list;
- }
-
-}
diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/Script.java b/src/main/org/apache/tools/ant/taskdefs/optional/Script.java
deleted file mode 100644
index 86ddc12fdd..0000000000
--- 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
- *
- * struct header {
- * char name[NAMSIZ];
- * char mode[8];
- * char uid[8];
- * char gid[8];
- * char size[12];
- * char mtime[12];
- * char chksum[8];
- * char linkflag;
- * char linkname[NAMSIZ];
- * char magic[8];
- * char uname[TUNMLEN];
- * char gname[TGNMLEN];
- * char devmajor[8];
- * char devminor[8];
- * } header;
- *
- *
- * @author Timothy Gerard Endres time@ice.com
- * @author Stefano Mazzocchi stefano@apache.org
- */
-
-public class TarEntry implements TarConstants {
-
- private StringBuffer name; /** The entry's name. */
- private int mode; /** The entry's permission mode. */
- private int userId; /** The entry's user id. */
- private int groupId; /** The entry's group id. */
- private long size; /** The entry's size. */
- private long modTime; /** The entry's modification time. */
- private int checkSum; /** The entry's checksum. */
- private byte linkFlag; /** The entry's link flag. */
- private StringBuffer linkName; /** The entry's link name. */
- private StringBuffer magic; /** The entry's magic tag. */
- private StringBuffer userName; /** The entry's user name. */
- private StringBuffer groupName; /** The entry's group name. */
- private int devMajor; /** The entry's major device number. */
- private int devMinor; /** The entry's minor device number. */
- private File file; /** The entry's file reference */
-
- /**
- * Construct an empty entry and prepares the header values.
- */
- private TarEntry () {
- this.magic = new StringBuffer(TMAGIC);
- this.name = new StringBuffer();
- this.linkName = new StringBuffer();
-
- String user = System.getProperty("user.name", "");
-
- if (user.length() > 31) {
- user = user.substring(0, 31);
- }
-
- this.userId = 0;
- this.groupId = 0;
- this.userName = new StringBuffer(user);
- this.groupName = new StringBuffer("");
- this.file = null;
- }
-
- /**
- * Construct an entry with only a name. This allows the programmer
- * to construct the entry's header "by hand". File is set to null.
- */
- public TarEntry(String name) {
- this();
-
- boolean isDir = name.endsWith("/");
-
- this.checkSum = 0;
- this.devMajor = 0;
- this.devMinor = 0;
- this.name = new StringBuffer(name);
- this.mode = isDir ? 040755 : 0100644;
- this.linkFlag = isDir ? LF_DIR : LF_NORMAL;
- this.userId = 0;
- this.groupId = 0;
- this.size = 0;
- this.checkSum = 0;
- this.modTime = (new Date()).getTime() / 1000;
- this.linkName = new StringBuffer("");
- this.userName = new StringBuffer("");
- this.groupName = new StringBuffer("");
- this.devMajor = 0;
- this.devMinor = 0;
- }
-
- /**
- * Construct an entry for a file. File is set to file, and the
- * header is constructed from information from the file.
- *
- * @param file The file that the entry represents.
- */
- public TarEntry(File file) {
- this();
-
- this.file = file;
-
- String name = file.getPath();
- String osname = System.getProperty("os.name");
-
- if (osname != null) {
-
- // Strip off drive letters!
- // REVIEW Would a better check be "(File.separator == '\')"?
- String Win32Prefix = "Windows";
- String prefix = osname.substring(0, Win32Prefix.length());
-
- if (prefix.equalsIgnoreCase(Win32Prefix)) {
- if (name.length() > 2) {
- char ch1 = name.charAt(0);
- char ch2 = name.charAt(1);
-
- if (ch2 == ':'
- && ((ch1 >= 'a' && ch1 <= 'z')
- || (ch1 >= 'A' && ch1 <= 'Z'))) {
- name = name.substring(2);
- }
- }
- }
- }
-
- name = name.replace(File.separatorChar, '/');
-
- // No absolute pathnames
- // Windows (and Posix?) paths can start with "\\NetworkDrive\",
- // so we loop on starting /'s.
- while (name.startsWith("/")) {
- name = name.substring(1);
- }
-
- this.linkName = new StringBuffer("");
- this.name = new StringBuffer(name);
-
- if (file.isDirectory()) {
- this.mode = 040755;
- this.linkFlag = LF_DIR;
-
- if (this.name.charAt(this.name.length() - 1) != '/') {
- this.name.append("/");
- }
- } else {
- this.mode = 0100644;
- this.linkFlag = LF_NORMAL;
- }
-
- if (this.name.length() > NAMELEN) {
- throw new RuntimeException("file name '" + this.name
- + "' is too long ( > "
- + NAMELEN + " bytes)");
-
- // UNDONE When File lets us get the userName, use it!
- }
-
- this.size = file.length();
- this.modTime = file.lastModified() / 1000;
- this.checkSum = 0;
- this.devMajor = 0;
- this.devMinor = 0;
- }
-
- /**
- * Construct an entry from an archive's header bytes. File is set
- * to null.
- *
- * @param headerBuf The header bytes from a tar archive entry.
- */
- public TarEntry(byte[] headerBuf) {
- this();
- this.parseTarHeader(headerBuf);
- }
-
- /**
- * Determine if the two entries are equal. Equality is determined
- * by the header names being equal.
- *
- * @return it Entry to be checked for equality.
- * @return True if the entries are equal.
- */
- public boolean equals(TarEntry it) {
- return this.getName().equals(it.getName());
- }
-
- /**
- * Determine if the given entry is a descendant of this entry.
- * Descendancy is determined by the name of the descendant
- * starting with this entry's name.
- *
- * @param desc Entry to be checked as a descendent of this.
- * @return True if entry is a descendant of this.
- */
- public boolean isDescendent(TarEntry desc) {
- return desc.getName().startsWith(this.getName());
- }
-
- /**
- * Get this entry's name.
- *
- * @return This entry's name.
- */
- public String getName() {
- return this.name.toString();
- }
-
- /**
- * Set this entry's name.
- *
- * @param name This entry's new name.
- */
- public void setName(String name) {
- this.name = new StringBuffer(name);
- }
-
- /**
- * Get this entry's user id.
- *
- * @return This entry's user id.
- */
- public int getUserId() {
- return this.userId;
- }
-
- /**
- * Set this entry's user id.
- *
- * @param userId This entry's new user id.
- */
- public void setUserId(int userId) {
- this.userId = userId;
- }
-
- /**
- * Get this entry's group id.
- *
- * @return This entry's group id.
- */
- public int getGroupId() {
- return this.groupId;
- }
-
- /**
- * Set this entry's group id.
- *
- * @param groupId This entry's new group id.
- */
- public void setGroupId(int groupId) {
- this.groupId = groupId;
- }
-
- /**
- * Get this entry's user name.
- *
- * @return This entry's user name.
- */
- public String getUserName() {
- return this.userName.toString();
- }
-
- /**
- * Set this entry's user name.
- *
- * @param userName This entry's new user name.
- */
- public void setUserName(String userName) {
- this.userName = new StringBuffer(userName);
- }
-
- /**
- * Get this entry's group name.
- *
- * @return This entry's group name.
- */
- public String getGroupName() {
- return this.groupName.toString();
- }
-
- /**
- * Set this entry's group name.
- *
- * @param groupName This entry's new group name.
- */
- public void setGroupName(String groupName) {
- this.groupName = new StringBuffer(groupName);
- }
-
- /**
- * Convenience method to set this entry's group and user ids.
- *
- * @param userId This entry's new user id.
- * @param groupId This entry's new group id.
- */
- public void setIds(int userId, int groupId) {
- this.setUserId(userId);
- this.setGroupId(groupId);
- }
-
- /**
- * Convenience method to set this entry's group and user names.
- *
- * @param userName This entry's new user name.
- * @param groupName This entry's new group name.
- */
- public void setNames(String userName, String groupName) {
- this.setUserName(userName);
- this.setGroupName(groupName);
- }
-
- /**
- * Set this entry's modification time. The parameter passed
- * to this method is in "Java time".
- *
- * @param time This entry's new modification time.
- */
- public void setModTime(long time) {
- this.modTime = time / 1000;
- }
-
- /**
- * Set this entry's modification time.
- *
- * @param time This entry's new modification time.
- */
- public void setModTime(Date time) {
- this.modTime = time.getTime() / 1000;
- }
-
- /**
- * Set this entry's modification time.
- *
- * @param time This entry's new modification time.
- */
- public Date getModTime() {
- return new Date(this.modTime * 1000);
- }
-
- /**
- * Get this entry's file.
- *
- * @return This entry's file.
- */
- public File getFile() {
- return this.file;
- }
-
- /**
- * Get this entry's file size.
- *
- * @return This entry's file size.
- */
- public long getSize() {
- return this.size;
- }
-
- /**
- * Set this entry's file size.
- *
- * @param size This entry's new file size.
- */
- public void setSize(long size) {
- this.size = size;
- }
-
- /**
- * Return whether or not this entry represents a directory.
- *
- * @return True if this entry is a directory.
- */
- public boolean isDirectory() {
- if (this.file != null) {
- return this.file.isDirectory();
- }
-
- if (this.linkFlag == LF_DIR) {
- return true;
- }
-
- if (this.getName().endsWith("/")) {
- return true;
- }
-
- return false;
- }
-
- /**
- * If this entry represents a file, and the file is a directory, return
- * an array of TarEntries for this entry's children.
- *
- * @return An array of TarEntry's for this entry's children.
- */
- public TarEntry[] getDirectoryEntries() {
- if (this.file == null ||!this.file.isDirectory()) {
- return new TarEntry[0];
- }
-
- String[] list = this.file.list();
- TarEntry[] result = new TarEntry[list.length];
-
- for (int i = 0; i < list.length; ++i) {
- result[i] = new TarEntry(new File(this.file, list[i]));
- }
-
- return result;
- }
-
- /**
- * Write an entry's header information to a header buffer.
- *
- * @param outbuf The tar entry header buffer to fill in.
- */
- public void writeEntryHeader(byte[] outbuf) {
- int offset = 0;
-
- offset = TarUtils.getNameBytes(this.name, outbuf, offset, NAMELEN);
- offset = TarUtils.getOctalBytes(this.mode, outbuf, offset, MODELEN);
- offset = TarUtils.getOctalBytes(this.userId, outbuf, offset, UIDLEN);
- offset = TarUtils.getOctalBytes(this.groupId, outbuf, offset, GIDLEN);
- offset = TarUtils.getLongOctalBytes(this.size, outbuf, offset, SIZELEN);
- offset = TarUtils.getLongOctalBytes(this.modTime, outbuf, offset, MODTIMELEN);
-
- int csOffset = offset;
-
- for (int c = 0; c < CHKSUMLEN; ++c) {
- outbuf[offset++] = (byte) ' ';
- }
-
- outbuf[offset++] = this.linkFlag;
- offset = TarUtils.getNameBytes(this.linkName, outbuf, offset, NAMELEN);
- offset = TarUtils.getNameBytes(this.magic, outbuf, offset, MAGICLEN);
- offset = TarUtils.getNameBytes(this.userName, outbuf, offset, UNAMELEN);
- offset = TarUtils.getNameBytes(this.groupName, outbuf, offset, GNAMELEN);
- offset = TarUtils.getOctalBytes(this.devMajor, outbuf, offset, DEVLEN);
- offset = TarUtils.getOctalBytes(this.devMinor, outbuf, offset, DEVLEN);
-
- while (offset < outbuf.length) {
- outbuf[offset++] = 0;
- }
-
- long checkSum = TarUtils.computeCheckSum(outbuf);
-
- TarUtils.getCheckSumOctalBytes(checkSum, outbuf, csOffset, CHKSUMLEN);
- }
-
- /**
- * Parse an entry's header information from a header buffer.
- *
- * @param header The tar entry header buffer to get information from.
- */
- public void parseTarHeader(byte[] header) {
- int offset = 0;
-
- this.name = TarUtils.parseName(header, offset, NAMELEN);
- offset += NAMELEN;
- this.mode = (int) TarUtils.parseOctal(header, offset, MODELEN);
- offset += MODELEN;
- this.userId = (int) TarUtils.parseOctal(header, offset, UIDLEN);
- offset += UIDLEN;
- this.groupId = (int) TarUtils.parseOctal(header, offset, GIDLEN);
- offset += GIDLEN;
- this.size = TarUtils.parseOctal(header, offset, SIZELEN);
- offset += SIZELEN;
- this.modTime = TarUtils.parseOctal(header, offset, MODTIMELEN);
- offset += MODTIMELEN;
- this.checkSum = (int) TarUtils.parseOctal(header, offset, CHKSUMLEN);
- offset += CHKSUMLEN;
- this.linkFlag = header[offset++];
- this.linkName = TarUtils.parseName(header, offset, NAMELEN);
- offset += NAMELEN;
- this.magic = TarUtils.parseName(header, offset, MAGICLEN);
- offset += MAGICLEN;
- this.userName = TarUtils.parseName(header, offset, UNAMELEN);
- offset += UNAMELEN;
- this.groupName = TarUtils.parseName(header, offset, GNAMELEN);
- offset += GNAMELEN;
- this.devMajor = (int) TarUtils.parseOctal(header, offset, DEVLEN);
- offset += DEVLEN;
- this.devMinor = (int) TarUtils.parseOctal(header, offset, DEVLEN);
- }
-}
diff --git a/src/main/org/apache/tools/tar/TarInputStream.java b/src/main/org/apache/tools/tar/TarInputStream.java
deleted file mode 100644
index a0758983ef..0000000000
--- 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
- *