This is an automated email from the ASF dual-hosted git repository.

elharo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/xerces-j.git


The following commit(s) were added to refs/heads/main by this push:
     new 59c0da038 Upgrade ant to 1.10.15 (#13)
59c0da038 is described below

commit 59c0da0380cbca307e84fe24dcd0e2b3fa452421
Author: Elliotte Rusty Harold <[email protected]>
AuthorDate: Wed Jun 25 12:34:06 2025 +0000

    Upgrade ant to 1.10.15 (#13)
---
 tools/ant-junit.jar    | Bin 93518 -> 141395 bytes
 tools/ant-launcher.jar | Bin 12143 -> 18870 bytes
 tools/ant.jar          | Bin 1323005 -> 2304360 bytes
 tools/bin/ant          | 252 +++++++++++++++++++++++-------------
 tools/bin/ant.bat      | 344 +++++++++++++++++++++++++++++++------------------
 tools/bin/antRun       |  28 ++--
 tools/bin/antRun.bat   |  96 +++++++-------
 7 files changed, 445 insertions(+), 275 deletions(-)

diff --git a/tools/ant-junit.jar b/tools/ant-junit.jar
index 063cce4f9..f983a5aa4 100644
Binary files a/tools/ant-junit.jar and b/tools/ant-junit.jar differ
diff --git a/tools/ant-launcher.jar b/tools/ant-launcher.jar
index 7c8f849ec..62c3e4714 100644
Binary files a/tools/ant-launcher.jar and b/tools/ant-launcher.jar differ
diff --git a/tools/ant.jar b/tools/ant.jar
index 704717779..e06c352d8 100644
Binary files a/tools/ant.jar and b/tools/ant.jar differ
diff --git a/tools/bin/ant b/tools/bin/ant
index cf336db07..81107b58f 100755
--- a/tools/bin/ant
+++ b/tools/bin/ant
@@ -1,18 +1,19 @@
 #! /bin/sh
 
-#   Copyright 2001-2005 The Apache Software Foundation
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
 #
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
+#     https://www.apache.org/licenses/LICENSE-2.0
 #
-#       http://www.apache.org/licenses/LICENSE-2.0
-#
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 
 # Extract launch and ant arguments, (see details below).
 ant_exec_args=
@@ -20,54 +21,94 @@ no_config=false
 use_jikes_default=false
 ant_exec_debug=false
 show_help=false
-for arg in "$@" ; do
-  if [ "$arg" = "--noconfig" ] ; then
+
+if [ -z "$PROTECT_NL" ]; then
+  PROTECT_NL=true
+  os=`uname -s`
+  rel=`uname -r`
+  # heirloom bourne-shell used by Solaris 10 is not POSIX
+  # it lacks features necessary to protect trailing NL from subshell trimming
+  if [ "$os" = SunOS -a "$rel" = "5.10" ]; then
+    PROTECT_NL=false
+  fi
+fi
+
+for arg in "$@"; do
+  if [ "$arg" = "--noconfig" ]; then
     no_config=true
-  elif [ "$arg" = "--usejikes" ] ; then
+  elif [ "$arg" = "--usejikes" ]; then
     use_jikes_default=true
-  elif [ "$arg" = "--execdebug" ] ; then
+  elif [ "$arg" = "--execdebug" ]; then
     ant_exec_debug=true
-  elif [ my"$arg" = my"--h"  -o my"$arg" = my"--help"  ] ; then
+  elif [ my"$arg" = my"--h" -o my"$arg" = my"--help"  ]; then
     show_help=true
     ant_exec_args="$ant_exec_args -h"
   else
-    if [  my"$arg" = my"-h"  -o  my"$arg" = my"-help" ] ; then
+    if [  my"$arg" = my"-h" -o  my"$arg" = my"-help" ]; then
       show_help=true
     fi
-    ant_exec_args="$ant_exec_args \"$arg\""
+
+    if [ "$PROTECT_NL" = "true" ]; then
+      # pad the value with X to protect trailing NLs from subshell output 
trimming
+      esc_arg="${arg}X"
+    else
+      esc_arg="${arg}"
+    fi
+
+    # wrap all arguments as "" strings, escape any internal back-slash, 
double-quote, $, or back-tick characters
+    #  use printf to avoid echo interpretation behaviors such as escapes and 
line continuation
+    # Mac bsd_sed does not support group-0, so pattern uses group-1
+    # Solaris sed only processes lines with trailing newline, passing in an 
extra newline
+    # subshell (heirloom and posix) will trim the added trailing newline
+    esc_arg="`printf '%s\n' "$esc_arg" | sed -e 's@\([$\"\`\\]\)@\\\\\\1@g' `"
+
+    if [ "$PROTECT_NL" = "true" ]; then
+      # remove the padding X added above, this syntax is POSIX compatible but 
not heirloom-sh
+      esc_arg="${esc_arg%X}"
+    fi
+    quoted_arg="\"$esc_arg\""
+
+    if $ant_exec_debug; then
+      # using printf to avoid echo line continuation and escape interpretation
+      printf "arg       : %s\n" "$arg"
+      printf "quoted_arg: %s\n" "$quoted_arg"
+    fi
+    ant_exec_args="$ant_exec_args $quoted_arg"
   fi
 done
 
 # Source/default ant configuration
-if $no_config ; then
+if $no_config; then
   rpm_mode=false
   usejikes=$use_jikes_default
 else
-  # load system-wide ant configuration
-  if [ -f "/etc/ant.conf" ] ; then
-    . /etc/ant.conf
+  # load system-wide ant configuration (ONLY if ANT_HOME has NOT been set)
+  if [ -z "$ANT_HOME" -o "$ANT_HOME" = "/usr/share/ant" ]; then
+    if [ -f "/etc/ant.conf" ]; then
+      . /etc/ant.conf
+    fi
   fi
 
   # load user ant configuration
-  if [ -f "$HOME/.ant/ant.conf" ] ; then
+  if [ -f "$HOME/.ant/ant.conf" ]; then
     . $HOME/.ant/ant.conf
   fi
-  if [ -f "$HOME/.antrc" ] ; then
+  if [ -f "$HOME/.antrc" ]; then
     . "$HOME/.antrc"
   fi
 
   # provide default configuration values
-  if [ -z "$rpm_mode" ] ; then
+  if [ -z "$rpm_mode" ]; then
     rpm_mode=false
   fi
-  if [ -z "$usejikes" ] ; then
+  if [ -z "$usejikes" ]; then
     usejikes=$use_jikes_default
   fi
 fi
 
 # Setup Java environment in rpm mode
-if $rpm_mode ; then
-  if [ -f /usr/share/java-utils/java-functions ] ; then
+if $rpm_mode; then
+  if [ -f /usr/share/java-utils/java-functions ]; then
     . /usr/share/java-utils/java-functions
     set_jvm
     set_javacmd
@@ -77,93 +118,129 @@ fi
 # OS specific support.  $var _must_ be set to either true or false.
 cygwin=false;
 darwin=false;
+mingw=false;
 case "`uname`" in
-  CYGWIN*) cygwin=true ;;
-  Darwin*) darwin=true
-           if [ -z "$JAVA_HOME" ] ; then
-             JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
-           fi
-           ;;
+  CYGWIN*)
+    cygwin=true
+    ;;
+  Darwin*)
+    darwin=true
+    if [ -z "$JAVA_HOME" ]; then
+      if [ -x '/usr/libexec/java_home' ]; then
+        JAVA_HOME=`/usr/libexec/java_home`
+      elif [ -d 
"/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home" ]; then
+        
JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
+      fi
+    fi
+    ;;
+  MINGW*)
+    mingw=true
+    ;;
 esac
 
-if [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ] ; then
+if [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ]; then
   ## resolve links - $0 may be a link to ant's home
   PRG="$0"
   progname=`basename "$0"`
 
   # need this for relative symlinks
-  while [ -h "$PRG" ] ; do
+  while [ -h "$PRG" ]; do
     ls=`ls -ld "$PRG"`
     link=`expr "$ls" : '.*-> \(.*\)$'`
     if expr "$link" : '/.*' > /dev/null; then
-    PRG="$link"
+      PRG="$link"
     else
-    PRG=`dirname "$PRG"`"/$link"
+      PRG=`dirname "$PRG"`"/$link"
     fi
   done
 
   ANT_HOME=`dirname "$PRG"`/..
 
   # make it fully qualified
-  ANT_HOME=`cd "$ANT_HOME" && pwd`
+  ANT_HOME=`cd "$ANT_HOME" > /dev/null && pwd`
 fi
 
-# For Cygwin, ensure paths are in UNIX format before anything is touched
-if $cygwin ; then
-  [ -n "$ANT_HOME" ] &&
-    ANT_HOME=`cygpath --unix "$ANT_HOME"`
-  [ -n "$JAVA_HOME" ] &&
-    JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+# For Cygwin and Mingw, ensure paths are in UNIX format before
+# anything is touched
+if $cygwin; then
+  [ -n "$ANT_HOME" ] && ANT_HOME=`cygpath --unix "$ANT_HOME"`
+  [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
+fi
+if $mingw; then
+  [ -n "$ANT_HOME" ] && ANT_HOME="`(cd "$ANT_HOME"; pwd)`"
+  [ -n "$JAVA_HOME" ] && JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
 fi
 
 # set ANT_LIB location
 ANT_LIB="${ANT_HOME}/lib"
 
-if [ -z "$JAVACMD" ] ; then
-  if [ -n "$JAVA_HOME"  ] ; then
-    if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
-      # IBM's JDK on AIX uses strange locations for the executables
+if [ -z "$JAVACMD" ]; then
+  if [ -n "$JAVA_HOME" ]; then
+    # IBM's JDK on AIX uses strange locations for the executables
+    if [ -x "$JAVA_HOME/jre/sh/java" ]; then
       JAVACMD="$JAVA_HOME/jre/sh/java"
+    elif [ -x "$JAVA_HOME/jre/bin/java" ]; then
+      JAVACMD="$JAVA_HOME/jre/bin/java"
     else
       JAVACMD="$JAVA_HOME/bin/java"
     fi
   else
     JAVACMD=`which java 2> /dev/null `
-    if [ -z "$JAVACMD" ] ; then
-        JAVACMD=java
+    if [ -z "$JAVACMD" ]; then
+      JAVACMD=java
     fi
   fi
 fi
 
-if [ ! -x "$JAVACMD" ] ; then
-  echo "Error: JAVA_HOME is not defined correctly."
-  echo "  We cannot execute $JAVACMD"
+if [ ! -x "$JAVACMD" ]; then
+  echo "We cannot run Java, please ensure you have Java installed."
+  echo "  We have tried to execute $JAVACMD but failed."
+  echo "If you have installed Java in a unusual place you can set JAVA_HOME"
+  echo "to the directory containing the Java installation."
   exit 1
 fi
 
 # Build local classpath using just the launcher in non-rpm mode or
 # use the Jpackage helper in rpm mode with basic and default jars
 # specified in the ant.conf configuration. Because the launcher is
-# used, libraries linked in ANT_HOME will also be include, but this
+# used, libraries linked in ANT_HOME/lib will also be included, but this
 # is discouraged as it is not java-version safe. A user should
 # request optional jars and their dependencies via the OPT_JAR_LIST
 # variable
-if $rpm_mode && [ -f /usr/bin/build-classpath ] ; then
+if $rpm_mode && [ -x /usr/bin/build-classpath ]; then
   LOCALCLASSPATH="$(/usr/bin/build-classpath ant ant-launcher jaxp_parser_impl 
xml-commons-apis)"
+
+  # If no optional jars have been specified then build the default list
+  if [ -z "$OPT_JAR_LIST" ]; then
+    for file in /etc/ant.d/*; do
+      if [ -f "$file" ]; then
+        case "$file" in
+          *~|*#*|*.rpmsave|*.rpmnew)
+          ;;
+          *)
+            for dep in `cat "$file"`; do
+              OPT_JAR_LIST="$OPT_JAR_LIST${OPT_JAR_LIST:+ }$dep"
+            done
+          ;;
+        esac
+      fi
+    done
+  fi
+
   # If the user requested to try to add some other jars to the classpath
-  if [ -n "$OPT_JAR_LIST" ] ; then
+  if [ -n "$OPT_JAR_LIST" ]; then
     _OPTCLASSPATH="$(/usr/bin/build-classpath $OPT_JAR_LIST 2> /dev/null)"
-    if [ -n "$_OPTCLASSPATH" ] ; then 
+    if [ -n "$_OPTCLASSPATH" ]; then
       LOCALCLASSPATH="$LOCALCLASSPATH:$_OPTCLASSPATH"
     fi
   fi
 
   # Explicitly add javac path to classpath, assume JAVA_HOME set
   # properly in rpm mode
-  if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
+  if [ -f "$JAVA_HOME/lib/tools.jar" ]; then
     LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
   fi
-  if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
+  if [ -f "$JAVA_HOME/lib/classes.zip" ]; then
     LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
   fi
 
@@ -173,11 +250,11 @@ if $rpm_mode && [ -f /usr/bin/build-classpath ] ; then
   #
   # if CLASSPATH_OVERRIDE is not set, we'll have the normal behaviour
   # with ant-found jars first and user CLASSPATH after
-  if [ -n "$CLASSPATH" ] ; then
-    # merge local and specified classpath 
-    if [ -z "$LOCALCLASSPATH" ] ; then 
+  if [ -n "$CLASSPATH" ]; then
+    # merge local and specified classpath
+    if [ -z "$LOCALCLASSPATH" ]; then
       LOCALCLASSPATH="$CLASSPATH"
-    elif [ -n "$CLASSPATH_OVERRIDE" ] ; then
+    elif [ -n "$CLASSPATH_OVERRIDE" ]; then
       LOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH"
     else
       LOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH"
@@ -188,20 +265,19 @@ if $rpm_mode && [ -f /usr/bin/build-classpath ] ; then
   fi
 else
   # not using rpm_mode; use launcher to determine classpaths
-  if [ -z "$LOCALCLASSPATH" ] ; then
-      LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
+  if [ -z "$LOCALCLASSPATH" ]; then
+    LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
   else
-      LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
+    LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
   fi
 fi
 
-if [ -n "$JAVA_HOME" ] ; then
+if [ -n "$JAVA_HOME" ]; then
   # OSX hack to make Ant work with jikes
-  if $darwin ; then
+  if $darwin; then
     OSXHACK="${JAVA_HOME}/../Classes"
-    if [ -d "${OSXHACK}" ] ; then
-      for i in "${OSXHACK}"/*.jar
-      do
+    if [ -d "${OSXHACK}" ]; then
+      for i in "${OSXHACK}"/*.jar; do
         JIKESPATH="$JIKESPATH:$i"
       done
     fi
@@ -219,17 +295,17 @@ fi
 # in the name in the path. Let's assume that paths containing ; are more
 # rare than windows style paths on cygwin.
 if $cygwin; then
-  if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
+  if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null; then
     format=mixed
   else
     format=windows
   fi
-  ANT_HOME=`cygpath --$format "$ANT_HOME"`
+  [ -n "$ANT_HOME" ] && ANT_HOME=`cygpath --$format "$ANT_HOME"`
   ANT_LIB=`cygpath --$format "$ANT_LIB"`
-  JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
+  [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
   LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`
   LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`
-  if [ -n "$CLASSPATH" ] ; then
+  if [ -n "$CLASSPATH" ]; then
     CP_TEMP=`cygpath --path --unix "$CLASSPATH"`
     CLASSPATH=`cygpath --path --$format "$CP_TEMP"`
   fi
@@ -237,7 +313,7 @@ if $cygwin; then
 fi
 
 # Show script help if requested
-if $show_help ; then
+if $show_help; then
   echo $0 '[script options] [options] [target [target2 [target3] ..]]'
   echo 'Script Options:'
   echo '  --help, --h            print this message and ant help'
@@ -248,33 +324,33 @@ if $show_help ; then
   echo '                         set explicitly in configuration files'
   echo '  --execdebug            print ant exec line generated by this'
   echo '                         launch script'
-  echo '  '
+  echo ''
 fi
 # add a second backslash to variables terminated by a backslash under cygwin
 if $cygwin; then
   case "$ANT_HOME" in
     *\\ )
-    ANT_HOME="$ANT_HOME\\"
+      ANT_HOME="$ANT_HOME\\"
     ;;
   esac
   case "$CYGHOME" in
     *\\ )
-    CYGHOME="$CYGHOME\\"
+      CYGHOME="$CYGHOME\\"
     ;;
   esac
   case "$JIKESPATH" in
     *\\ )
-    JIKESPATH="$JIKESPATH\\"
+      JIKESPATH="$JIKESPATH\\"
     ;;
   esac
   case "$LOCALCLASSPATH" in
     *\\ )
-    LOCALCLASSPATH="$LOCALCLASSPATH\\"
+      LOCALCLASSPATH="$LOCALCLASSPATH\\"
     ;;
   esac
   case "$CLASSPATH" in
     *\\ )
-    CLASSPATH="$CLASSPATH\\"
+      CLASSPATH="$CLASSPATH\\"
     ;;
   esac
 fi
@@ -292,8 +368,10 @@ else
     ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
   fi
 fi
-ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" 
-Dant.home=\"$ANT_HOME\" -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts 
org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"$CLASSPATH\" 
$ant_exec_args"
-if $ant_exec_debug ; then
-    echo $ant_exec_command
+ant_exec_command="exec \"\$JAVACMD\" $ANT_OPTS -classpath \"\$LOCALCLASSPATH\" 
-Dant.home=\"\$ANT_HOME\" -Dant.library.dir=\"\$ANT_LIB\" $ant_sys_opts 
org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"\$CLASSPATH\""
+if $ant_exec_debug; then
+  # using printf to avoid echo line continuation and escape interpretation 
confusion
+  printf "%s\n" "$ant_exec_command $ant_exec_args"
 fi
-eval $ant_exec_command
+
+eval "$ant_exec_command $ant_exec_args"
diff --git a/tools/bin/ant.bat b/tools/bin/ant.bat
old mode 100755
new mode 100644
index e2dafabdd..41f8530ba
--- a/tools/bin/ant.bat
+++ b/tools/bin/ant.bat
@@ -1,126 +1,218 @@
-@echo off
-
-REM  Copyright 2001,2004-2005 The Apache Software Foundation
-REM
-REM  Licensed under the Apache License, Version 2.0 (the "License");
-REM  you may not use this file except in compliance with the License.
-REM  You may obtain a copy of the License at
-REM
-REM      http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM  Unless required by applicable law or agreed to in writing, software
-REM  distributed under the License is distributed on an "AS IS" BASIS,
-REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM  See the License for the specific language governing permissions and
-REM  limitations under the License.
-
-if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat"
-
-if "%OS%"=="Windows_NT" @setlocal
-if "%OS%"=="WINNT" @setlocal
-
-rem %~dp0 is expanded pathname of the current script under NT
-set DEFAULT_ANT_HOME=%~dp0..
-
-if "%ANT_HOME%"=="" set ANT_HOME=%DEFAULT_ANT_HOME%
-set DEFAULT_ANT_HOME=
-
-set _USE_CLASSPATH=yes
-
-rem Slurp the command line arguments. This loop allows for an unlimited number
-rem of arguments (up to the command line limit, anyway).
-set ANT_CMD_LINE_ARGS=%1
-if ""%1""=="""" goto doneStart
-shift
-:setupArgs
-if ""%1""=="""" goto doneStart
-if ""%1""==""-noclasspath"" goto clearclasspath
-set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1
-shift
-goto setupArgs
-
-rem here is there is a -noclasspath in the options
-:clearclasspath
-set _USE_CLASSPATH=no
-shift
-goto setupArgs
-
-rem This label provides a place for the argument list loop to break out
-rem and for NT handling to skip to.
-
-:doneStart
-rem find ANT_HOME if it does not exist due to either an invalid value passed
-rem by the user or the %0 problem on Windows 9x
-if exist "%ANT_HOME%\lib\ant.jar" goto checkJava
-
-rem check for ant in Program Files
-if not exist "%ProgramFiles%\ant" goto checkSystemDrive
-set ANT_HOME=%ProgramFiles%\ant
-goto checkJava
-
-:checkSystemDrive
-rem check for ant in root directory of system drive
-if not exist %SystemDrive%\ant\lib\ant.jar goto checkCDrive
-set ANT_HOME=%SystemDrive%\ant
-goto checkJava
-
-:checkCDrive
-rem check for ant in C:\ant for Win9X users
-if not exist C:\ant\lib\ant.jar goto noAntHome
-set ANT_HOME=C:\ant
-goto checkJava
-
-:noAntHome
-echo ANT_HOME is set incorrectly or ant could not be located. Please set 
ANT_HOME.
-goto end
-
-:checkJava
-set _JAVACMD=%JAVACMD%
-
-if "%JAVA_HOME%" == "" goto noJavaHome
-if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
-if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
-goto checkJikes
-
-:noJavaHome
-if "%_JAVACMD%" == "" set _JAVACMD=java.exe
-
-:checkJikes
-if not "%JIKESPATH%"=="" goto runAntWithJikes
-
-:runAnt
-if "%_USE_CLASSPATH%"=="no" goto runAntNoClasspath
-if not "%CLASSPATH%"=="" goto runAntWithClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% 
%ANT_CMD_LINE_ARGS%
-goto end
-
-:runAntNoClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% 
%ANT_CMD_LINE_ARGS%
-goto end
-
-:runAntWithClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp 
"%CLASSPATH%" %ANT_CMD_LINE_ARGS%
-goto end
-
-:runAntWithJikes
-if "%_USE_CLASSPATH%"=="no" goto runAntWithJikesNoClasspath
-if not "%CLASSPATH%"=="" goto runAntWithJikesAndClasspath
-
-:runAntWithJikesNoClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" 
org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
-goto end
-
-:runAntWithJikesAndClasspath
-"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" 
org.apache.tools.ant.launch.Launcher %ANT_ARGS%  -cp "%CLASSPATH%" 
%ANT_CMD_LINE_ARGS%
-goto end
-
-:end
-set _JAVACMD=
-set ANT_CMD_LINE_ARGS=
-
-if "%OS%"=="Windows_NT" @endlocal
-if "%OS%"=="WINNT" @endlocal
-
-:mainEnd
-if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat"
-
+@echo off
+
+REM  Licensed to the Apache Software Foundation (ASF) under one or more
+REM  contributor license agreements.  See the NOTICE file distributed with
+REM  this work for additional information regarding copyright ownership.
+REM  The ASF licenses this file to You under the Apache License, Version 2.0
+REM  (the "License"); you may not use this file except in compliance with
+REM  the License.  You may obtain a copy of the License at
+REM
+REM      https://www.apache.org/licenses/LICENSE-2.0
+REM
+REM  Unless required by applicable law or agreed to in writing, software
+REM  distributed under the License is distributed on an "AS IS" BASIS,
+REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM  See the License for the specific language governing permissions and
+REM  limitations under the License.
+
+REM This is an inordinately troublesome piece of code, particularly because it
+REM tries to work on both Win9x and WinNT-based systems. If we could abandon 
'9x
+REM support, things would be much easier, but sadly, it is not yet time.
+REM Be cautious about editing this, and only add WinNT specific stuff in code 
that
+REM only runs on WinNT.
+
+if "%HOME%"=="" goto homeDrivePathPre
+if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat"
+
+:homeDrivePathPre
+if "%HOMEDRIVE%%HOMEPATH%"=="" goto userProfilePre
+if "%HOMEDRIVE%%HOMEPATH%"=="%HOME%" goto userProfilePre
+if exist "%HOMEDRIVE%%HOMEPATH%\antrc_pre.bat" call 
"%HOMEDRIVE%%HOMEPATH%\antrc_pre.bat"
+
+:userProfilePre
+if "%USERPROFILE%"=="" goto alpha
+if "%USERPROFILE%"=="%HOME%" goto alpha
+if "%USERPROFILE%"=="%HOMEDRIVE%%HOMEPATH%" goto alpha
+if exist "%USERPROFILE%\antrc_pre.bat" call "%USERPROFILE%\antrc_pre.bat"
+
+:alpha
+
+if "%OS%"=="Windows_NT" @setlocal
+if "%OS%"=="WINNT" @setlocal
+
+if "%ANT_HOME%"=="" goto setDefaultAntHome
+
+:stripAntHome
+if not _%ANT_HOME:~-1%==_\ goto checkClasspath
+set ANT_HOME=%ANT_HOME:~0,-1%
+goto stripAntHome
+
+:setDefaultAntHome
+rem %~dp0 is expanded pathname of the current script under NT
+set ANT_HOME=%~dp0..
+
+:checkClasspath
+set _USE_CLASSPATH=yes
+rem CLASSPATH must not be used if it is equal to ""
+if "%CLASSPATH%"=="""" set _USE_CLASSPATH=no
+if "%CLASSPATH%"=="" set _USE_CLASSPATH=no
+
+rem Slurp the command line arguments. This loop allows for an unlimited number
+rem of arguments (up to the command line limit, anyway).
+set ANT_CMD_LINE_ARGS=
+:setupArgs
+if ""%1""=="""" goto doneStart
+if ""%1""==""-noclasspath"" goto clearclasspath
+set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1
+shift
+goto setupArgs
+
+rem here is there is a -noclasspath in the options
+:clearclasspath
+set _USE_CLASSPATH=no
+shift
+goto setupArgs
+
+rem This label provides a place for the argument list loop to break out
+rem and for NT handling to skip to.
+
+:doneStart
+
+if "%_USE_CLASSPATH%"=="no" goto findAntHome
+
+:stripClasspath
+if not _%CLASSPATH:~-1%==_\ goto findAntHome
+set CLASSPATH=%CLASSPATH:~0,-1%
+goto stripClasspath
+
+:findAntHome
+rem find ANT_HOME if it does not exist due to either an invalid value passed
+rem by the user or the %0 problem on Windows 9x
+if exist "%ANT_HOME%\lib\ant.jar" goto checkJava
+
+rem check for ant in Program Files
+if not exist "%ProgramFiles%\ant" goto checkSystemDrive
+set ANT_HOME=%ProgramFiles%\ant
+goto checkJava
+
+:checkSystemDrive
+rem check for ant in root directory of system drive
+if not exist %SystemDrive%\ant\lib\ant.jar goto checkCDrive
+set ANT_HOME=%SystemDrive%\ant
+goto checkJava
+
+:checkCDrive
+rem check for ant in C:\ant for Win9X users
+if not exist C:\ant\lib\ant.jar goto noAntHome
+set ANT_HOME=C:\ant
+goto checkJava
+
+:noAntHome
+echo ANT_HOME is set incorrectly or ant could not be located. Please set 
ANT_HOME.
+goto end
+
+:checkJava
+set _JAVACMD=%JAVACMD%
+
+if "%JAVA_HOME%" == "" goto noJavaHome
+if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome
+if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe
+goto checkJikes
+
+:noJavaHome
+if "%_JAVACMD%" == "" set _JAVACMD=java.exe
+
+:checkJikes
+if not "%JIKESPATH%"=="" goto runAntWithJikes
+
+:runAnt
+if "%_USE_CLASSPATH%"=="no" goto runAntNoClasspath
+:runAntWithClasspath
+"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp 
"%CLASSPATH%" %ANT_CMD_LINE_ARGS%
+rem Check the error code of the Ant build
+if not "%OS%"=="Windows_NT" goto onError
+set ANT_ERROR=%ERRORLEVEL%
+goto end
+
+:runAntNoClasspath
+"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% 
%ANT_CMD_LINE_ARGS%
+rem Check the error code of the Ant build
+if not "%OS%"=="Windows_NT" goto onError
+set ANT_ERROR=%ERRORLEVEL%
+goto end
+
+:runAntWithJikes
+
+if not _%JIKESPATH:~-1%==_\ goto checkJikesAndClasspath
+set JIKESPATH=%JIKESPATH:~0,-1%
+goto runAntWithJikes
+
+:checkJikesAndClasspath
+
+if "%_USE_CLASSPATH%"=="no" goto runAntWithJikesNoClasspath
+
+:runAntWithJikesAndClasspath
+"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" 
org.apache.tools.ant.launch.Launcher %ANT_ARGS%  -cp "%CLASSPATH%" 
%ANT_CMD_LINE_ARGS%
+rem Check the error code of the Ant build
+if not "%OS%"=="Windows_NT" goto onError
+set ANT_ERROR=%ERRORLEVEL%
+goto end
+
+:runAntWithJikesNoClasspath
+"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" 
"-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" 
org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS%
+rem Check the error code of the Ant build
+if not "%OS%"=="Windows_NT" goto onError
+set ANT_ERROR=%ERRORLEVEL%
+goto end
+
+:onError
+rem Windows 9x way of checking the error code.  It matches via brute force.
+for %%i in (1 10 100) do set err%%i=
+for %%i in (0 1 2) do if errorlevel %%i00 set err100=%%i
+if %err100%==2 goto onError200
+if %err100%==0 set err100=
+for %%i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %err100%%%i0 set err10=%%i
+if "%err100%"=="" if %err10%==0 set err10=
+:onError1
+for %%i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %err100%%err10%%%i set 
err1=%%i
+goto onErrorEnd
+:onError200
+for %%i in (0 1 2 3 4 5) do if errorlevel 2%%i0 set err10=%%i
+if err10==5 for %%i in (0 1 2 3 4 5) do if errorlevel 25%%i set err1=%%i
+if not err10==5 goto onError1
+:onErrorEnd
+set ANT_ERROR=%err100%%err10%%err1%
+for %%i in (1 10 100) do set err%%i=
+
+:end
+rem bug ID 32069: resetting an undefined env variable changes the errorlevel.
+if not "%_JAVACMD%"=="" set _JAVACMD=
+if not "%_ANT_CMD_LINE_ARGS%"=="" set ANT_CMD_LINE_ARGS=
+
+if "%ANT_ERROR%"=="0" goto mainEnd
+
+goto omega
+
+:mainEnd
+
+rem If there were no errors, we run the post script.
+if "%OS%"=="Windows_NT" @endlocal
+if "%OS%"=="WINNT" @endlocal
+
+if "%HOME%"=="" goto homeDrivePathPost
+if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat"
+
+:homeDrivePathPost
+if "%HOMEDRIVE%%HOMEPATH%"=="" goto userProfilePost
+if "%HOMEDRIVE%%HOMEPATH%"=="%HOME%" goto userProfilePost
+if exist "%HOMEDRIVE%%HOMEPATH%\antrc_post.bat" call 
"%HOMEDRIVE%%HOMEPATH%\antrc_post.bat"
+
+:userProfilePost
+if "%USERPROFILE%"=="" goto omega
+if "%USERPROFILE%"=="%HOME%" goto omega
+if "%USERPROFILE%"=="%HOMEDRIVE%%HOMEPATH%" goto omega
+if exist "%USERPROFILE%\antrc_post.bat" call "%USERPROFILE%\antrc_post.bat"
+
+:omega
+
+exit /b %ANT_ERROR%
diff --git a/tools/bin/antRun b/tools/bin/antRun
index baddd71cd..713762eff 100755
--- a/tools/bin/antRun
+++ b/tools/bin/antRun
@@ -1,21 +1,19 @@
-#!/bin/sh
+#! /bin/sh
 
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License.  You may obtain a copy of the License at
 #
-#  Copyright  2001-2002,2004 The Apache Software Foundation
-# 
-#   Licensed under the Apache License, Version 2.0 (the "License");
-#   you may not use this file except in compliance with the License.
-#   You may obtain a copy of the License at
-# 
-#       http://www.apache.org/licenses/LICENSE-2.0
-# 
-#   Unless required by applicable law or agreed to in writing, software
-#   distributed under the License is distributed on an "AS IS" BASIS,
-#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-#   See the License for the specific language governing permissions and
-#   limitations under the License.
-# 
+#     https://www.apache.org/licenses/LICENSE-2.0
 #
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
 
 # Args: DIR command
 cd "$1"
diff --git a/tools/bin/antRun.bat b/tools/bin/antRun.bat
old mode 100755
new mode 100644
index 289e19b30..e6516e073
--- a/tools/bin/antRun.bat
+++ b/tools/bin/antRun.bat
@@ -1,47 +1,49 @@
-@echo off
-
-REM
-REM Copyright  2001-2002,2004-2005 The Apache Software Foundation
-REM
-REM  Licensed under the Apache License, Version 2.0 (the "License");
-REM  you may not use this file except in compliance with the License.
-REM  You may obtain a copy of the License at
-REM
-REM      http://www.apache.org/licenses/LICENSE-2.0
-REM
-REM  Unless required by applicable law or agreed to in writing, software
-REM  distributed under the License is distributed on an "AS IS" BASIS,
-REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-REM  See the License for the specific language governing permissions and
-REM  limitations under the License.
-REM
-REM
-
-if "%OS%"=="Windows_NT" @setlocal
-if "%OS%"=="WINNT" @setlocal
-
-if ""%1""=="""" goto runCommand
-
-rem Change drive and directory to %1
-if "%OS%"=="Windows_NT" cd /d ""%1""
-if not "%OS%"=="Windows_NT" cd ""%1""
-shift
-
-rem Slurp the command line arguments. This loop allows for an unlimited number
-rem of agruments (up to the command line limit, anyway).
-set ANT_RUN_CMD=%1
-if ""%1""=="""" goto runCommand
-shift
-:loop
-if ""%1""=="""" goto runCommand
-set ANT_RUN_CMD=%ANT_RUN_CMD% %1
-shift
-goto loop
-
-:runCommand
-rem echo %ANT_RUN_CMD%
-%ANT_RUN_CMD%
-
-if "%OS%"=="Windows_NT" @endlocal
-if "%OS%"=="WINNT" @endlocal
-
+@echo off
+
+REM  Licensed to the Apache Software Foundation (ASF) under one or more
+REM  contributor license agreements.  See the NOTICE file distributed with
+REM  this work for additional information regarding copyright ownership.
+REM  The ASF licenses this file to You under the Apache License, Version 2.0
+REM  (the "License"); you may not use this file except in compliance with
+REM  the License.  You may obtain a copy of the License at
+REM
+REM      https://www.apache.org/licenses/LICENSE-2.0
+REM
+REM  Unless required by applicable law or agreed to in writing, software
+REM  distributed under the License is distributed on an "AS IS" BASIS,
+REM  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+REM  See the License for the specific language governing permissions and
+REM  limitations under the License.
+
+if "%OS%"=="Windows_NT" @setlocal
+if "%OS%"=="WINNT" @setlocal
+
+if ""%1""=="""" goto runCommand
+
+rem Change drive and directory to %1
+if "%OS%"=="Windows_NT" goto nt_cd
+if "%OS%"=="WINNT" goto nt_cd
+cd ""%1""
+goto end_cd
+:nt_cd
+cd /d ""%1""
+:end_cd
+shift
+
+rem Slurp the command line arguments. This loop allows for an unlimited number
+rem of arguments (up to the command line limit, anyway).
+set ANT_RUN_CMD=%1
+if ""%1""=="""" goto runCommand
+shift
+:loop
+if ""%1""=="""" goto runCommand
+set ANT_RUN_CMD=%ANT_RUN_CMD% %1
+shift
+goto loop
+
+:runCommand
+rem echo %ANT_RUN_CMD%
+%ANT_RUN_CMD%
+
+if "%OS%"=="Windows_NT" @endlocal
+if "%OS%"=="WINNT" @endlocal


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to