1 |
d2a8c3fd
|
Marc NICOLAS
|
|
2 |
|
|
|
3 |
|
|
|
4 |
|
|
|
5 |
|
|
|
6 |
|
|
|
7 |
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
|
|
|
14 |
|
|
|
15 |
|
|
|
16 |
|
|
|
17 |
|
|
|
18 |
|
|
"""
|
19 |
|
|
|
20 |
|
|
runant.py
|
21 |
|
|
|
22 |
|
|
This script is a translation of the runant.pl written by Steve Loughran.
|
23 |
|
|
It runs ant with/out arguments, it should be quite portable (thanks to
|
24 |
|
|
the python os library)
|
25 |
|
|
This script has been tested with Python2.0/Win2K
|
26 |
|
|
|
27 |
|
|
created: 2001-04-11
|
28 |
|
|
author: Pierre Dittgen pierre.dittgen@criltelecom.com
|
29 |
|
|
|
30 |
|
|
Assumptions:
|
31 |
|
|
|
32 |
|
|
- the "java" executable/script is on the command path
|
33 |
|
|
"""
|
34 |
|
|
import os, os.path, string, sys
|
35 |
|
|
|
36 |
|
|
|
37 |
|
|
debug = 0
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
|
41 |
|
|
|
42 |
|
|
if os.environ.has_key('ANT_HOME'):
|
43 |
|
|
ANT_HOME = os.environ['ANT_HOME']
|
44 |
|
|
else:
|
45 |
|
|
ANT_HOME = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
ANT_LIB = os.path.join(ANT_HOME, 'lib')
|
49 |
|
|
|
50 |
|
|
|
51 |
|
|
JAVACMD = None
|
52 |
|
|
if not os.environ.has_key('JAVACMD'):
|
53 |
|
|
if os.environ.has_key('JAVA_HOME'):
|
54 |
|
|
if not os.path.exists(os.environ['JAVA_HOME']):
|
55 |
|
|
print "Warning: JAVA_HOME is not defined correctly."
|
56 |
|
|
else:
|
57 |
|
|
JAVACMD = os.path.join(os.environ['JAVA_HOME'], 'bin', 'java')
|
58 |
|
|
else:
|
59 |
|
|
print "Warning: JAVA_HOME not set."
|
60 |
|
|
else:
|
61 |
|
|
JAVACMD = os.environ['JAVACMD']
|
62 |
|
|
if not JAVACMD:
|
63 |
|
|
JAVACMD = 'java'
|
64 |
|
|
|
65 |
|
|
launcher_jar = os.path.join(ANT_LIB, 'ant-launcher.jar')
|
66 |
|
|
if not os.path.exists(launcher_jar):
|
67 |
|
|
print 'Warning: Unable to locate ant-launcher.jar. Expected to find it in %s' % \
|
68 |
|
|
ANT_LIB
|
69 |
|
|
|
70 |
|
|
|
71 |
|
|
LOCALCLASSPATH = launcher_jar
|
72 |
|
|
if os.environ.has_key('LOCALCLASSPATH'):
|
73 |
|
|
LOCALCLASSPATH += os.pathsep + os.environ['LOCALCLASSPATH']
|
74 |
|
|
|
75 |
|
|
ANT_OPTS = ""
|
76 |
|
|
if os.environ.has_key('ANT_OPTS'):
|
77 |
|
|
ANT_OPTS = os.environ['ANT_OPTS']
|
78 |
|
|
|
79 |
|
|
OPTS = ""
|
80 |
|
|
if os.environ.has_key('JIKESPATH'):
|
81 |
|
|
OPTS = '-Djikes.class.path=\"%s\"' % os.environ['JIKESPATH']
|
82 |
|
|
|
83 |
|
|
ANT_ARGS = ""
|
84 |
|
|
if os.environ.has_key('ANT_ARGS'):
|
85 |
|
|
ANT_ARGS = os.environ['ANT_ARGS']
|
86 |
|
|
|
87 |
|
|
CLASSPATH = ""
|
88 |
|
|
if os.environ.has_key('CLASSPATH'):
|
89 |
|
|
CLASSPATH = os.environ['CLASSPATH']
|
90 |
|
|
|
91 |
|
|
|
92 |
|
|
cmdline = ('%s %s -classpath %s -Dant.home=%s %s ' + \
|
93 |
|
|
'org.apache.tools.ant.launch.Launcher %s -lib %s %s') \
|
94 |
|
|
% (JAVACMD, ANT_OPTS, LOCALCLASSPATH, ANT_HOME, OPTS, ANT_ARGS, \
|
95 |
|
|
CLASSPATH, string.join(sys.argv[1:], ' '))
|
96 |
|
|
|
97 |
|
|
if debug:
|
98 |
|
|
print '\n%s\n\n' % (cmdline)
|
99 |
|
|
sys.stdout.flush()
|
100 |
|
|
|
101 |
|
|
|
102 |
|
|
os.system(cmdline) |