source: release-kits/lirk3/bin/apache-ant-1.6.5/bin/runant.py@ 14982

Last change on this file since 14982 was 14982, checked in by oranfry, 16 years ago

initial import of LiRK3

File size: 3.0 KB
Line 
1#!/usr/bin/python
2# Copyright 2001,2003-2004 The Apache Software Foundation
3#
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
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
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.
15#
16
17"""
18
19 runant.py
20
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
25
26 created: 2001-04-11
27 author: Pierre Dittgen [email protected]
28
29 Assumptions:
30
31 - the "java" executable/script is on the command path
32"""
33import os, os.path, string, sys
34
35# Change it to 1 to get extra debug information
36debug = 0
37
38#######################################################################
39
40# If ANT_HOME is not set default to script's parent directory
41if os.environ.has_key('ANT_HOME'):
42 ANT_HOME = os.environ['ANT_HOME']
43else:
44 ANT_HOME = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))
45
46# set ANT_LIB location
47ANT_LIB = os.path.join(ANT_HOME, 'lib')
48
49# set JAVACMD (check variables JAVACMD and JAVA_HOME)
50JAVACMD = None
51if 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."
59else:
60 JAVACMD = os.environ['JAVACMD']
61if not JAVACMD:
62 JAVACMD = 'java'
63
64launcher_jar = os.path.join(ANT_LIB, 'ant-launcher.jar')
65if not os.path.exists(launcher_jar):
66 print 'Unable to locate ant-launcher.jar. Expected to find it in %s' % \
67 ANT_LIB
68
69# Build up standard classpath (LOCALCLASSPATH)
70LOCALCLASSPATH = launcher_jar
71if os.environ.has_key('LOCALCLASSPATH'):
72 LOCALCLASSPATH += os.pathsep + os.environ['LOCALCLASSPATH']
73
74ANT_OPTS = ""
75if os.environ.has_key('ANT_OPTS'):
76 ANT_OPTS = os.environ['ANT_OPTS']
77
78OPTS = ""
79if os.environ.has_key('JIKESPATH'):
80 OPTS = '-Djikes.class.path=\"%s\"' % os.environ['JIKESPATH']
81
82ANT_ARGS = ""
83if os.environ.has_key('ANT_ARGS'):
84 ANT_ARGS = os.environ['ANT_ARGS']
85
86CLASSPATH = ""
87if os.environ.has_key('CLASSPATH'):
88 CLASSPATH = os.environ['CLASSPATH']
89
90# Builds the commandline
91cmdline = ('%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:], ' '))
95
96if debug:
97 print '\n%s\n\n' % (cmdline)
98
99# Run the biniou!
100os.system(cmdline)
Note: See TracBrowser for help on using the repository browser.