ant.cmd 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. Run ant
  15. */
  16. '@echo off'
  17. parse arg mode envarg '::' antarg
  18. if mode\='.' & mode\='..' & mode\='/' then do
  19. envarg = mode envarg
  20. mode = ''
  21. end
  22. if antarg = '' then do
  23. antarg = envarg
  24. envarg = ''
  25. end
  26. x = setlocal()
  27. env="OS2ENVIRONMENT"
  28. antenv = _getenv_('antenv')
  29. if _testenv_() = 0 then interpret 'call "' || antenv || '"' '"' || envarg || '"'
  30. if mode = '' then mode = _getenv_('ANT_MODE' '..')
  31. if mode \= '/' then do
  32. runrc = _getenv_('runrc')
  33. antrc = _getenv_('antrc' 'antrc.cmd')
  34. if mode = '..' then mode = '-r'
  35. else mode = ''
  36. interpret 'call "' || runrc || '"' antrc '"' || mode || '"'
  37. end
  38. if _testenv_() = 0 then do
  39. say 'Ant environment is not set properly'
  40. x = endlocal()
  41. exit 16
  42. end
  43. settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME
  44. java = _getenv_('javacmd' 'java')
  45. opts = value('ANT_OPTS',,env)
  46. args = value('ANT_ARGS',,env)
  47. lcp = value('LOCALCLASSPATH',,env)
  48. cp = value('CLASSPATH',,env)
  49. if value('ANT_USE_CP',,env) \= '' then do
  50. if lcp \= '' & right(lcp, 1) \= ';' then lcp = lcp || ';'
  51. lcp = lcp || cp
  52. 'SET CLASSPATH='
  53. end
  54. if lcp\='' then lcp = '-classpath' lcp
  55. cmd = java opts lcp '-jar' ANT_HOME ||'\lib\ant-launcher.jar' settings args antarg
  56. launcher = stream(ANT_HOME ||'\lib\ant-launcher.jar', 'C', 'query exists')
  57. if launcher = '' then entry = 'org.apache.tools.ant.Main'
  58. else entry = 'org.apache.tools.ant.launch.Launcher'
  59. java opts lcp entry settings args antarg
  60. x = endlocal()
  61. return rc
  62. _testenv_: procedure expose env ANT_HOME JAVA_HOME
  63. ANT_HOME = value('ANT_HOME',,env)
  64. if ANT_HOME = '' then return 0
  65. JAVA_HOME = value('JAVA_HOME',,env)
  66. if JAVA_HOME = '' then return 0
  67. cp = translate(value('CLASSPATH',,env))
  68. if pos(translate(ANT_HOME), cp) = 0 then return 0
  69. if pos(translate(JAVA_HOME), cp) = 0 then return 0
  70. return 1
  71. _getenv_: procedure expose env
  72. parse arg envar default
  73. if default = '' then default = envar
  74. var = value(translate(envar),,env)
  75. if var = '' then var = default
  76. return var