diff --git a/docs/index.html b/docs/index.html index ee3a3fd2c..727630ce5 100644 --- a/docs/index.html +++ b/docs/index.html @@ -147,7 +147,8 @@ current directory. When found, it uses that file as a buildfile. To make Ant use another buildfile, use the commandline option -buildfile <file>, where <file> is the buildfile you want to use.

You can also set properties which override properties specified in the -buildfile. This can be done with the -D<property>=<value> +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 @@ -483,6 +484,7 @@ If you do not want these default excludes applied, you may disable them with the

  • Javadoc/Javadoc2
  • KeySubst
  • Mkdir
  • +
  • Patch
  • Property
  • Rename
  • Replace
  • @@ -526,6 +528,12 @@ These properties will override the properties that are set in the new project. the target of the new Ant project that should be executed. No + + output + Filename to write the ant output to. + + No +

    Examples

    @@ -994,111 +1002,6 @@ that perform file copying operations through the Project commodity methods.

    the dest.dir directory replacing all the occurencies of the string @year@ with 2000.


    -

    Get

    -

    Description

    -

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

    -

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

    -

    Parameters

    - - - - - - - - - - - - - - - - - - - - - -
    AttributeDescriptionRequired
    srcthe URL from which to retrieve a file.Yes
    destthe file where to store the retrieved file.Yes
    verboseshow verbose information ("on"/"off").No
    -

    Examples

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

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

    -
    -

    GUnzip

    -

    Description

    -

    Expands a GZip file.

    - -

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

    - -

    Parameters

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

    Examples

    -
    -

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

    -
    -

    expands test.tar.gz to test.tar

    -
    -

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

    -
    -

    expands test.tar.gz to test2.tar

    -
    -

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

    -
    -

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

    - -
    -

    GZip

    -

    Description

    -

    GZips a file.

    -

    Parameters

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

    Examples

    -
    -

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

    -
    -

    FixCRLF

    Description

    Adjusts a text file to local.

    @@ -1133,6 +1036,12 @@ subdir is a directory).

    excluded. No files (except default excludes) are excluded when omitted. 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 @@ -1215,6 +1124,116 @@ converts all tabs to spaces. EOF characters are left alone if run on DOS systems, and are removed if run on Unix systems. You never know what editor a user will use to browse README's.


    +

    Get

    +

    Description

    +

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

    +

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

    +

    Parameters

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

    Examples

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

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

    +
    +

    GUnzip

    +

    Description

    +

    Expands a GZip file.

    + +

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

    + +

    Parameters

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

    Examples

    +
    +

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

    +
    +

    expands test.tar.gz to test.tar

    +
    +

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

    +
    +

    expands test.tar.gz to test2.tar

    +
    +

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

    +
    +

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

    + +
    +

    GZip

    +

    Description

    +

    GZips a file.

    +

    Parameters

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

    Examples

    +
    +

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

    +
    +

    Jar

    Description

    Jars a set of files.

    @@ -1354,12 +1373,25 @@ the one that is currently running Ant.

    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 @@ -1480,6 +1512,11 @@ relative to the srcdir directory.

    indicates whether token filtering should take place No + + target + Generate class files for specific VM version, e.g. "1.1" or "1.2". + No +

    Examples

      <javac srcdir="${src}"
    @@ -1742,13 +1779,13 @@ instead.

    serialwarn - Generate warning about @serial tag + FUTURE: Generate warning about @serial tag 1.2 No helpfile - Specifies the HTML help file to use + FUTURE: Specifies the HTML help file to use 1.2 No @@ -1760,7 +1797,7 @@ instead.

    charset - Charset for cross-platform viewing of generated + FUTURE: Charset for cross-platform viewing of generated documentation 1.2 No @@ -1771,6 +1808,16 @@ instead.

    1.1 No + + doclet + Specifies the class file that starts the doclet used in generating the documentation. + No + + + docletpath + Specifies the path to the doclet class file that is specified with the -doclet option. + No +

    Example

      <javadoc packagenames="com.dummy.test.*"
    @@ -1849,6 +1896,84 @@ necessary.

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

    creates a directory ${dist}/lib.


    +

    Patch

    +

    Description

    +

    Applies a diff file to originals. +

    Parameters

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

    Examples

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

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

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

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

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

    Property

    Description

    Sets a property (by name and value), or set of properties (from file or @@ -1907,6 +2032,14 @@ This also holds for properties loaded from a property file.

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

      <property resource="foo.properties" />

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

    +

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

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

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


    Rename

    Description

    @@ -1997,6 +2130,23 @@ This also holds for properties loaded from a property file.

    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 +

    Examples

      <rmic classname="com.xyz.FooBar" base="${build}/classes" />
    diff --git a/src/main/org/apache/tools/ant/taskdefs/Patch.java b/src/main/org/apache/tools/ant/taskdefs/Patch.java new file mode 100644 index 000000000..3b1eab045 --- /dev/null +++ b/src/main/org/apache/tools/ant/taskdefs/Patch.java @@ -0,0 +1,161 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2000 The Apache Software Foundation. All rights + * reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * 3. The end-user documentation included with the redistribution, if + * any, must include the following acknowlegement: + * "This product includes software developed by the + * Apache Software Foundation (http://www.apache.org/)." + * Alternately, this acknowlegement may appear in the software itself, + * if and wherever such third-party acknowlegements normally appear. + * + * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +package org.apache.tools.ant.taskdefs; + +import org.apache.tools.ant.*; +import java.io.File; + +/** + * Task as a layer on top of patch. Patch applies a diff file to an original. + * + * @author Stefan Bodewig stefan.bodewig@megabit.net + */ +public class Patch extends Exec { + + private File originalFile; + private File patchFile; + private boolean backup = false; + private boolean ignoreWhitespace = false; + private int strip = -1; + private boolean quiet = false; + private boolean reverse = false; + + /** + * The file to patch. + */ + public void setOriginalfile(String file) { + originalFile = project.resolveFile(file); + } + + /** + * The file containing the diff output. + */ + public void setPatchfile(String file) { + patchFile = project.resolveFile(file); + } + + /** + * Shall patch write backups. + */ + public void setBackups(String backups) { + backup = Project.toBoolean(backups); + } + + /** + * Ignore whitespace differences. + */ + public void setIgnorewhitespace(String ignore) { + ignoreWhitespace = Project.toBoolean(ignore); + } + + /** + * Strip the smallest prefix containing num leading slashes + * from filenames. + * + *

    patch's -p option. + */ + public void setStrip(String num) { + strip = Integer.parseInt(num); + } + + /** + * Work silently unless an error occurs. + */ + public void setQuiet(String q) { + quiet = Project.toBoolean(q); + } + + /** + * Assume patch was created with old and new files swapped. + */ + public void setReverse(String r) { + reverse = Project.toBoolean(r); + } + + public void execute() throws BuildException { + if (patchFile == null) { + throw new BuildException("patchfile argument is required"); + } + + StringBuffer command = new StringBuffer("patch -i "+patchFile+" "); + + if (backup) { + command.append("-b "); + } + + if (ignoreWhitespace) { + command.append("-l "); + } + + if (strip >= 0) { + command.append("-p"+strip+" "); + } + + if (quiet) { + command.append("-s "); + } + + if (reverse) { + command.append("-R "); + } + + if (originalFile != null) { + command.append(originalFile); + } + + run(command.toString()); + } + +}// Patch diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index a966a41c1..d9fffa6b9 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -29,6 +29,7 @@ available=org.apache.tools.ant.taskdefs.Available filter=org.apache.tools.ant.taskdefs.Filter fixcrlf=org.apache.tools.ant.taskdefs.FixCRLF rename=org.apache.tools.ant.taskdefs.Rename +patch=org.apache.tools.ant.taskdefs.Patch compileTask=org.apache.tools.ant.taskdefs.CompileTask # optional tasks