diff --git a/WHATSNEW b/WHATSNEW index fa49b84f1..7dab24184 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -1,4 +1,4 @@ -Changes from Ant 1.2 to Ant 1.3 Beta 1 +Changes from Ant 1.2 to Ant 1.3 Beta 2 =========================================== Changes that could break older environments: @@ -72,6 +72,10 @@ Other changes: * wlrun, wlstop and ejbjar now support Weblogic 6.0 +* The MPasre task has been updated to work with MParse 2.0 + +* The documentation has been significantly updated. + Fixed bugs: ----------- diff --git a/build.xml b/build.xml index 5b47f238d..88a9191c2 100644 --- a/build.xml +++ b/build.xml @@ -298,7 +298,8 @@ - + diff --git a/docs/manual/CoreTasks/filter.html b/docs/manual/CoreTasks/filter.html index 52e66d422..db6f83e9a 100644 --- a/docs/manual/CoreTasks/filter.html +++ b/docs/manual/CoreTasks/filter.html @@ -15,7 +15,7 @@ Token filters are used by all tasks that perform file copying operations through the Project commodity methods.

Note 1: the token string must not contain the separators chars (@).
Note 2: Either token and value attributes must be provided, or only the -filterfile attribute.

+filtersfile attribute.

Parameters

@@ -50,7 +50,7 @@ filterfile attribute.

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

-
  <filter filterfile="deploy_env.properties"/>
+
  <filter filtersfile="deploy_env.properties"/>
will read all property entries from the deploy_env.properties file and set these as filters. diff --git a/docs/manual/CoreTasks/javac.html b/docs/manual/CoreTasks/javac.html index e11d5f10f..3c3abff3c 100644 --- a/docs/manual/CoreTasks/javac.html +++ b/docs/manual/CoreTasks/javac.html @@ -157,7 +157,7 @@ classname in the "build.compiler" property. + defaults to yes. diff --git a/docs/manual/CoreTasks/tar.html b/docs/manual/CoreTasks/tar.html index 46d29e929..dfce64485 100644 --- a/docs/manual/CoreTasks/tar.html +++ b/docs/manual/CoreTasks/tar.html @@ -22,16 +22,24 @@ filesets are extended to allow control over the access mode, username and groupn to be applied to the tar entries. This is useful, for example, when preparing archives for Unix systems where some files need to have execute permission.

-

The POSIX tar standard does not support path lengths greater than 100 characters. The -behaviour of the tar task when it encounters such paths is controlled by the longfile -attribute. If this attribute is not present, the tar task will throw an exception upon encountering -a long path. If the longfile attribute is set to truncate, any long paths will be -truncated to the 100 character maximum length prior to adding to the archive. This ensures that -the file will be in the archive and that the archive can be untarred by any compliant version of -tar. If the loss of path information is not acceptable, and it rarely is, longfile may be set to -the value gnu. The tar task will then produce a GNU tar file which can have -arbitrary length paths. Note however, that the resulting archive will only be able to be untarred -with GNU tar.

+

Early versions of tar did not support path lengths greater than 100 +characters. Modern versions of tar do so, but in incompatible ways. +The behaviour of the tar task when it encounters such paths is +controlled by the longfile attribute. +If the longfile attribute is set to fail, any long paths will +cause the tar task to fail. If the longfile attribute is set to +truncate, any long paths will be truncated to the 100 character +maximum length prior to adding to the archive. If the value of the longfile +attribute is set to omit then files containing long paths will be +omitted from the archive. Either option ensures that the archive can be +untarred by any compliant version of tar. If the loss of path or file +information is not acceptable, and it rarely is, longfile may be set to the +value gnu. The tar task will then produce a GNU tar file which +can have arbitrary length paths. Note however, that the resulting archive will +only be able to be untarred with GNU tar. The default for the longfile +attribute is warn which behaves just like the gnu option except +that it produces a warning for each file path encountered that does not match +the limit.

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

@@ -55,9 +63,11 @@ with GNU tar.

- - + diff --git a/docs/manual/Integration/VAJAntTool.html b/docs/manual/Integration/VAJAntTool.html index 071c6796f..f64cbeb6f 100644 --- a/docs/manual/Integration/VAJAntTool.html +++ b/docs/manual/Integration/VAJAntTool.html @@ -3,133 +3,619 @@ - Ant VisualAge for Java Tool Integration + Visual Age for Java Tasks and Plugin User Manual -

Ant PlugIn for VisualAge for Java

-by + +

Visual Age for Java Tasks and Plugin User Manual

+ by -Version 1.0 - 2000/11/09
+Version 1.1 - 2001/02/14

Table of Contents

+

Introduction

-Visual Age for Java is a great Java IDE, but it lacks decent build support -for creating deliveries. On the other hand, Ant supports the build process -very good, but is (at least at the moment) command line based. So we decided -to write a small visual Ant frontend to make running Ant from VAJ possible. -We use the Tool API to integrate Ant in VisualAge for Java. In combination -with the VAJ targets (vajload, vajexport, vajimport) you can load defined -defined versions of projects into your workspace, export the source code, -compile it with an external compiler and build a jar without leaving the -IDE. Of course compile messages are viewed in a logging window. Concluding: -This tool provides a comfortable deployment VAJ has not (out of the box)!
+Visual Age for Java is a great Java IDE, but it lacks decent +build support; for creating deliveries. On the other hand, +Ant supports the build process very good, but is +(at least at the moment) command line based. So we decided +to write some tasks to access the VAJ repository and +a small visual Ant frontend to make running Ant from VAJ possible. +We use the Tool API to integrate Ant in VisualAge for Java. +In combination with the VAJ tasks (vajload, vajexport, vajimport) +you can load defined defined versions of projects into your workspace, +export the source code, compile it with an external compiler +and build a jar without leaving the IDE. Of course compile +messages are viewed in a logging window. Concluding: This +tool provides decent deployment support VAJ has not (out of the box).
+ +

The Tasks

+At the moment there are three tasks which help integrating the VAJ repository +contents into an external build process: + +
includeAntRuntime whether to include the Ant run-time libraries; - defaults to no. No
longfileControls how long paths are handled. Allowable - values are "gnu" and "truncate"NoDetermines how long files (>100 chars) are to be + handled. Allowable values are "truncate", "fail", + "warn", "omil" and "gnu". Default is + "warn". + No
includes
+ + + + + + + + + + + + + + +
VAJLoad
+
loads specified versions into the workspace
+
VAJExport
+
exports specified packages into the file system
+
VAJImport
+
imports specified files into the workspace
+
+These tasks are described in detail below. + +
+

VAJLoad

+

Description:

+

Loads a specified VAJ project version into the workspace.

+ +

Parameters

+

none

+ +

Parameters specified as nested elements

+

vajproject

+ + + + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
namename of the VAJ project to load into the workspaceyes
versionname of the requested versionyes
+ +

Example

+
+<vajload>
+    <vajproject name="My Testcases" version="1.7beta" />
+    <vajproject name="JUnit" version="3.2" />
+</vajload>
+
+ +
+

VAJExport

+ +

Description:

+

Exports Java source files, class files and/or resources from the workspace +to the file system. Exports can be specified by giving the VAJ project +name and package name(s). This works very similar to +FileSets.

+ +

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
destdirlocation to store the exported filesyes
exportSourcesexport source files (default: "yes")no
exportResourcesexport resource files (default: "yes")no
exportClassesexport class files (default: "no")no
exportDebugInfoinclude debug info in exported + class files (default: "no")no
defaultexcludes use default excludes when exporting (default: "yes") + no
+ +

Parameters specified as nested elements

+ +

include

+specifies the packages to include into the export + + + + + + + + + + + + + + +
AttributeDescriptionRequired
namename of the VAJ project and package to export.
+ The first element of the name must be the project name,
+ then the package name elements separated by '/'.
yes
+ +

exclude

+specifies the packages to exclude from the export
+ + + + + + + + + + + + + + +
AttributeDescriptionRequired
namename of the VAJ project/package not to exportyes
+ +

Example

+
+<vajexport destdir="${src.dir}" exportResources="no">
+    <include name="MyProject/**"/>
+    <exclude name="MyProject/test/**"/>
+</vajexport>
+
+This example exports all packages in the VAJ project 'MyProject', except +packages starting with 'test'. +
+

VAJImport

+ +

Description:

+

Imports Java source files, class files and/or resources from the file +system into VAJ. These imports can be specified with a fileset.

+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeDescriptionRequired
vajProjectimported files are added to this VAJ projectyes
importSourcesexport source files (default: "yes")no
importResourcesexport resource files (default: "yes")no
importClassesexport class files (default: "no")no
+ +

Parameters specified as nested elements

+ +

fileset

+A FileSet specifies the files to import. + +

Example

+
+<vajimport project="Test" importClasses="true">
+    <fileset dir="${import.dir}">
+        <include name="com/sample/**/*.class"/>
+        <exclude name="com/sample/test/**"/>
+    </fileset>
+</vajimport>
+
+This example imports all class files in the directory ${import.dir}/com/sample +excluding those in the subdirectory test
+ +
+

A sample build file

+This is a sample build file which builds a zip file useful for distribution +of the VAJ plugin. The build file exports a specific version of Ant, compiles +it, extracts necessary helper classes and zips everything together. This +is useful as complete example as well as to deploy Ant in a team where all +developers use VAJ. The resulting zip file must be unzipped in +<VAJInstallDir>\ide\tools\org-apache-tools-ant. +For more information see the installation section.
+
+
+<?xml version="1.0"?>
+<!-- ======================================================================= -->
+<!-- Builds a binary distribution of the VAJ Ant Plugin                      -->
+<!-- ======================================================================= -->
+<project name="anttool" default="buildall" basedir="c:\temp\anttool">
+
+  <property name="src.dir" value="${basedir}/src"/>
+  <property name="zip.dir" value="${basedir}/dist"/>
+  <property name="build.classes" value="${basedir}/classes"/>
+
+  <!-- location of the unzipped Ant source distribution  -->
+  <property name="antdistribution.dir" value="u:\ant-1.3beta1"/>
+
+  <!-- VAJ install dir -->
+  <property name="vaj.dir" value="C:\IBMVJava2"/>
+
+  <path id="classpath">
+      <pathelement location="${src.dir}"/>
+      <pathelement location="${vaj.dir}\IDE\project_resources\IBM IDE Utility class libraries" />
+      <pathelement location="${build.classes}"/>
+  </path>
+
+
+  <!-- =================================================================== -->
+  <!-- Load Projects into Workspace                                        -->
+  <!-- =================================================================== -->
+  <target name="load" description="load projects">
+    <vajload>
+      <project name="Ant" version="1.3"/>
+      <project name="Apache Oro RegExp" version="2.0.1"/>
+    </vajload>
+  </target>
+
+
+  <!-- =================================================================== -->
+  <!-- Creates the build dirs                                              -->
+  <!-- =================================================================== -->
+  <target name="preparedirs">
+    <mkdir dir="${basedir}"/>
+    <mkdir dir="${src.dir}"/>
+    <mkdir dir="${zip.dir}"/>
+    <mkdir dir="${build.classes}"/>
+  </target>
+
+
+  <!-- =================================================================== -->
+  <!-- Export from VA                                                      -->
+  <!-- =================================================================== -->
+  <target name="export" depends="preparedirs" description="export projects">
+    <mkdir dir="${src.dir}"/>
+    <!-- Export all Ant sources except optional tasks and the Oro sources -->
+    <vajexport destdir="${src.dir}">
+      <include name="Ant/**"/>
+      <exclude name="Ant/**/optional/**"/>
+      <exclude name="Ant/org/apache/tools/ant/gui/**"/>
+      <include name="Apache Oro*/**"/>
+    </vajexport>
+    <!-- Export selected optional tasks -->
+    <vajexport destdir="${src.dir}">
+      <include name="Ant/org/apache/tools/ant/taskdefs/optional/ide/**"/>
+    </vajexport>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Unzip necessary libraries                                           -->
+  <!-- =================================================================== -->
+  <target name="expand">
+    <mkdir dir="${build.classes}"/>
+    <unzip src="${antdistribution.dir}\lib\parser.jar"
+           dest="${build.classes}"
+    />
+    <unzip src="${antdistribution.dir}\lib\jaxp.jar"
+           dest="${build.classes}"
+    />
+    <delete dir="${build.classes}\META-INF" />
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Compile the source code                                            -->
+  <!-- =================================================================== -->
+  <target name="compile" depends="expand" description="compile java sources">
+    <mkdir dir="${build.classes}"/>
+    <javac srcdir="${src.dir}"
+           destdir="${build.classes}"
+           debug="on"
+           deprecation="off"
+           optimize="on" >
+      <classpath refid="classpath" />
+      <include name="org/apache/**"/>
+      <exclude name="**/JakartaRegexpMatcher.java"/>
+    </javac>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Copy resources and zip everything together                           -->
+  <!-- =================================================================== -->
+  <target name="zip" depends="compile" description="creates zip distribution">
+    <copy todir="${build.classes}">
+      <fileset dir="${src.dir}">
+          <include name="org/apache/**"/>
+          <exclude name="**/*.java"/>
+      </fileset>
+    </copy>
+    <mkdir dir="${build.classes}/doc"/>
+    <copy todir="${build.classes}/doc" overwrite="yes">
+      <fileset dir="${antdistribution.dir}/docs">
+          <include name="VAJAnttool.html, toolmenu.gif, anttool1.gif"/>
+      </fileset>
+    </copy>
+    <copy file="${antdistribution.dir}/src/main/org/apache/tools/ant/taskdefs/optional/ide/default.ini" todir="${build.classes}" overwrite="yes"/>
+    <mkdir dir="${zip.dir}"/>
+    <zip basedir="${build.classes}" zipfile="${zip.dir}/anttool.zip" />
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Cleans source and class dirs                                        -->
+  <!-- =================================================================== -->
+  <target name="clean" depends="preparedirs" description="removes all files from src and build tree">
+    <delete>
+      <fileset dir="${src.dir}"/>
+    </delete>
+    <delete>
+      <fileset dir="${build.classes}"/>
+    </delete>
+    <delete>
+      <fileset dir="${zip.dir}"/>
+    </delete>
+  </target>
+
+  <!-- =================================================================== -->
+  <!-- Cleans the build dir, loads required project versions, exports,     -->
+  <!-- compiles and zips the Plugin                                        -->
+  <!-- =================================================================== -->
+  <target name="buildall" depends="clean, load, export, zip" description="build all">
+  </target>
+</project>
+
+ +
+

The Plugin

+The tasks are usable within VAJ by running the +org.apache.tools.ant.Main class, but this is +quite inconvenient. Therefore a small GUI is +provided which allows selecting a build file +and executing its targets. This Plugin is accessible +from the VAJ Tools menu (see Usage). +

Installation

-At the moment the installation has it's rough edges. If something described -below doesn't work for You, it's probably not Your fault but incomplete/wrong -instructions. In this case, please contact one of the -authors.
-We assume C:\IBMVJava as VAJ install directory. -If you have installed it elsewhere, adapt the paths below. Execute following -steps to get the PlugIn up and running: +At the moment the installation has it's rough edges. If something +described below doesn't work for You, it's probably not Your fault +but incomplete/wrong instructions. In this case, please contact one +of the authors. +We assume C:\IBMVJava as VAJ install +directory. If You have installed it elsewhere, adapt the pathes below. +Execute following steps to get the PlugIn up and running: +

Usage

-Being sure the tool is installed correctly and your Ant build file is -configured, it is really easy to use.
-Go to your Workbench, select the project you want to deploy and open -its context menu. In the submenu Tools you should find the new -entry Ant Build. Click it to start the tool! -

-

-After a short time this frame should pop up: -

-

-This frame contains the following: +Beeing sure the tool is installed correctly and your Ant build +file is configured, it is really easy to use.
+Go to your Workbench, select the project you want to deploy and +open its context menu. In the submenu Tools you should find +the new entry Ant Build. Klick it to start the tool! + +
+ After a short time this frame should pop up: +
+ This frame contains the following elements: -After you have set up your buildprocess you might find it useful to save -the data you've just entered, so we implemented an option to save it to -the repository into your selected project. Make sure that you have an open -edition of your project before selecting Save BuildInfo To Repository -from the File menu. Now your information is saved to this edition -of your project and will be loaded automatically the next time you start -Ant Build.
-If you have closed the log window accidentally, it can be reopened with -the Log item in the File menu, and if you want to know who -developed this, just select About in the Help menu. -
+After you have set up your buildprocess you might find it useful +to save the data you've just entered, so we implemented an option to +save it to the repository into your selected project. Make sure that you +have an open edition of your project before selecting +Save BuildInfo To Repository from the File menu. +Now your information is saved to this edition of your project and will +be loaded automatically the next time you start Ant Build.
+If you have closed the log window accidentally, it can be reopened +with the Log item in the File menu, and if you want to +know who developed this, just select About in the Help menu.

Frequently Asked Questions

-

F: I want to load, export and build more then one Visual Age project to -one jar! How to?
-A: The VA tasks are able to load and export several Projects all at -once. You can choose whatever project you like for storing the tool -information, it doesn't really matter.

+ +

Q: I want to load, export and build more then one Visual Age project +to one jar! How to?
+A: The VA tasks are able to load and export several Projects all +at once. You can choose whatever project you like for storing the tool +information, it doesn't really matter +

+

Q: When I load my build file, the list of targets is empty. Why?
+A: You need to add the optional "description" parameter to the targets You +want to come up in the list. Then reload the build file in the "ant build" +tool. We chose to display only targets with description to allow the build +file developer to distinguish between targets for end users and helper targets. +

+

Q: Is there a sample build file available?
+A: Now You can find an example in this manual +

+ +

Q: Why does it export my entire workspace when I've already implicitly +selected a project when starting the Tool?
+A: This selection does not carry into the buildfile you are using. Set the +Project name at the beginning of the "includes" parameter. +

+

Q: When I import Ant into my Workspace, I get Problems reported. Can I +ignore them?
+A: It depends on the problems reported, and what you want to do with Ant. +Problems you can't ignore: +

+

+ +

Q: Why is the task name vajload when the class is called VAJLoadProjects?
+A: At the moment this task can load only project versions. This is reflected +by the class name. It may be extended to load package and class versions, +too, and we didn't want to let these extensions affect the build files. Therefore +we chose the more general name vajload as task name. +

+

Q: I want to use the same buildfile both within Visual Age and from the +command line using my regular Ant environment. What do I need to be aware +of?
+A: The three Visual Age Tasks won't work when executing Ant from the command +line. +

+

Q: How do I control the import/export of sourcefiles, compiled files and +project resources explicity?
+A: Via the Boolean values exportClasses (default false) exportSources (default +true) and exportResources (default true). In some situations, Resources are +not exported correctly without this being explicity set. +


+

Known Problems

+ +
+

VisualAge for Java Versions

-This tool integration has been tested with versions 3.02 and 3.5 of VisualAge -for Java. It should run with the 2.x Versions, too, but we didn't try. -The graphical user interface is build with AWT so it is JDK independent -by now!
+This tool integration has been tested with versions 3.02 and 3.5 +of VisualAge for Java. It should run with the 2.x Versions, too, but +we didn't try. The graphical user interface is build with AWT so it is +JDK independent by now. +
+ +

History

+ + + + + + + + + + + + + +
1.02000/09/11Initial Version
1.12001/02/14Added Task documentation and more FAQs (thanks to + Richard Bourke for the FAQ additions) +

-

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

+
Copyright © 2001 Apache Software Foundation. All rights Reserved.
+ diff --git a/docs/manual/OptionalTasks/mparse.html b/docs/manual/OptionalTasks/mparse.html index 0ee403cf3..49436b071 100644 --- a/docs/manual/OptionalTasks/mparse.html +++ b/docs/manual/OptionalTasks/mparse.html @@ -1,16 +1,20 @@ + -JavaCC Task +MParse Task -

MParse

+

MParse

+

by

+

Requirements

-

This task requires Metamata Development environment 1.1. It does not work as -is with the latest 2.0 version freely available at Metamata.

+

This task requires Metamata Development environment 2.0 freely available at Metamata.

Description

Invokes the Metamata MParse compiler @@ -51,32 +55,62 @@ is with the latest 2.0 version freely available at Yes - workingdir + verbose - The temporary directory used by MParse. + Enable all messages - Yes + No + + + debugparser + + Enables parser debugging + + No + + + debugscanner + + Enables scanner debugging + + No - cleanuphack - Remove the stale file as well as the intermediate Sun + cleanup + Remove the intermediate Sun JavaCC file created during the transformation of the grammar file. - No. Default to false. + No. Default to false + + + maxmemory + Set the maximum memory for the JVM. this is a convenient + way to set the -mx or -Xmx argument. + No

Nested elements

-

userclasspath

-

 The userclasspath element is required and represents a PATH like +

jvmarg

+

Additional parameters may be passed to the VM via nested <jvmarg> +attributes. <jvmarg> allows all attributes described in Command +line arguments.

+

classpath

+

Sets class path (also source path unless one explicitly set). Overrides +METAPATH/CLASSPATH environment variables.  The classpath element represents a PATH like +structure.

+

sourcepath

+

Sets source path. Overrides the SOURCEPATH environment variable. The sourcepath element represents a PATH like structure.

Example

-
  <mparse target="src/Parser.jj" metamatahome="c:/metamata" workingdir="c:/tmp">
-    <userclasspath>
-      <pathelement location="./lib/dependency.jar"/>
-    </userclasspath>
+
  <mparse target="c:/metamata/examples/parseexamples/javagrammars/singlefile/JavaParser.jj"
+          metamatahome="c:/metamata" cleanup="true">
+    <classpath>
+      <pathelement location="c:/metamata/examples/"/>
+    </classpath>
   </mparse>

- This invokes Metamata MParse installed in c:/metamata on a grammar file src/Parser.jj -with a working directory in c:/tmp and a specific classpath + This invokes Metamata MParse installed in c:/metamata on one of the grammar file +example (JavaParser.jj) + and cleans up the intermediate Sun JavaCC file.


diff --git a/docs/manual/OptionalTasks/vsslabel.html b/docs/manual/OptionalTasks/vsslabel.html new file mode 100644 index 000000000..f489e4e0d --- /dev/null +++ b/docs/manual/OptionalTasks/vsslabel.html @@ -0,0 +1,78 @@ + + + + + Documentation for Ant 1.3 optional task VSSLABEL + + + +

VssLabel

+

Description

+Task to perform LABEL commands to Microsoft Visual Source Safe. +

Assigns a label to the specified version or current version of a file or +project.

+

Parameters

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
AttributeValuesRequired
loginusername,passwordNo
vsspathSourceSafe pathYes
ssdirdirectory where ss.exe resides. By default the task + expects it to be in the PATH.No
labelA label to apply to the hierarchyYes
versionAn existing file or project version to label. By default the current + version is labelled.No
+

Examples

+
+
+<vsslabel vsspath="/source/aProject"
+          login="me,mypassword"
+          label="Release1"/>
+
+
+

Labels the current version of the VSS project $/source/aproject with +the label Release1 using the username me and the password +mypassword. +

+
+
+<vsslabel vsspath="/source/aProject/myfile.txt"
+          version="4"
+          label="1.03.004"/>
+
+
+

Labels version 4 of the VSS file $/source/aproject/myfile.txt with the +label 1.03.004. If this version already has a label, the operation (and +the build) will fail. +

+ +
+

Copyright © 2000,2001 Apache Software Foundation. All rights +Reserved.

+ + + diff --git a/docs/manual/credits.html b/docs/manual/credits.html index a3a7f61a0..3faa79258 100644 --- a/docs/manual/credits.html +++ b/docs/manual/credits.html @@ -30,6 +30,7 @@
  • Jon S. Stevens (jon@latchkey.com)
  • Roger Vaughn (rvaughn@seaconinc.com)
  • Dave Walend (dwalend@cs.tufts.edu)
  • +
  • Phillip Wells (philwells@rocketmail.com)
  • diff --git a/docs/manual/optionaltasklist.html b/docs/manual/optionaltasklist.html index be1df30d6..9cfbf83cf 100644 --- a/docs/manual/optionaltasklist.html +++ b/docs/manual/optionaltasklist.html @@ -33,7 +33,9 @@ Stylebook
    Test
    Telnet
    +Visual Age for Java Tasks
    VssGet
    +VssLabel
    diff --git a/docs/manual/toc.html b/docs/manual/toc.html index 67f28f1f6..418e4b77a 100644 --- a/docs/manual/toc.html +++ b/docs/manual/toc.html @@ -17,7 +17,7 @@ IDE Integration
    Developing with Ant
    Ant Resources
    -LICENSE
    +License
    Feedback

    Authors
    diff --git a/src/etc/testcases/core/include/basic/include.inc b/src/etc/testcases/core/include/basic/include.inc new file mode 100644 index 000000000..3332925f0 --- /dev/null +++ b/src/etc/testcases/core/include/basic/include.inc @@ -0,0 +1,3 @@ + + + diff --git a/src/etc/testcases/core/include/basic/include.xml b/src/etc/testcases/core/include/basic/include.xml new file mode 100644 index 000000000..f5879f20f --- /dev/null +++ b/src/etc/testcases/core/include/basic/include.xml @@ -0,0 +1,9 @@ + + + +]> + + + &include; + diff --git a/src/etc/testcases/core/include/basic/relative.xml b/src/etc/testcases/core/include/basic/relative.xml new file mode 100644 index 000000000..bcdf7eeaa --- /dev/null +++ b/src/etc/testcases/core/include/basic/relative.xml @@ -0,0 +1,9 @@ + + + +]> + + + &include; + diff --git a/src/etc/testcases/core/include/frag#ment/include.inc b/src/etc/testcases/core/include/frag#ment/include.inc new file mode 100644 index 000000000..3332925f0 --- /dev/null +++ b/src/etc/testcases/core/include/frag#ment/include.inc @@ -0,0 +1,3 @@ + + + diff --git a/src/etc/testcases/core/include/frag#ment/include.xml b/src/etc/testcases/core/include/frag#ment/include.xml new file mode 100644 index 000000000..5dbeff6fd --- /dev/null +++ b/src/etc/testcases/core/include/frag#ment/include.xml @@ -0,0 +1,9 @@ + + + +]> + + + &include; + diff --git a/src/etc/testcases/core/include/frag#ment/relative.xml b/src/etc/testcases/core/include/frag#ment/relative.xml new file mode 100644 index 000000000..f71ed407d --- /dev/null +++ b/src/etc/testcases/core/include/frag#ment/relative.xml @@ -0,0 +1,9 @@ + + + +]> + + + &include; + diff --git a/src/etc/testcases/core/include/frag#ment/simple.xml b/src/etc/testcases/core/include/frag#ment/simple.xml new file mode 100644 index 000000000..acdff54b2 --- /dev/null +++ b/src/etc/testcases/core/include/frag#ment/simple.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/etc/testcases/taskdefs/property.xml b/src/etc/testcases/taskdefs/property.xml new file mode 100644 index 000000000..fdc601e1d --- /dev/null +++ b/src/etc/testcases/taskdefs/property.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java index 0eb41fa11..c9efb8a60 100644 --- a/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/src/main/org/apache/tools/ant/AntClassLoader.java @@ -103,6 +103,12 @@ public class AntClassLoader extends ClassLoader { */ private Vector loaderPackages = new Vector(); + /** + * This flag indicates that the classloader will ignore the base + * classloader if it can;t find a class. + */ + private boolean ignoreBase = false; + private static Method getProtectionDomain = null; private static Method defineClassProtectionDomain = null; static { @@ -143,6 +149,16 @@ public class AntClassLoader extends ClassLoader { this(project, classpath); this.systemFirst = systemFirst; } + + /** + * Set this classloader to run in isolated mode. In isolated mode, classes not + * found on the given classpath will not be referred to the base class loader + * but will cause a classNotFoundException. + */ + public void setIsolated(boolean isolated) { + ignoreBase = isolated; + } + /** * Add a package root to the list of packages which must be loaded on the @@ -354,6 +370,9 @@ public class AntClassLoader extends ClassLoader { project.log("Class " + classname + " loaded from ant loader", Project.MSG_DEBUG); } catch (ClassNotFoundException cnfe) { + if (ignoreBase) { + throw cnfe; + } theClass = findBaseClass(classname); project.log("Class " + classname + " loaded from system loader", Project.MSG_DEBUG); } diff --git a/src/main/org/apache/tools/ant/ProjectHelper.java b/src/main/org/apache/tools/ant/ProjectHelper.java index 2243c1f69..60766d15b 100644 --- a/src/main/org/apache/tools/ant/ProjectHelper.java +++ b/src/main/org/apache/tools/ant/ProjectHelper.java @@ -99,13 +99,17 @@ public class ProjectHelper { */ private void parse() throws BuildException { FileInputStream inputStream = null; + InputSource inputSource = null; try { SAXParser saxParser = getParserFactory().newSAXParser(); parser = saxParser.getParser(); - inputStream = new FileInputStream(buildFile); - saxParser.parse(inputStream, new RootHandler()); + String uri = "file:" + buildFile.getAbsolutePath().replace('\\', '/'); + for (int index = uri.indexOf('#'); index != -1; index = uri.indexOf('#')) { + uri = uri.substring(0, index) + "%23" + uri.substring(index+1); + } + saxParser.parse(uri, new RootHandler()); } catch(ParserConfigurationException exc) { throw new BuildException("Parser has not been configured correctly", exc); @@ -208,16 +212,35 @@ public class ProjectHelper { */ public InputSource resolveEntity(String publicId, String systemId) { - + if (systemId.startsWith("file:")) { String path = systemId.substring(5); + int index = path.indexOf("file:"); + + // we only have to handle these for backward compatibility + // since they are in the FAQ. + while (index != -1) { + path = path.substring(0, index) + path.substring(index + 5); + index = path.indexOf("file:"); + } + + String entitySystemId = path; + index = path.indexOf("%23"); + // convert these to # + while (index != -1) { + path = path.substring(0, index) + "#" + path.substring(index + 3); + index = path.indexOf("%23"); + } + File file = new File(path); if (!file.isAbsolute()) { file = new File(buildFileParent, path); } try { - return new InputSource(new FileInputStream(file)); + InputSource inputSource = new InputSource(new FileInputStream(file)); + inputSource.setSystemId("file:" + entitySystemId); + return inputSource; } catch (FileNotFoundException fne) { project.log(file.getAbsolutePath()+" could not be found", Project.MSG_WARN); diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index 69b401198..a5993385e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -428,8 +428,10 @@ public class Execute { */ public Process exec(Project project, String[] cmd, String[] env) throws IOException { - project.log("Execute:CommandLauncher: " + - Commandline.toString(cmd), Project.MSG_DEBUG); + if (project != null) { + project.log("Execute:CommandLauncher: " + + Commandline.toString(cmd), Project.MSG_DEBUG); + } return Runtime.getRuntime().exec(cmd, env); } @@ -471,8 +473,10 @@ public class Execute { for ( int i = 0; i < cmd.length; i++ ) { newcmd[i] = Commandline.quoteArgument(cmd[i]); } - project.log("Execute:Java11CommandLauncher: " + - Commandline.toString(newcmd), Project.MSG_DEBUG); + if (project != null) { + project.log("Execute:Java11CommandLauncher: " + + Commandline.toString(newcmd), Project.MSG_DEBUG); + } return Runtime.getRuntime().exec(newcmd, env); } } @@ -497,8 +501,10 @@ public class Execute { throws IOException { try { - project.log("Execute:Java13CommandLauncher: " + - Commandline.toString(cmd), Project.MSG_DEBUG); + if (project != null) { + project.log("Execute:Java13CommandLauncher: " + + Commandline.toString(cmd), Project.MSG_DEBUG); + } Object[] arguments = { cmd, env, workingDir }; return (Process)_execWithCWD.invoke(Runtime.getRuntime(), arguments); } @@ -571,13 +577,16 @@ public class Execute { // Use cmd.exe to change to the specified directory before running // the command - String[] newcmd = new String[cmd.length+5]; + final int preCmdLength = 6; + String[] newcmd = new String[cmd.length + preCmdLength]; newcmd[0] = "cmd"; newcmd[1] = "/c"; newcmd[2] = "cd"; - newcmd[3] = workingDir.getAbsolutePath(); - newcmd[4] = "&&"; - System.arraycopy(cmd, 0, newcmd, 5, cmd.length); + newcmd[3] = "/d"; + newcmd[4] = workingDir.getAbsolutePath(); + newcmd[5] = "&&"; + System.arraycopy(cmd, 0, newcmd, preCmdLength, cmd.length); + return exec(project, newcmd, env); } } diff --git a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java index 76c3a53a0..030f1c983 100644 --- a/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java +++ b/src/main/org/apache/tools/ant/taskdefs/ExecuteJava.java @@ -119,7 +119,8 @@ public class ExecuteJava { if (classpath == null) { target = Class.forName(classname); } else { - AntClassLoader loader = new AntClassLoader(project, classpath); + AntClassLoader loader = new AntClassLoader(project, classpath, false); + loader.setIsolated(true); target = loader.forceLoadClass(classname); } final Method main = target.getMethod("main", param); diff --git a/src/main/org/apache/tools/ant/taskdefs/defaults.properties b/src/main/org/apache/tools/ant/taskdefs/defaults.properties index c2d950d41..02f9758f0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/defaults.properties +++ b/src/main/org/apache/tools/ant/taskdefs/defaults.properties @@ -88,6 +88,7 @@ cccheckin=org.apache.tools.ant.taskdefs.optional.clearcase.CCCheckin ccuncheckout=org.apache.tools.ant.taskdefs.optional.clearcase.CCUnCheckout sound=org.apache.tools.ant.taskdefs.optional.sound.SoundTask junitreport=org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator +vsslabel=org.apache.tools.ant.taskdefs.optional.vss.MSVSSLABEL # deprecated ant tasks (kept for back compatibility) javadoc2=org.apache.tools.ant.taskdefs.Javadoc diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java index ba6da6cbe..51ad99014 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java @@ -243,7 +243,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { // Get the filename into a String object File classFile = null; - String className = currentText; + String className = currentText.trim(); // If it's a primitive wrapper then we shouldn't try and put // it into the jar, so ignore it. diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java index 81abf204c..36baaae1d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java @@ -521,9 +521,12 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { } else { - //File other then class changed rebuild - log("Non class file " + genericEntry.getName() + " has changed",Project.MSG_VERBOSE); - rebuild = true; + // is it the manifest. If so ignore it + if (!genericEntry.getName().equals("META-INF/MANIFEST.MF")) { + //File other then class changed rebuild + log("Non class file " + genericEntry.getName() + " has changed",Project.MSG_VERBOSE); + rebuild = true; + } break; } } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java index a0453654a..6f414c3fc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ide/VAJImport.java @@ -95,7 +95,7 @@ import org.apache.tools.ant.types.FileSet; * Required * * - * project + * vajproject * the name of the Project to import to * Yes * @@ -130,7 +130,7 @@ public class VAJImport extends Task { /** * The VisualAge for Java Project name to import into. */ - public void setProject(String projectName) { + public void setVajproject(String projectName) { this.importProject = projectName; } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java b/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java index 94bab75ef..038935fe1 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/metamata/MParse.java @@ -62,46 +62,89 @@ import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; import org.apache.tools.ant.types.Path; -import java.io.File; -import java.io.IOException; +import java.io.*; +import java.util.*; -/* +/** + * Simple Metamata MParse task based on the original written by + * Thomas Haas + * + * This version was written for Metamata 2.0 available at + * http://www.metamata.com * - * @author thomas.haas@softwired-inc.com + * @author Stephane Bailliez */ public class MParse extends Task { - private Path userclasspath = null; + private Path classpath = null; + private Path sourcepath = null; private File metahome = null; - private File metaworkingdir = null; private File target = null; - private boolean cleanupHack = false; + private boolean verbose = false; + private boolean debugparser = false; + private boolean debugscanner = false; + private boolean cleanup = false; private CommandlineJava cmdl = new CommandlineJava(); + private File optionsFile = null; - + /** location of metamata dev environment */ public void setMetamatahome(File metamatahome) { this.metahome = metamatahome; } - public void setWorkingdir(File workingdir) { - this.metaworkingdir = workingdir; - } - + /** the .jj file to process */ public void setTarget(File target) { this.target = target; } - public Path createUserclasspath() { - if (userclasspath == null) { - userclasspath = new Path(project); - } - - return userclasspath; + /** create a classpath entry */ + public Path createClasspath() { + if (classpath == null) { + classpath = new Path(project); + } + return classpath; + } + + /** creates a sourcepath entry */ + public Path createSourcepath() { + if (sourcepath == null) { + sourcepath = new Path(project); + } + return sourcepath; + } + + /** set verbose mode */ + public void setVerbose(boolean flag){ + verbose = flag; + } + + /** set scanner debug mode */ + public void setDebugscanner(boolean flag){ + debugscanner = flag; + } + + /** set parser debug mode */ + public void setDebugparser(boolean flag){ + debugparser = flag; + } + + /** set the hack to cleanup the temp file */ + public void setCleanup(boolean value) { + cleanup = value; } + /** Creates a nested jvmarg element. */ + public Commandline.Argument createJvmarg() { + return cmdl.createVmArgument(); + } - public void setCleanupHack(boolean value) { - cleanupHack = value; + /** -mx or -Xmx depending on VM version */ + public void setMaxmemory(String max){ + if (Project.getJavaVersion().startsWith("1.1")) { + createJvmarg().setValue("-mx" + max); + } else { + createJvmarg().setValue("-Xmx" + max); + } } public MParse() { @@ -109,81 +152,200 @@ public class MParse extends Task { cmdl.setClassname("com.metamata.jj.MParse"); } - + + /** execute the command line */ public void execute() throws BuildException { - - if (target == null || !target.isFile()) { - throw new BuildException("Invalid target: " + target); - } - final File javaFile = new File(target.toString().substring(0, - target.toString().indexOf(".jj")) + ".java"); - if (javaFile.exists() && target.lastModified() < javaFile.lastModified()) { - project.log("Target is already build - skipping (" + target + ")"); - return; + try { + setUp(); + ExecuteStreamHandler handler = createStreamHandler(); + _execute(handler); + } finally { + cleanUp(); } - cmdl.createArgument().setValue(target.getAbsolutePath()); + } + + /** return the default stream handler for this task */ + protected ExecuteStreamHandler createStreamHandler(){ + return new LogStreamHandler(this, Project.MSG_INFO, Project.MSG_INFO); + } + + /** + * check the options and build the command line + */ + protected void setUp() throws BuildException { + checkOptions(); - if (metahome == null || !metahome.isDirectory()) { - throw new BuildException("Metamatahome not valid."); - } - if (metaworkingdir == null || !metaworkingdir.isDirectory()) { - throw new BuildException("Workingdir not set."); - } - if (userclasspath == null) { - throw new BuildException("Userclasspath not set."); + // set the classpath as the jar files + File[] jars = getMetamataLibs(); + final Path classPath = cmdl.createClasspath(project); + for (int i = 0; i < jars.length; i++){ + classPath.createPathElement().setLocation(jars[i]); } - final Path classpath = cmdl.createClasspath(project); - classpath.createPathElement().setLocation(new File(metahome.getAbsolutePath() + "/lib/metamatadebug.jar")); - classpath.createPathElement().setLocation(new File(metahome.getAbsolutePath() + "/lib/metamata.jar")); - classpath.createPathElement().setLocation(new File(metahome.getAbsolutePath() + "/lib/JavaCC.zip")); + // set the metamata.home property + final Commandline.Argument vmArgs = cmdl.createVmArgument(); + vmArgs.setValue("-Dmetamata.home=" + metahome.getAbsolutePath() ); - final Commandline.Argument arg = cmdl.createVmArgument(); - arg.setValue("-mx140M"); - arg.setValue("-Dmwp=" + metaworkingdir.getAbsolutePath()); - arg.setValue("-Dmetamata.home=" + metahome.getAbsolutePath()); - arg.setValue("-Dmetamata.java=java"); - arg.setValue("-Dmetamata.java.options=-mx140M"); - arg.setValue("-Dmetamata.java.options.classpath=-classpath"); - arg.setValue("-Dmetamata.java.compiler=javac"); - arg.setValue("-Dmetamata.java.compiler.options.0=-J-mx64M"); - arg.setValue("-Dmetamata.java.compiler.options.classpath=-classpath"); - arg.setValue("-Dmetamata.language=en"); - arg.setValue("-Dmetamata.country=US"); - arg.setValue("-Dmetamata.classpath=" + userclasspath); - final Execute process = new Execute(new LogStreamHandler(this, - Project.MSG_INFO, - Project.MSG_INFO), null); + // write all the options to a temp file and use it ro run the process + String[] options = getOptions(); + optionsFile = createTmpFile(); + generateOptionsFile(optionsFile, options); + Commandline.Argument args = cmdl.createArgument(); + args.setLine("-arguments " + optionsFile.getAbsolutePath()); + } + + + /** execute the process with a specific handler */ + protected void _execute(ExecuteStreamHandler handler) throws BuildException { + // target has been checked as a .jj, see if there is a matching + // java file and if it is needed to run to process the grammar + String pathname = target.getAbsolutePath(); + int pos = pathname.length() - ".jj".length(); + pathname = pathname.substring(0, pos) + ".java"; + File javaFile = new File(pathname); + if (javaFile.exists() && target.lastModified() < javaFile.lastModified()) { + project.log("Target is already build - skipping (" + target + ")"); + return; + } + + final Execute process = new Execute(handler); log(cmdl.toString(), Project.MSG_VERBOSE); process.setCommandline(cmdl.getCommandline()); - try { - try { - if (process.execute() != 0) { - throw new BuildException("MParse failed."); - } - } finally { - if (cleanupHack) { - final File oo393 = new File(javaFile.getParent(), - "OO393.class"); - if (oo393.exists()) { - project.log("Removing stale file: " + oo393.getName()); - oo393.delete(); - } - final File sunjj = new File(javaFile.getParent(), - "__jj" + javaFile.getName().substring(0, - javaFile.getName().indexOf(".java")) + ".sunjj"); - if (sunjj.exists()) { - project.log("Removing stale file: " + sunjj.getName()); - sunjj.delete(); - } - } + if (process.execute() != 0) { + throw new BuildException("Metamata task failed."); } + } catch (IOException e){ + throw new BuildException("Failed to launch Metamata task: " + e); + } + } + + /** clean up all the mess that we did with temporary objects */ + protected void cleanUp(){ + if (optionsFile != null){ + optionsFile.delete(); + optionsFile = null; + } + if (cleanup) { + String name = target.getName(); + int pos = name.length() - ".jj".length(); + name = "__jj" + name.substring(0, pos) + ".sunjj"; + final File sunjj = new File(target.getParent(), name); + if (sunjj.exists()) { + project.log("Removing stale file: " + sunjj.getName()); + sunjj.delete(); + } + } + } + + /** + * return an array of files containing the path to the needed + * libraries to run metamata. The file are not checked for + * existence. You should do this yourself if needed or simply let the + * forked process do it for you. + * @return array of jars/zips needed to run metamata. + */ + protected File[] getMetamataLibs(){ + Vector files = new Vector(); + files.addElement( new File(metahome, "lib/metamata.jar") ); + files.addElement( new File(metahome, "bin/lib/JavaCC.zip") ); + + File[] array = new File[ files.size() ]; + files.copyInto(array); + return array; + } + + + /** + * validate options set and resolve files and paths + * @throws BuildException thrown if an option has an incorrect state. + */ + protected void checkOptions() throws BuildException { + // check that the home is ok. + if (metahome == null || !metahome.exists()){ + throw new BuildException("'metamatahome' must point to Metamata home directory."); + } + metahome = project.resolveFile(metahome.getPath()); + + // check that the needed jar exists. + File[] jars = getMetamataLibs(); + for (int i = 0; i < jars.length; i++){ + if (!jars[i].exists()){ + throw new BuildException( jars[i] + " does not exist. Check your metamata installation."); + } + } + + // check that the target is ok and resolve it. + if (target == null || !target.isFile() || !target.getName().endsWith(".jj") ) { + throw new BuildException("Invalid target: " + target); + } + target = project.resolveFile(target.getPath()); + } + + /** + * return all options of the command line as string elements + * @param an array of options corresponding to the setted options. + */ + protected String[] getOptions(){ + Vector options = new Vector(); + if (verbose){ + options.addElement("-verbose"); + } + if (debugscanner){ + options.addElement("-ds"); + } + if (debugparser){ + options.addElement("-dp"); + } + if (classpath != null){ + options.addElement("-classpath"); + options.addElement(classpath.toString()); } - catch (IOException e) { - throw new BuildException("Failed to launch MParse: " + e); + if (sourcepath != null){ + options.addElement("-sourcepath"); + options.addElement(sourcepath.toString()); } + options.addElement(target.getAbsolutePath()); + + String[] array = new String[options.size()]; + options.copyInto(array); + return array; + } + + /** + * write all options to a file with one option / line + * @param tofile the file to write the options to. + * @param options the array of options element to write to the file. + * @throws BuildException thrown if there is a problem while writing + * to the file. + */ + protected void generateOptionsFile(File tofile, String[] options) throws BuildException { + FileWriter fw = null; + try { + fw = new FileWriter(tofile); + PrintWriter pw = new PrintWriter(fw); + for (int i = 0; i < options.length; i++){ + pw.println( options[i] ); + } + pw.flush(); + } catch (IOException e){ + throw new BuildException("Error while writing options file " + tofile, e); + } finally { + if (fw != null){ + try { + fw.close(); + } catch (IOException ignored){} + } + } + } + + /** create a temporary file in the current directory */ + protected final static File createTmpFile(){ + // must be compatible with JDK 1.1 !!!! + final long rand = (new Random(System.currentTimeMillis())).nextLong(); + File file = new File("metamata" + rand + ".tmp"); + return file; } } diff --git a/src/script/antRun.bat b/src/script/antRun.bat index a083cbf85..816cb606e 100755 --- a/src/script/antRun.bat +++ b/src/script/antRun.bat @@ -1,6 +1,8 @@ @echo off +# Change drive and directory to %1 (Win9X only for NT/2K use "cd /d") cd %1 +%1\ set ANT_RUN_CMD=%2 shift shift diff --git a/src/testcases/org/apache/tools/ant/IncludeTest.java b/src/testcases/org/apache/tools/ant/IncludeTest.java new file mode 100644 index 000000000..67dba02f3 --- /dev/null +++ b/src/testcases/org/apache/tools/ant/IncludeTest.java @@ -0,0 +1,94 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 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", "Ant", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their names without prior written + * permission of the Apache Group. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * ==================================================================== + * + * This software consists of voluntary contributions made by many + * individuals on behalf of the Apache Software Foundation. For more + * information on the Apache Software Foundation, please see + * . + */ + +package org.apache.tools.ant; + +import org.apache.tools.ant.taskdefs.TaskdefsTest; + +/** + * Test the build file inclusion using XML entities. + * + * @author Conor MacNeill + */ +public class IncludeTest extends TaskdefsTest { + + public IncludeTest(String name) { + super(name); + } + + public void test1() { + configureProject("src/etc/testcases/core/include/basic/include.xml"); + expectLog("test1", "from included entity"); + } + + public void test2() { + configureProject("src/etc/testcases/core/include/frag#ment/include.xml"); + expectLog("test1", "from included entity"); + } + + public void test3() { + configureProject("src/etc/testcases/core/include/frag#ment/simple.xml"); + expectLog("test1", "from simple buildfile"); + } + + public void test4() { + configureProject("src/etc/testcases/core/include/basic/relative.xml"); + expectLog("test1", "from included entity"); + } + + public void test5() { + configureProject("src/etc/testcases/core/include/frag#ment/relative.xml"); + expectLog("test1", "from included entity"); + } +} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/PropertyTest.java b/src/testcases/org/apache/tools/ant/taskdefs/PropertyTest.java new file mode 100644 index 000000000..3b5378536 --- /dev/null +++ b/src/testcases/org/apache/tools/ant/taskdefs/PropertyTest.java @@ -0,0 +1,74 @@ +/* + * The Apache Software License, Version 1.1 + * + * Copyright (c) 2001 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", "Ant", and "Apache Software + * Foundation" must not be used to endorse or promote products derived + * from this software without prior written permission. For written + * permission, please contact apache@apache.org. + * + * 5. Products derived from this software may not be called "Apache" + * nor may "Apache" appear in their 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; + +/** + * @author Conor MacNeill + */ +public class PropertyTest extends TaskdefsTest { + + public PropertyTest(String name) { + super(name); + } + + public void setUp() { + configureProject("src/etc/testcases/taskdefs/property.xml"); + } + + public void test1() { + // should get no output at all + expectOutputAndError("test1", "", ""); + } +} diff --git a/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java b/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java index 197aafe37..92eb4b574 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/TaskdefsTest.java @@ -67,6 +67,7 @@ public abstract class TaskdefsTest extends TestCase { private StringBuffer logBuffer; private StringBuffer outBuffer; + private StringBuffer errBuffer; private BuildException buildException; public TaskdefsTest(String name) { @@ -92,36 +93,54 @@ public abstract class TaskdefsTest extends TestCase { assertEquals(output, realOutput); } + protected void expectOutputAndError(String taskname, String output, String error) { + executeTarget(taskname); + String realOutput = getOutput(); + assertEquals(output, realOutput); + String realError = getError(); + assertEquals(error, realError); + } + protected void expectLog(String taskname, String log) { executeTarget(taskname); String realLog = getLog(); assertEquals(log, realLog); } - protected String getOutput() { - StringBuffer cleanOut = new StringBuffer(); + + protected String getOutput() { + return cleanBuffer(outBuffer); + } + + protected String getError() { + return cleanBuffer(errBuffer); + } + + private String cleanBuffer(StringBuffer buffer) { + StringBuffer cleanedBuffer = new StringBuffer(); boolean cr = false; - for (int i = 0; i < outBuffer.length(); i++) { - char ch = outBuffer.charAt(i); + for (int i = 0; i < buffer.length(); i++) { + char ch = buffer.charAt(i); if (ch == '\r') { cr = true; continue; } if (!cr) { - cleanOut.append(ch); + cleanedBuffer.append(ch); } else { if (ch == '\n') { - cleanOut.append(ch); + cleanedBuffer.append(ch); } else { - cleanOut.append('\r').append(ch); + cleanedBuffer.append('\r').append(ch); } } } - return cleanOut.toString(); + return cleanedBuffer.toString(); } protected void configureProject(String filename) { + logBuffer = new StringBuffer(); project = new Project(); project.init(); project.setUserProperty( "ant.file" , new File(filename).getAbsolutePath() ); @@ -131,16 +150,22 @@ public abstract class TaskdefsTest extends TestCase { protected void executeTarget(String targetName) { PrintStream sysOut = System.out; + PrintStream sysErr = System.err; try { - outBuffer = new StringBuffer(); sysOut.flush(); + sysErr.flush(); + outBuffer = new StringBuffer(); PrintStream out = new PrintStream(new AntOutputStream()); System.setOut(out); + errBuffer = new StringBuffer(); + PrintStream err = new PrintStream(new AntOutputStream()); + System.setErr(err); logBuffer = new StringBuffer(); buildException = null; project.executeTarget(targetName); } finally { System.setOut(sysOut); + System.setErr(sysErr); } } diff --git a/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java b/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java index ae19289c2..d98beb37d 100644 --- a/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java +++ b/src/testcases/org/apache/tools/ant/taskdefs/optional/ANTLRTest.java @@ -87,7 +87,7 @@ public class ANTLRTest extends TaskdefsTest { } public void test4() { - expectBuildException("test4", "ANTLR exited with an error code of 1 ( try forking )"); + executeTarget("test4"); } public void test5() {