source: release-kits/lirk3/bin/apache-ant-1.6.5/bootstrap/bin/ant@ 14982

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

initial import of LiRK3

File size: 8.6 KB
Line 
1#! /bin/sh
2
3# Copyright 2001-2005 The Apache Software Foundation
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Extract launch and ant arguments, (see details below).
18ant_exec_args=
19no_config=false
20use_jikes_default=false
21ant_exec_debug=false
22show_help=false
23for arg in "$@" ; do
24 if [ "$arg" = "--noconfig" ] ; then
25 no_config=true
26 elif [ "$arg" = "--usejikes" ] ; then
27 use_jikes_default=true
28 elif [ "$arg" = "--execdebug" ] ; then
29 ant_exec_debug=true
30 elif [ my"$arg" = my"--h" -o my"$arg" = my"--help" ] ; then
31 show_help=true
32 ant_exec_args="$ant_exec_args -h"
33 else
34 if [ my"$arg" = my"-h" -o my"$arg" = my"-help" ] ; then
35 show_help=true
36 fi
37 ant_exec_args="$ant_exec_args \"$arg\""
38 fi
39done
40
41# Source/default ant configuration
42if $no_config ; then
43 rpm_mode=false
44 usejikes=$use_jikes_default
45else
46 # load system-wide ant configuration
47 if [ -f "/etc/ant.conf" ] ; then
48 . /etc/ant.conf
49 fi
50
51 # load user ant configuration
52 if [ -f "$HOME/.ant/ant.conf" ] ; then
53 . $HOME/.ant/ant.conf
54 fi
55 if [ -f "$HOME/.antrc" ] ; then
56 . "$HOME/.antrc"
57 fi
58
59 # provide default configuration values
60 if [ -z "$rpm_mode" ] ; then
61 rpm_mode=false
62 fi
63 if [ -z "$usejikes" ] ; then
64 usejikes=$use_jikes_default
65 fi
66fi
67
68# Setup Java environment in rpm mode
69if $rpm_mode ; then
70 if [ -f /usr/share/java-utils/java-functions ] ; then
71 . /usr/share/java-utils/java-functions
72 set_jvm
73 set_javacmd
74 fi
75fi
76
77# OS specific support. $var _must_ be set to either true or false.
78cygwin=false;
79darwin=false;
80case "`uname`" in
81 CYGWIN*) cygwin=true ;;
82 Darwin*) darwin=true
83 if [ -z "$JAVA_HOME" ] ; then
84 JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Home
85 fi
86 ;;
87esac
88
89if [ -z "$ANT_HOME" -o ! -d "$ANT_HOME" ] ; then
90 ## resolve links - $0 may be a link to ant's home
91 PRG="$0"
92 progname=`basename "$0"`
93
94 # need this for relative symlinks
95 while [ -h "$PRG" ] ; do
96 ls=`ls -ld "$PRG"`
97 link=`expr "$ls" : '.*-> \(.*\)$'`
98 if expr "$link" : '/.*' > /dev/null; then
99 PRG="$link"
100 else
101 PRG=`dirname "$PRG"`"/$link"
102 fi
103 done
104
105 ANT_HOME=`dirname "$PRG"`/..
106
107 # make it fully qualified
108 ANT_HOME=`cd "$ANT_HOME" && pwd`
109fi
110
111# For Cygwin, ensure paths are in UNIX format before anything is touched
112if $cygwin ; then
113 [ -n "$ANT_HOME" ] &&
114 ANT_HOME=`cygpath --unix "$ANT_HOME"`
115 [ -n "$JAVA_HOME" ] &&
116 JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
117fi
118
119# set ANT_LIB location
120ANT_LIB="${ANT_HOME}/lib"
121
122if [ -z "$JAVACMD" ] ; then
123 if [ -n "$JAVA_HOME" ] ; then
124 if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
125 # IBM's JDK on AIX uses strange locations for the executables
126 JAVACMD="$JAVA_HOME/jre/sh/java"
127 else
128 JAVACMD="$JAVA_HOME/bin/java"
129 fi
130 else
131 JAVACMD=`which java 2> /dev/null `
132 if [ -z "$JAVACMD" ] ; then
133 JAVACMD=java
134 fi
135 fi
136fi
137
138if [ ! -x "$JAVACMD" ] ; then
139 echo "Error: JAVA_HOME is not defined correctly."
140 echo " We cannot execute $JAVACMD"
141 exit 1
142fi
143
144# Build local classpath using just the launcher in non-rpm mode or
145# use the Jpackage helper in rpm mode with basic and default jars
146# specified in the ant.conf configuration. Because the launcher is
147# used, libraries linked in ANT_HOME will also be include, but this
148# is discouraged as it is not java-version safe. A user should
149# request optional jars and their dependencies via the OPT_JAR_LIST
150# variable
151if $rpm_mode && [ -f /usr/bin/build-classpath ] ; then
152 LOCALCLASSPATH="$(/usr/bin/build-classpath ant ant-launcher jaxp_parser_impl xml-commons-apis)"
153 # If the user requested to try to add some other jars to the classpath
154 if [ -n "$OPT_JAR_LIST" ] ; then
155 _OPTCLASSPATH="$(/usr/bin/build-classpath $OPT_JAR_LIST 2> /dev/null)"
156 if [ -n "$_OPTCLASSPATH" ] ; then
157 LOCALCLASSPATH="$LOCALCLASSPATH:$_OPTCLASSPATH"
158 fi
159 fi
160
161 # Explicitly add javac path to classpath, assume JAVA_HOME set
162 # properly in rpm mode
163 if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then
164 LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar"
165 fi
166 if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then
167 LOCALCLASSPATH="$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip"
168 fi
169
170 # if CLASSPATH_OVERRIDE env var is set, LOCALCLASSPATH will be
171 # user CLASSPATH first and ant-found jars after.
172 # In that case, the user CLASSPATH will override ant-found jars
173 #
174 # if CLASSPATH_OVERRIDE is not set, we'll have the normal behaviour
175 # with ant-found jars first and user CLASSPATH after
176 if [ -n "$CLASSPATH" ] ; then
177 # merge local and specified classpath
178 if [ -z "$LOCALCLASSPATH" ] ; then
179 LOCALCLASSPATH="$CLASSPATH"
180 elif [ -n "$CLASSPATH_OVERRIDE" ] ; then
181 LOCALCLASSPATH="$CLASSPATH:$LOCALCLASSPATH"
182 else
183 LOCALCLASSPATH="$LOCALCLASSPATH:$CLASSPATH"
184 fi
185
186 # remove class path from launcher -cp option
187 CLASSPATH=""
188 fi
189else
190 # not using rpm_mode; use launcher to determine classpaths
191 if [ -z "$LOCALCLASSPATH" ] ; then
192 LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar
193 else
194 LOCALCLASSPATH=$ANT_LIB/ant-launcher.jar:$LOCALCLASSPATH
195 fi
196fi
197
198if [ -n "$JAVA_HOME" ] ; then
199 # OSX hack to make Ant work with jikes
200 if $darwin ; then
201 OSXHACK="${JAVA_HOME}/../Classes"
202 if [ -d "${OSXHACK}" ] ; then
203 for i in "${OSXHACK}"/*.jar
204 do
205 JIKESPATH="$JIKESPATH:$i"
206 done
207 fi
208 fi
209fi
210
211# Allow Jikes support (off by default)
212if $usejikes; then
213 ANT_OPTS="$ANT_OPTS -Dbuild.compiler=jikes"
214fi
215
216# For Cygwin, switch paths to appropriate format before running java
217# For PATHs convert to unix format first, then to windows format to ensure
218# both formats are supported. Probably this will fail on directories with ;
219# in the name in the path. Let's assume that paths containing ; are more
220# rare than windows style paths on cygwin.
221if $cygwin; then
222 if [ "$OS" = "Windows_NT" ] && cygpath -m .>/dev/null 2>/dev/null ; then
223 format=mixed
224 else
225 format=windows
226 fi
227 ANT_HOME=`cygpath --$format "$ANT_HOME"`
228 ANT_LIB=`cygpath --$format "$ANT_LIB"`
229 JAVA_HOME=`cygpath --$format "$JAVA_HOME"`
230 LCP_TEMP=`cygpath --path --unix "$LOCALCLASSPATH"`
231 LOCALCLASSPATH=`cygpath --path --$format "$LCP_TEMP"`
232 if [ -n "$CLASSPATH" ] ; then
233 CP_TEMP=`cygpath --path --unix "$CLASSPATH"`
234 CLASSPATH=`cygpath --path --$format "$CP_TEMP"`
235 fi
236 CYGHOME=`cygpath --$format "$HOME"`
237fi
238
239# Show script help if requested
240if $show_help ; then
241 echo $0 '[script options] [options] [target [target2 [target3] ..]]'
242 echo 'Script Options:'
243 echo ' --help, --h print this message and ant help'
244 echo ' --noconfig suppress sourcing of /etc/ant.conf,'
245 echo ' $HOME/.ant/ant.conf, and $HOME/.antrc'
246 echo ' configuration files'
247 echo ' --usejikes enable use of jikes by default, unless'
248 echo ' set explicitly in configuration files'
249 echo ' --execdebug print ant exec line generated by this'
250 echo ' launch script'
251 echo ' '
252fi
253# add a second backslash to variables terminated by a backslash under cygwin
254if $cygwin; then
255 case "$ANT_HOME" in
256 *\\ )
257 ANT_HOME="$ANT_HOME\\"
258 ;;
259 esac
260 case "$CYGHOME" in
261 *\\ )
262 CYGHOME="$CYGHOME\\"
263 ;;
264 esac
265 case "$JIKESPATH" in
266 *\\ )
267 JIKESPATH="$JIKESPATH\\"
268 ;;
269 esac
270 case "$LOCALCLASSPATH" in
271 *\\ )
272 LOCALCLASSPATH="$LOCALCLASSPATH\\"
273 ;;
274 esac
275 case "$CLASSPATH" in
276 *\\ )
277 CLASSPATH="$CLASSPATH\\"
278 ;;
279 esac
280fi
281# Execute ant using eval/exec to preserve spaces in paths,
282# java options, and ant args
283ant_sys_opts=
284if [ -n "$CYGHOME" ]; then
285 if [ -n "$JIKESPATH" ]; then
286 ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\" -Dcygwin.user.home=\"$CYGHOME\""
287 else
288 ant_sys_opts="-Dcygwin.user.home=\"$CYGHOME\""
289 fi
290else
291 if [ -n "$JIKESPATH" ]; then
292 ant_sys_opts="-Djikes.class.path=\"$JIKESPATH\""
293 fi
294fi
295ant_exec_command="exec \"$JAVACMD\" $ANT_OPTS -classpath \"$LOCALCLASSPATH\" -Dant.home=\"$ANT_HOME\" -Dant.library.dir=\"$ANT_LIB\" $ant_sys_opts org.apache.tools.ant.launch.Launcher $ANT_ARGS -cp \"$CLASSPATH\" $ant_exec_args"
296if $ant_exec_debug ; then
297 echo $ant_exec_command
298fi
299eval $ant_exec_command
Note: See TracBrowser for help on using the repository browser.