1
|
1 |
/*
|
|
2 |
Copyright 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 |
Run ant
|
|
17 |
*/
|
|
18 |
|
|
19 |
'@echo off'
|
|
20 |
parse arg mode envarg '::' antarg
|
|
21 |
|
|
22 |
if mode\='.' & mode\='..' & mode\='/' then do
|
|
23 |
envarg = mode envarg
|
|
24 |
mode = ''
|
|
25 |
end
|
|
26 |
|
|
27 |
if antarg = '' then do
|
|
28 |
antarg = envarg
|
|
29 |
envarg = ''
|
|
30 |
end
|
|
31 |
|
|
32 |
x = setlocal()
|
|
33 |
|
|
34 |
env="OS2ENVIRONMENT"
|
|
35 |
antenv = _getenv_('antenv')
|
|
36 |
if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"'
|
|
37 |
|
|
38 |
if mode = '' then mode = _getenv_('ANT_MODE' '..')
|
|
39 |
if mode \= '/' then do
|
|
40 |
runrc = _getenv_('runrc')
|
|
41 |
antrc = _getenv_('antrc' 'antrc.cmd')
|
|
42 |
if mode = '..' then mode = '-r'
|
|
43 |
else mode = ''
|
|
44 |
interpret 'call "' || runrc || '"' antrc '"' || mode || '"'
|
|
45 |
end
|
|
46 |
|
|
47 |
if _testenv_() = 0 then do
|
|
48 |
say 'Ant environment is not set properly'
|
|
49 |
x = endlocal()
|
|
50 |
exit 16
|
|
51 |
end
|
|
52 |
|
|
53 |
settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME
|
|
54 |
|
|
55 |
java = _getenv_('javacmd' 'java')
|
|
56 |
opts = value('ANT_OPTS',,env)
|
|
57 |
args = value('ANT_ARGS',,env)
|
|
58 |
lcp = value('LOCALCLASSPATH',,env)
|
|
59 |
cp = value('CLASSPATH',,env)
|
|
60 |
if value('ANT_USE_CP',,env) \= '' then do
|
|
61 |
if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';'
|
|
62 |
lcp = lcp || cp
|
|
63 |
'SET CLASSPATH='
|
|
64 |
end
|
|
65 |
if lcp\='' then lcp = '-classpath' lcp
|
|
66 |
|
|
67 |
cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg
|
|
68 |
launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists')
|
|
69 |
if launcher = '' then entry = 'org.apache.tools.ant.Main'
|
|
70 |
else entry = 'org.apache.tools.ant.launch.Launcher'
|
|
71 |
java opts lcp entry settings args antarg
|
|
72 |
|
|
73 |
x = endlocal()
|
|
74 |
|
|
75 |
return rc
|
|
76 |
|
|
77 |
_testenv_: procedure expose env ANT_HOME JAVA_HOME
|
|
78 |
ANT_HOME = value('ANT_HOME',,env)
|
|
79 |
if ANT_HOME = '' then return 0
|
|
80 |
JAVA_HOME = value('JAVA_HOME',,env)
|
|
81 |
if JAVA_HOME = '' then return 0
|
|
82 |
cp = translate(value('CLASSPATH',,env))
|
|
83 |
if pos(translate(ANT_HOME), cp) = 0 then return 0
|
|
84 |
if pos(translate(JAVA_HOME), cp) = 0 then return 0
|
|
85 |
return 1
|
|
86 |
|
|
87 |
_getenv_: procedure expose env
|
|
88 |
parse arg envar default
|
|
89 |
if default = '' then default = envar
|
|
90 |
var = value(translate(envar),,env)
|
|
91 |
if var = '' then var = default
|
|
92 |
return var
|