Return-Path: Delivered-To: apmail-ant-dev-archive@ant.apache.org Received: (qmail 60242 invoked by uid 500); 22 Aug 2003 14:15:48 -0000 Mailing-List: contact dev-help@ant.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Ant Developers List" Reply-To: "Ant Developers List" Delivered-To: mailing list dev@ant.apache.org Received: (qmail 60227 invoked by uid 500); 22 Aug 2003 14:15:47 -0000 Received: (qmail 60220 invoked from network); 22 Aug 2003 14:15:47 -0000 Received: from minotaur.apache.org (209.237.227.194) by daedalus.apache.org with SMTP; 22 Aug 2003 14:15:47 -0000 Received: (qmail 559 invoked by uid 1652); 22 Aug 2003 14:08:24 -0000 Date: 22 Aug 2003 14:08:24 -0000 Message-ID: <20030822140824.558.qmail@minotaur.apache.org> From: antoine@apache.org To: ant-cvs@apache.org Subject: cvs commit: ant/src/script runant.py X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N antoine 2003/08/22 07:08:24 Modified: src/script runant.py Log: make the script to start ant from python use the new launcher Submitted by: Knut Wannheden (knut dot wannheden at paranor dot ch) Revision Changes Path 1.3 +31 -51 ant/src/script/runant.py Index: runant.py =================================================================== RCS file: /home/cvs/ant/src/script/runant.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- runant.py 10 Jan 2002 14:18:42 -0000 1.2 +++ runant.py 22 Aug 2003 14:08:24 -0000 1.3 @@ -3,10 +3,10 @@ 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 + 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. @@ -28,72 +28,52 @@ # # 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) +if os.environ.has_key('ANT_HOME'): + ANT_HOME = os.environ['ANT_HOME'] else: - ANT_HOME = os.environ['ANT_HOME'] + ANT_HOME = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0]))) + +# Add jar files +ANT_LIB = os.path.join(ANT_HOME, 'lib') if not os.environ.has_key('JAVACMD'): - JAVACMD = 'java' + JAVACMD = 'java' else: - JAVACMD = os.environ['JAVACMD'] - -# Sets the separator char for CLASSPATH -SEPARATOR = ':' -if os.name == 'dos' or os.name == 'nt': - SEPARATOR = ';' + JAVACMD = os.environ['JAVACMD'] # Build up standard classpath localpath = '' if os.environ.has_key('CLASSPATH'): - localpath = os.environ['CLASSPATH'] + localpath = os.environ['CLASSPATH'] else: - if debug: - print 'Warning: no initial classpath\n' + 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 +launcher_jar = os.path.join(ANT_LIB, 'ant-launcher.jar') +if not os.path.exists(launcher_jar): + print 'Unable to locate ant-launcher.jar. Expected to find it in %s' % \ + ANT_LIB +if localpath: + localpath = launcher_jar + os.pathsep + localpath 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' + localpath = launcher_jar -# Jikes ANT_OPTS = [] if os.environ.has_key('ANT_OPTS'): - ANT_OPTS = string.split(os.environ['ANT_OPTS']) + ANT_OPTS = string.split(os.environ['ANT_OPTS']) + +OPTS = [] if os.environ.has_key('JIKESPATH'): - ANT_OPTS.append('-Djikes.class.path=' + os.environ['JIKESPATH']) + 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:], ' ')) +cmdline = ('%s %s -classpath %s -Dant.home=\"%s\" %s ' + \ + 'org.apache.tools.ant.launch.Launcher %s') \ + % (JAVACMD, string.join(ANT_OPTS,' '), localpath, ANT_HOME, \ + string.join(OPTS,' '), string.join(sys.argv[1:], ' ')) if debug: - print '\n%s\n\n' % (cmdline) + print '\n%s\n\n' % (cmdline) # Run the biniou! os.system(cmdline) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org For additional commands, e-mail: dev-help@ant.apache.org