You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2002/07/12 11:36:54 UTC
cvs commit: xml-cocoon2/tools/lib ant-1.5-optional.jar ant-1.5.jar ant-1.4.1-optional.jar ant-1.4.1.jar
cziegeler 2002/07/12 02:36:54
Modified: tools/bin ant ant.bat antRun antRun.bat lcp.bat runant.pl
Added: tools/bin antRun.pl complete-ant-cmd.pl runant.py
tools/lib ant-1.5-optional.jar ant-1.5.jar
Removed: tools/bin fix-packages.py
tools/lib ant-1.4.1-optional.jar ant-1.4.1.jar
Log:
Updated to latest ant
Revision Changes Path
1.2 +121 -41 xml-cocoon2/tools/bin/ant
Index: ant
===================================================================
RCS file: /home/cvs/xml-cocoon2/tools/bin/ant,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ant 11 Jan 2002 09:35:27 -0000 1.1
+++ ant 12 Jul 2002 09:36:51 -0000 1.2
@@ -1,26 +1,39 @@
#! /bin/sh
+# Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+# reserved.
+
+# load system-wide ant configuration
+if [ -f "/etc/ant.conf" ] ; then
+ . /etc/ant.conf
+fi
+
+# provide default values for people who don't use RPMs
+if [ -z "$rpm_mode" ] ; then
+ rpm_mode=false;
+fi
+if [ -z "$usejikes" ] ; then
+ usejikes=false;
+fi
+
+# load user ant configuration
if [ -f "$HOME/.antrc" ] ; then
. $HOME/.antrc
fi
-# Cygwin support. $cygwin _must_ be set to either true or false.
+# OS specific support. $var _must_ be set to either true or false.
+cygwin=false;
+darwin=false;
case "`uname`" in
CYGWIN*) cygwin=true ;;
- *) cygwin=false ;;
+ Darwin*) darwin=true
+ if [ -z "$JAVA_HOME" ] ; then
+ JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
+ fi
+ ;;
esac
-# 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"`
- [ -n "$CLASSPATH" ] &&
- CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
-fi
-
-if [ "$ANT_HOME" = "" ] ; then
+if [ -z "$ANT_HOME" ] ; then
# try to find ANT
if [ -d /opt/ant ] ; then
ANT_HOME=/opt/ant
@@ -33,6 +46,10 @@
## resolve links - $0 may be a link to ant's home
PRG=$0
progname=`basename $0`
+ saveddir=`pwd`
+
+ # need this for relative symlinks
+ cd `dirname $PRG`
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
@@ -46,40 +63,97 @@
ANT_HOME=`dirname "$PRG"`/..
+ # make it fully qualified
+ ANT_HOME=`cd "$ANT_HOME" && pwd`
+
+ cd $saveddir
fi
-if [ "$JAVA_HOME" != "" ] ; then
- if [ "$JAVACMD" = "" ] ; then
- JAVACMD=$JAVA_HOME/bin/java
- fi
-else
- if [ "$JAVACMD" = "" ] ; then
+# set ANT_LIB location
+ANT_LIB=${ANT_HOME}/lib
+
+# 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"`
+ [ -n "$CLASSPATH" ] &&
+ CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
+fi
+
+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
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ else
JAVACMD=java
fi
fi
-# add in the dependency .jar files
-DIRLIBS=${ANT_HOME}/lib/*.jar
-for i in ${DIRLIBS}
-do
- # if the directory is empty, then it will return the input string
- # this is stupid, so case for it
- if [ "$i" != "${DIRLIBS}" ] ; then
- LOCALCLASSPATH=$LOCALCLASSPATH:"$i"
+if [ ! -x "$JAVACMD" ] ; then
+ echo "Error: JAVA_HOME is not defined correctly."
+ echo " We cannot execute $JAVACMD"
+ exit 1
+fi
+
+if [ -n "$CLASSPATH" ] ; then
+ LOCALCLASSPATH="$CLASSPATH"
+fi
+
+# in rpm_mode get ant/optional/xml parser&api from JAVALIBDIR
+if $rpm_mode; then
+ JAVALIBDIR=/usr/share/java
+ for i in ant ant-optional jaxp_parser xml_apis
+ do
+ if [ -z "$LOCALCLASSPATH" ] ; then
+ LOCALCLASSPATH=$JAVALIBDIR/$i.jar
+ else
+ LOCALCLASSPATH="$JAVALIBDIR/$i.jar":"$LOCALCLASSPATH"
fi
-done
+ done
+
+# in rpm mode ant/lib is in /usr/share/java/ant
+ANT_LIB=${JAVALIBDIR}/ant
-if [ "$CLASSPATH" != "" ] ; then
- LOCALCLASSPATH=$CLASSPATH:$LOCALCLASSPATH
fi
-if [ "$JAVA_HOME" != "" ] ; then
- if test -f $JAVA_HOME/lib/tools.jar ; then
- LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar
+# add in the dependency .jar files in non-RPM mode (the default)
+for i in "${ANT_LIB}"/*.jar
+do
+ # if the directory is empty, then it will return the input string
+ # this is stupid, so case for it
+ if [ "$i" != "${ANT_LIB}/*.jar" ] ; then
+ if [ -z "$LOCALCLASSPATH" ] ; then
+ LOCALCLASSPATH=$i
+ else
+ LOCALCLASSPATH="$i":"$LOCALCLASSPATH"
+ fi
fi
+done
- if test -f $JAVA_HOME/lib/classes.zip ; then
- LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip
+if [ -n "$JAVA_HOME" ] ; 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
+ LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
+ fi
+
+ # OSX hack to make Ant work with jikes
+ if $darwin ; then
+ OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes"
+ if [ -d ${OSXHACK} ] ; then
+ for i in ${OSXHACK}/*.jar
+ do
+ JIKESPATH=$JIKESPATH:$i
+ done
+ fi
fi
else
echo "Warning: JAVA_HOME environment variable is not set."
@@ -89,19 +163,25 @@
fi
# supply JIKESPATH to Ant as jikes.class.path
-if [ "$JIKESPATH" != "" ] ; then
- if [ "$ANT_OPTS" != "" ] ; then
- ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH"
- else
- ANT_OPTS=-Djikes.class.path=$JIKESPATH
+if [ -n "$JIKESPATH" ] ; then
+ if $cygwin ; then
+ JIKESPATH=`cygpath --path --windows "$JIKESPATH"`
fi
+ ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH"
+fi
+
+# Allow Jikes support (off by default)
+if $usejikes; then
+ ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
ANT_HOME=`cygpath --path --windows "$ANT_HOME"`
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
+ CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"`
+ ANT_OPTS="$ANT_OPTS -Dcygwin.user.home="`cygpath --path --windows "$HOME"`
fi
-$JAVACMD -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main "$@"
+"$JAVACMD" -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main $ANT_ARGS "$@"
1.2 +27 -10 xml-cocoon2/tools/bin/ant.bat
Index: ant.bat
===================================================================
RCS file: /home/cvs/xml-cocoon2/tools/bin/ant.bat,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- ant.bat 11 Jan 2002 09:35:27 -0000 1.1
+++ ant.bat 12 Jul 2002 09:36:51 -0000 1.2
@@ -1,5 +1,8 @@
@echo off
-
+
+REM Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+REM reserved.
+
if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat"
if not "%OS%"=="Windows_NT" goto win9xStart
@@ -10,15 +13,22 @@
set DEFAULT_ANT_HOME=%~dp0
rem : operator works similar to make : operator
-set DEFAULT_ANT_HOME=%DEFAULT_ANT_HOME:\bin\=%
+set DEFAULT_ANT_HOME=%DEFAULT_ANT_HOME%\..
-if %ANT_HOME%a==a set ANT_HOME=%DEFAULT_ANT_HOME%
+if "%ANT_HOME%"=="" set ANT_HOME=%DEFAULT_ANT_HOME%
set DEFAULT_ANT_HOME=
+rem Need to check if we are using the 4NT shell...
+if "%@eval[2+2]" == "4" goto setup4NT
+
rem On NT/2K grab all arguments at once
set ANT_CMD_LINE_ARGS=%*
goto doneStart
+:setup4NT
+set ANT_CMD_LINE_ARGS=%$
+goto doneStart
+
:win9xStart
rem Slurp the command line arguments. This loop allows for an unlimited number of
rem agruments (up to the command line limit, anyway).
@@ -45,23 +55,30 @@
:checkSystemDrive
rem check for ant in root directory of system drive
-if not exist "%SystemDrive%\ant" goto noAntHome
+if not exist %SystemDrive%\ant\nul 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\nul goto noAntHome
+set ANT_HOME=C:\ant
+goto checkJava
+
:noAntHome
echo ANT_HOME is not set and ant could not be located. Please set ANT_HOME.
goto end
:checkJava
set _JAVACMD=%JAVACMD%
-set LOCALCLASSPATH="%CLASSPATH%"
-for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" "%%i"
+set LOCALCLASSPATH=%CLASSPATH%
+for %%i in ("%ANT_HOME%\lib\*.jar") do call "%ANT_HOME%\bin\lcp.bat" %%i
if "%JAVA_HOME%" == "" goto noJavaHome
if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java
-if exist "%JAVA_HOME%\lib\tools.jar" call "%ANT_HOME%\bin\lcp.bat" "%JAVA_HOME%\lib\tools.jar"
-if exist "%JAVA_HOME%\lib\classes.zip" call "%ANT_HOME%\bin\lcp.bat" "%JAVA_HOME%\lib\classes.zip"
+if not exist "%_JAVACMD%.exe" echo Error: "%_JAVACMD%.exe" not found - check JAVA_HOME && goto end
+if exist "%JAVA_HOME%\lib\tools.jar" call "%ANT_HOME%\bin\lcp.bat" %JAVA_HOME%\lib\tools.jar
+if exist "%JAVA_HOME%\lib\classes.zip" call "%ANT_HOME%\bin\lcp.bat" %JAVA_HOME%\lib\classes.zip
goto checkJikes
:noJavaHome
@@ -77,11 +94,11 @@
if not "%JIKESPATH%" == "" goto runAntWithJikes
:runAnt
-%_JAVACMD% -classpath %LOCALCLASSPATH% -Dant.home="%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%
+"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" -Dant.home="%ANT_HOME%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_ARGS% %ANT_CMD_LINE_ARGS%
goto end
:runAntWithJikes
-%_JAVACMD% -classpath %LOCALCLASSPATH% -Dant.home="%ANT_HOME%" -Djikes.class.path=%JIKESPATH% %ANT_OPTS% org.apache.tools.ant.Main %ANT_CMD_LINE_ARGS%
+"%_JAVACMD%" -classpath "%LOCALCLASSPATH%" -Dant.home="%ANT_HOME%" -Djikes.class.path="%JIKESPATH%" %ANT_OPTS% org.apache.tools.ant.Main %ANT_ARGS% %ANT_CMD_LINE_ARGS%
:end
set LOCALCLASSPATH=
1.2 +3 -0 xml-cocoon2/tools/bin/antRun
Index: antRun
===================================================================
RCS file: /home/cvs/xml-cocoon2/tools/bin/antRun,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- antRun 11 Jan 2002 09:35:27 -0000 1.1
+++ antRun 12 Jul 2002 09:36:51 -0000 1.2
@@ -1,5 +1,8 @@
#! /bin/sh
+# Copyright (c) 2001 The Apache Software Foundation. All rights
+# reserved.
+
# Args: DIR command
cd "$1"
CMD="$2"
1.2 +5 -2 xml-cocoon2/tools/bin/antRun.bat
Index: antRun.bat
===================================================================
RCS file: /home/cvs/xml-cocoon2/tools/bin/antRun.bat,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- antRun.bat 11 Jan 2002 09:35:27 -0000 1.1
+++ antRun.bat 12 Jul 2002 09:36:51 -0000 1.2
@@ -1,6 +1,9 @@
@echo off
-
-# Change drive and directory to %1 (Win9X only for NT/2K use "cd /d")
+
+REM Copyright (c) 2001 The Apache Software Foundation. All rights
+REM reserved.
+
+rem Change drive and directory to %1 (Win9X only for NT/2K use "cd /d")
cd %1
%1\
set ANT_RUN_CMD=%2
1.2 +12 -2 xml-cocoon2/tools/bin/lcp.bat
Index: lcp.bat
===================================================================
RCS file: /home/cvs/xml-cocoon2/tools/bin/lcp.bat,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- lcp.bat 11 Jan 2002 09:35:27 -0000 1.1
+++ lcp.bat 12 Jul 2002 09:36:52 -0000 1.2
@@ -1,2 +1,12 @@
-set LOCALCLASSPATH=%1;%LOCALCLASSPATH%
-
+REM Copyright (c) 2001 The Apache Software Foundation. All rights
+REM reserved.
+
+set _CLASSPATHCOMPONENT=%1
+:argCheck
+if %2a==a goto gotAllArgs
+shift
+set _CLASSPATHCOMPONENT=%_CLASSPATHCOMPONENT% %1
+goto argCheck
+:gotAllArgs
+set LOCALCLASSPATH=%_CLASSPATHCOMPONENT%;%LOCALCLASSPATH%
+
1.2 +37 -6 xml-cocoon2/tools/bin/runant.pl
Index: runant.pl
===================================================================
RCS file: /home/cvs/xml-cocoon2/tools/bin/runant.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- runant.pl 11 Jan 2002 09:35:27 -0000 1.1
+++ runant.pl 12 Jul 2002 09:36:52 -0000 1.2
@@ -1,4 +1,8 @@
#!/usr/bin/perl
+#
+# Copyright (c) 2001-2002 The Apache Software Foundation. All rights
+# reserved.
+#
#######################################################################
#
# runant.pl
@@ -51,11 +55,18 @@
my $JAVACMD = $ENV{JAVACMD};
$JAVACMD = "java" if $JAVACMD eq "";
+my $onnetware = 0;
+if ($^O eq "NetWare")
+{
+ $onnetware = 1;
+}
+
#ISSUE: what java wants to split up classpath varies from platform to platform
#and perl is not too hot at hinting which box it is on.
-#here I assume ":" 'cept on win32 and dos. Add extra tests here as needed.
+#here I assume ":" 'cept on win32, dos, and netware. Add extra tests here as needed.
my $s=":";
-if(($^O eq "MSWin32") || ($^O eq "dos"))
+if(($^O eq "MSWin32") || ($^O eq "dos") || ($^O eq "cygwin") ||
+ ($onnetware == 1))
{
$s=";";
}
@@ -67,6 +78,13 @@
print "warning: no initial classpath\n" if ($debug);
$localpath="";
}
+if ($onnetware == 1)
+{
+# avoid building a command line bigger than 512 characters - make localpath
+# only include the "extra" stuff, and add in the system classpath as an expanded
+# variable.
+ $localpath="";
+}
#add jar files. I am sure there is a perl one liner to do this.
my $jarpattern="$HOME/lib/*.jar";
@@ -101,19 +119,32 @@
"to the installation directory of java\n";
}
+#set JVM options and Ant arguments, if any
+my @ANT_OPTS=split(" ", $ENV{ANT_OPTS});
+my @ANT_ARGS=split(" ", $ENV{ANT_ARGS});
+
#jikes
-my @ANT_OPTS=split $ENV{ANT_OPTS};
if($ENV{JIKESPATH} ne "")
{
push @ANT_OPTS, "-Djikes.class.path=$ENV{JIKESPATH}";
}
#construct arguments to java
-
my @ARGS;
-push @ARGS, "-classpath", "$localpath", "-Dant.home=$HOME";
+if ($onnetware == 1)
+{
+# make classpath literally $CLASSPATH; and then the contents of $localpath
+# this is to avoid pushing us over the 512 character limit
+# even skip the ; - that is already in $localpath
+ push @ARGS, "-classpath", "\$CLASSPATH$localpath";
+}
+else
+{
+ push @ARGS, "-classpath", "$localpath";
+}
+push @ARGS, "-Dant.home=$HOME";
push @ARGS, @ANT_OPTS;
-push @ARGS, "org.apache.tools.ant.Main";
+push @ARGS, "org.apache.tools.ant.Main", @ANT_ARGS;
push @ARGS, @ARGV;
print "\n $JAVACMD @ARGS\n\n" if ($debug);
1.1 xml-cocoon2/tools/bin/antRun.pl
Index: antRun.pl
===================================================================
#!/usr/bin/perl
#######################################################################
#
# antRun.pl
#
# wrapper script for invoking commands on a platform with Perl installed
# this is akin to antRun.bat, and antRun the SH script
#
# created: 2001-10-18
# last modified: 2001-11-13
# author: Jeff Tulley jtulley@novell.com
#######################################################################
#be fussy about variables
use strict;
#turn warnings on during dev; generates a few spurious uninitialised var access warnings
#use warnings;
#and set $debug to 1 to turn on trace info (currently unused)
my $debug=1;
#######################################################################
# change drive and directory to "%1"
my $ANT_RUN_CMD = @ARGV[0];
# assign current run command to "%2"
chdir (@ARGV[0]) || die "Can't cd to $ARGV[0]: $!\n";
if ($^O eq "NetWare") {
# There is a bug in Perl 5 on NetWare, where chdir does not
# do anything. On NetWare, the following path-prefixed form should
# always work. (afaict)
$ANT_RUN_CMD .= "/".@ARGV[1];
}
else {
$ANT_RUN_CMD = @ARGV[1];
}
# dispose of the first two arguments, leaving only the command's args.
shift;
shift;
# run the command
my $returnValue = system $ANT_RUN_CMD, @ARGV;
if ($returnValue eq 0) {
exit 0;
}
else {
# only 0 and 1 are widely recognized as exit values
# so change the exit value to 1
exit 1;
}
1.1 xml-cocoon2/tools/bin/complete-ant-cmd.pl
Index: complete-ant-cmd.pl
===================================================================
#!/usr/bin/perl
#
# Copyright (c) 2001 The Apache Software Foundation. All rights
# reserved.
#
# A script to allow Bash or Z-Shell to complete an Ant command-line.
#
# To install for Bash 2.0 or better, add the following to ~/.bashrc:
#
# $ complete -C complete-ant-cmd ant build.sh
#
# To install for Z-Shell 2.5 or better, add the following to ~/.zshrc:
#
# function ant_complete () {
# local args_line args
# read -l args_line
# set -A args $args_line
# set -A reply $(COMP_LINE=$args_line complete-ant-cmd ${args[1]} $1)
# }
# compctl -K ant_complete ant build.sh
#
# @author Mike Williams <mi...@cortexebusiness.com.au>
my $cmdLine = $ENV{'COMP_LINE'};
my $antCmd = $ARGV[0];
my $word = $ARGV[1];
my @completions;
if ($word =~ /^-/) {
list( restrict( $word, getArguments() ));
} elsif ($cmdLine =~ /-(f|buildfile)\s+\S*$/) {
list( getBuildFiles($word) );
} else {
list( restrict( $word, getTargets() ));
}
exit(0);
sub list {
for (@_) {
print "$_\n";
}
}
sub restrict {
my ($word, @completions) = @_;
grep( /^\Q$word\E/, @completions );
}
sub getArguments {
qw(-buildfile -debug -emacs -f -find -help -listener -logfile
-logger -projecthelp -quiet -verbose -version);
}
sub getBuildFiles {
my ($word) = @_;
grep( /\.xml$/, glob( "$word*" ));
}
sub getTargets {
# Look for build-file
my $buildFile = 'build.xml';
if ($cmdLine =~ /-(f|buildfile)\s+(\S+)/) {
$buildFile = $2;
}
return () unless (-f $buildFile);
# Run "ant -projecthelp" to list targets. Keep a cache of results in a
# cache-file.
my $cacheFile = $buildFile;
$cacheFile =~ s|(.*/)?(.*)|${1}.ant-targets-${2}|;
if ((!-e $cacheFile) || (-M $buildFile) < (-M $cacheFile)) {
open( CACHE, '>'.$cacheFile ) || die "can\'t write $cacheFile: $!\n";
open( HELP, "$antCmd -projecthelp -f '$buildFile'|" ) || return();
my %targets;
while( <HELP> ) {
if (/^\s+(\S+)/) {
$targets{$1}++;
}
}
my @targets = sort keys %targets;
for (@targets) { print CACHE "$_\n"; }
return @targets;
}
# Read the target-cache
open( CACHE, $cacheFile ) || die "can\'t read $cacheFile: $!\n";
my @targets;
while (<CACHE>) {
chop;
s/\r$//; # for Cygwin
push( @targets, $_ );
}
close( CACHE );
@targets;
}
1.1 xml-cocoon2/tools/bin/runant.py
Index: runant.py
===================================================================
#!/usr/bin/python
"""
runant.py
This script is a translation of the runant.pl written by Steve Loughran.
It runs ant with/out arguments, it should be quite portable (thanks to
the python os library)
This script has been tested with Python2.0/Win2K
Copyright (c) 2001 The Apache Software Foundation. All rights
reserved.
created: 2001-04-11
author: Pierre Dittgen pierre.dittgen@criltelecom.com
Assumptions:
- the "java" executable/script is on the command path
- ANT_HOME has been set
"""
import os, os.path, string, sys
# Change it to 1 to get extra debug information
debug = 0
#######################################################################
#
# check to make sure environment is setup
#
if not os.environ.has_key('ANT_HOME'):
print '\n\nANT_HOME *MUST* be set!\n\n'
sys.exit(1)
else:
ANT_HOME = os.environ['ANT_HOME']
if not os.environ.has_key('JAVACMD'):
JAVACMD = 'java'
else:
JAVACMD = os.environ['JAVACMD']
# Sets the separator char for CLASSPATH
SEPARATOR = ':'
if os.name == 'dos' or os.name == 'nt':
SEPARATOR = ';'
# Build up standard classpath
localpath = ''
if os.environ.has_key('CLASSPATH'):
localpath = os.environ['CLASSPATH']
else:
if debug:
print 'Warning: no initial classpath\n'
# Add jar files
LIBDIR = os.path.join(ANT_HOME, 'lib')
jarfiles = []
for file in os.listdir(LIBDIR):
if file[-4:] == '.jar':
jarfiles.append(os.path.join(LIBDIR,file))
if debug:
print 'Jar files:'
for jar in jarfiles:
print jar
localpath = localpath + SEPARATOR + string.join(jarfiles, SEPARATOR)
# If JAVA_HOME is defined, look for tools.jar & classes.zip
# and add to classpath
if os.environ.has_key('JAVA_HOME') and os.environ['JAVA_HOME'] != '':
JAVA_HOME = os.environ['JAVA_HOME']
TOOLS = os.path.join(JAVA_HOME, os.path.join('lib', 'tools.jar'))
if os.path.exists(TOOLS):
localpath = localpath + SEPARATOR + TOOLS
CLASSES = os.path.join(JAVA_HOME, os.path.join('lib', 'classes.zip'))
if os.path.exists(CLASSES):
localpath = localpath + SEPARATOR + CLASSES
else:
print '\n\nWarning: JAVA_HOME environment variable is not set.\n', \
'If the build fails because sun.* classes could not be found\n', \
'you will need to set the JAVA_HOME environment variable\n', \
'to the installation directory of java\n'
# Jikes
ANT_OPTS = []
if os.environ.has_key('ANT_OPTS'):
ANT_OPTS = string.split(os.environ['ANT_OPTS'])
if os.environ.has_key('JIKESPATH'):
ANT_OPTS.append('-Djikes.class.path=' + os.environ['JIKESPATH'])
# Builds the commandline
cmdline = '%s -classpath %s -Dant.home=%s %s org.apache.tools.ant.Main %s' \
% (JAVACMD, localpath, ANT_HOME, string.join(ANT_OPTS,' '), \
string.join(sys.argv[1:], ' '))
if debug:
print '\n%s\n\n' % (cmdline)
# Run the biniou!
os.system(cmdline)
1.1 xml-cocoon2/tools/lib/ant-1.5-optional.jar
<<Binary file>>
1.1 xml-cocoon2/tools/lib/ant-1.5.jar
<<Binary file>>
----------------------------------------------------------------------
In case of troubles, e-mail: webmaster@xml.apache.org
To unsubscribe, e-mail: cocoon-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: cocoon-cvs-help@xml.apache.org