GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / ant / bin / runant.py
blobc7b53b692af205b18bc99244e8c15ab0b4c1f042
1 #!/usr/bin/python
2 # Copyright 2001,2003-2004 The Apache Software Foundation
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
17 """
19 runant.py
21 This script is a translation of the runant.pl written by Steve Loughran.
22 It runs ant with/out arguments, it should be quite portable (thanks to
23 the python os library)
24 This script has been tested with Python2.0/Win2K
26 created: 2001-04-11
27 author: Pierre Dittgen pierre.dittgen@criltelecom.com
29 Assumptions:
31 - the "java" executable/script is on the command path
32 """
33 import os, os.path, string, sys
35 # Change it to 1 to get extra debug information
36 debug = 0
38 #######################################################################
40 # If ANT_HOME is not set default to script's parent directory
41 if os.environ.has_key('ANT_HOME'):
42 ANT_HOME = os.environ['ANT_HOME']
43 else:
44 ANT_HOME = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
46 # set ANT_LIB location
47 ANT_LIB = os.path.join(ANT_HOME, 'lib')
49 # set JAVACMD (check variables JAVACMD and JAVA_HOME)
50 JAVACMD = None
51 if not os.environ.has_key('JAVACMD'):
52 if os.environ.has_key('JAVA_HOME'):
53 if not os.path.exists(os.environ['JAVA_HOME']):
54 print "Warning: JAVA_HOME is not defined correctly."
55 else:
56 JAVACMD = os.path.join(os.environ['JAVA_HOME'], 'bin', 'java')
57 else:
58 print "Warning: JAVA_HOME not set."
59 else:
60 JAVACMD = os.environ['JAVACMD']
61 if not JAVACMD:
62 JAVACMD = 'java'
64 launcher_jar = os.path.join(ANT_LIB, 'ant-launcher.jar')
65 if not os.path.exists(launcher_jar):
66 print 'Unable to locate ant-launcher.jar. Expected to find it in %s' % \
67 ANT_LIB
69 # Build up standard classpath (LOCALCLASSPATH)
70 LOCALCLASSPATH = launcher_jar
71 if os.environ.has_key('LOCALCLASSPATH'):
72 LOCALCLASSPATH += os.pathsep + os.environ['LOCALCLASSPATH']
74 ANT_OPTS = ""
75 if os.environ.has_key('ANT_OPTS'):
76 ANT_OPTS = os.environ['ANT_OPTS']
78 OPTS = ""
79 if os.environ.has_key('JIKESPATH'):
80 OPTS = '-Djikes.class.path=\"%s\"' % os.environ['JIKESPATH']
82 ANT_ARGS = ""
83 if os.environ.has_key('ANT_ARGS'):
84 ANT_ARGS = os.environ['ANT_ARGS']
86 CLASSPATH = ""
87 if os.environ.has_key('CLASSPATH'):
88 CLASSPATH = os.environ['CLASSPATH']
90 # Builds the commandline
91 cmdline = ('%s %s -classpath %s -Dant.home=%s %s ' + \
92 'org.apache.tools.ant.launch.Launcher %s -lib %s %s') \
93 % (JAVACMD, ANT_OPTS, LOCALCLASSPATH, ANT_HOME, OPTS, ANT_ARGS, \
94 CLASSPATH, string.join(sys.argv[1:], ' '))
96 if debug:
97 print '\n%s\n\n' % (cmdline)
99 # Run the biniou!
100 os.system(cmdline)