1 /* 2 Licensed to the Apache Software Foundation (ASF) under one or more 3 contributor license agreements. See the NOTICE file distributed with 4 this work for additional information regarding copyright ownership. 5 The ASF licenses this file to You under the Apache License, Version 2.0 6 (the "License"); you may not use this file except in compliance with 7 the License. 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 Run ant 18 */ 19 20 '@echo off' 21 parse arg mode envarg '::' antarg 22 23 if mode\='.' & mode\='..' & mode\='/' then do 24 envarg = mode envarg 25 mode = '' 26 end 27 28 if antarg = '' then do 29 antarg = envarg 30 envarg = '' 31 end 32 33 x = setlocal() 34 35 env="OS2ENVIRONMENT" 36 antenv = _getenv_('antenv') 37 if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"' 38 39 if mode = '' then mode = _getenv_('ANT_MODE' '..') 40 if mode \= '/' then do 41 runrc = _getenv_('runrc') 42 antrc = _getenv_('antrc' 'antrc.cmd') 43 if mode = '..' then mode = '-r' 44 else mode = '' 45 interpret 'call "' || runrc || '"' antrc '"' || mode || '"' 46 end 47 48 if _testenv_() = 0 then do 49 say 'Ant environment is not set properly' 50 x = endlocal() 51 exit 16 52 end 53 54 settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME 55 56 java = _getenv_('javacmd' 'java') 57 opts = value('ANT_OPTS',,env) 58 args = value('ANT_ARGS',,env) 59 lcp = value('LOCALCLASSPATH',,env) 60 cp = value('CLASSPATH',,env) 61 if value('ANT_USE_CP',,env) \= '' then do 62 if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';' 63 lcp = lcp || cp 64 'SET CLASSPATH=' 65 end 66 if lcp\='' then lcp = '-classpath' lcp 67 68 cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg 69 launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists') 70 if launcher = '' then entry = 'org.apache.tools.ant.Main' 71 else entry = 'org.apache.tools.ant.launch.Launcher' 72 java opts lcp entry settings args antarg 73 74 x = endlocal() 75 76 return rc 77 78 _testenv_: procedure expose env ANT_HOME JAVA_HOME 79 ANT_HOME = value('ANT_HOME',,env) 80 if ANT_HOME = '' then return 0 81 JAVA_HOME = value('JAVA_HOME',,env) 82 if JAVA_HOME = '' then return 0 83 cp = translate(value('CLASSPATH',,env)) 84 if pos(translate(ANT_HOME), cp) = 0 then return 0 85 if pos(translate(JAVA_HOME), cp) = 0 then return 0 86 return 1 87 88 _getenv_: procedure expose env 89 parse arg envar default 90 if default = '' then default = envar 91 var = value(translate(envar),,env) 92 if var = '' then var = default 93 return var 94