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