diff --git a/build.xml b/build.xml index 67fbb2fc1..af1e1b09f 100644 --- a/build.xml +++ b/build.xml @@ -961,7 +961,7 @@ - + @@ -1138,7 +1138,7 @@ - + diff --git a/docs/manual/install.html b/docs/manual/install.html index b1c80acb9..9c65fc539 100644 --- a/docs/manual/install.html +++ b/docs/manual/install.html @@ -18,9 +18,9 @@ href="http://cvs.apache.org/builds/ant/nightly/">http://cvs.apache.org/builds/an

If you prefer the source edition, you can download the source for the latest Ant release from http://ant.apache.org/srcdownload.cgi. -Again, if you prefer the edge, you can access -the code as it is being developed via CVS. The Jakarta website has details on -accessing CVS. Please checkout the +Again, if you prefer the edge, you can access +the code as it is being developed via CVS. The Jakarta website has details on +accessing CVS. Please checkout the ant module. See the section Building Ant on how to @@ -33,7 +33,7 @@ Ant CVS repository on-line.

System Requirements

Ant has been used successfully on many platforms, including Linux, commercial flavours of Unix such as Solaris and HP-UX, -Windows 9x and NT, Novell Netware 6 and MacOS X. +Windows 9x and NT, OS/2 Warp, Novell Netware 6 and MacOS X.

To build and use Ant, you must have a JAXP-compliant XML parser installed and available on your classpath.

@@ -95,17 +95,17 @@ file there. This directory will be known as ANT_HOME. @@ -114,7 +114,7 @@ installed in a short, 8.3 path, such as C:\Ant.
- Windows 95, Windows 98 & Windows ME Note: + Windows 95, Windows 98 & Windows ME Note:
  -On these systems, the script used to launch Ant will have +On these systems, the script used to launch Ant will have problems if ANT_HOME is a long filename (i.e. a filename which is not -of the format known as "8.3"). This is due to -limitations in the OS's handling of the "for" -batch-file statement. It is recommended, therefore, that Ant be +of the format known as "8.3"). This is due to +limitations in the OS's handling of the "for" +batch-file statement. It is recommended, therefore, that Ant be installed in a short, 8.3 path, such as C:\Ant.

On these systems you will also need to configure more environment space to cater for the environment variables used in the Ant lauch script. - To do this, you will need to add or update the following line in + To do this, you will need to add or update the following line in the config.sys file

shell=c:\command.com c:\ /p /e:32768

@@ -152,7 +152,7 @@ libraries may either be placed in Ant's lib directory, where they will be picked automatically, or made available on the system CLASSPATH environment variable.

-

Windows

+

Windows and OS/2

Assume Ant is installed in c:\ant\. The following sets up the environment:

set ANT_HOME=c:\ant
diff --git a/docs/manual/running.html b/docs/manual/running.html
index fe73dc6dd..9e11288d0 100644
--- a/docs/manual/running.html
+++ b/docs/manual/running.html
@@ -161,17 +161,48 @@ set):

Cygwin Users

-

The Unix launch script that come with Ant works correctly with Cygwin. You -should not have any problems launching Ant form the Cygwin shell. It is important +

The Unix launch script that come with Ant works correctly with Cygwin. You +should not have any problems launching Ant form the Cygwin shell. It is important to note however, that once Ant is runing it is part of the JDK which operates as -a native Windows application. The JDK is not a Cygwin executable, and it therefore +a native Windows application. The JDK is not a Cygwin executable, and it therefore has no knowledge of the Cygwin paths, etc. In particular when using the <exec> -task, executable names such as "/bin/sh" will not work, even though these -work from the Cygwin shell from which Ant was launched. You can use an executable +task, executable names such as "/bin/sh" will not work, even though these +work from the Cygwin shell from which Ant was launched. You can use an executable name such as "sh" and rely on that command being available in the Windows path.

+

OS/2 Users

+

The OS/2 lanuch script was developed so as it can perform complex task. It has two parts: +ant.cmd which calls Ant and antenv.cmd which sets environment for Ant. +Most often you will just call ant.cmd using the same command line options as described +above. The behaviour can be modified by a number of ways explained below.

+ +

Script ant.cmd first verifies whether the Ant environment is set correctly. The +requirements are:

+
    +
  1. Environment variable JAVA_HOME is set.
  2. +
  3. Environment variable ANT_HOME is set.
  4. +
  5. environment variable CLASSPATH is set and contains at least one element from +JAVA_HOME and at least one element from ANT_HOME.
  6. +
+ +

If any of these conditions is violated, script antenv.cmd is called. This script +first invokes configuration scripts if there exist: the system-wide configuration +antconf.cmd from the %ETC% directory and then the user comfiguration +antrc.cmd from the %HOME% directory. At this moment both +JAVA_HOME and ANT_HOME must be defined because antenv.cmd +now adds classes.zip or tools.jar (depending on version of JVM) and +everything from %ANT_HOME%\lib except ant-*.jar to +CLASSPATH. Finally ant.cmd calls per-directory configuration +antrc.cmd. All settings made by ant.cmd are local and are undone when the +script ends. The settings made by antenv.cmd are persistent during the lifetime of the +shell (of course unless called automaticaly from ant.cmd). It is thus possible to call +antenv.cmd manually and modify some settings before calling ant.cmd.

+ +

Scripts envset.cmd and runrc.cmd perform auxilliary tasks. All scripts +have some documentation inside.

+

Running Ant via Java

If you have installed Ant in the do-it-yourself way, Ant can be started with:

diff --git a/docs/manual/runninglist.html b/docs/manual/runninglist.html index e9ad3ec27..587aad9fd 100644 --- a/docs/manual/runninglist.html +++ b/docs/manual/runninglist.html @@ -16,6 +16,7 @@   Files
  Environment Variables
  Cygwin Users
+  OS/2 Users
Running Ant via Java
diff --git a/src/main/org/apache/tools/ant/taskdefs/Execute.java b/src/main/org/apache/tools/ant/taskdefs/Execute.java index ad05a0a61..d619d11b8 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Execute.java +++ b/src/main/org/apache/tools/ant/taskdefs/Execute.java @@ -109,7 +109,9 @@ public class Execute { static { // Try using a JDK 1.3 launcher try { - vmLauncher = new Java13CommandLauncher(); + if (!Os.isFamily("os/2")) { + vmLauncher = new Java13CommandLauncher(); + } } catch (NoSuchMethodException exc) { // Ignore and keep trying } diff --git a/src/script/ant.cmd b/src/script/ant.cmd new file mode 100644 index 000000000..1086d1c53 --- /dev/null +++ b/src/script/ant.cmd @@ -0,0 +1,71 @@ +/* + Copyright (c) 2003 The Apache Software Foundation. All rights + reserved. + + Run ant +*/ + +parse arg mode envarg '::' antarg + +if mode\='.' & mode\='..' & mode\='/' then do + envarg = mode envarg + mode = '' +end + +if antarg = '' then do + antarg = envarg + envarg = '' +end + +x = setlocal() + +env="OS2ENVIRONMENT" +antenv = _getenv_('antenv') +if _testenv_() = 0 then do + interpret 'call "' || antenv || '"' '"' || envarg || '"' + if _testenv_() = 0 then do + say 'Ant environment is not set properly' + x = endlocal() + exit 16 + end +end + +if mode = '' then mode = _getenv_('ANT_MODE' '..') +if mode \= '/' then do + runrc = _getenv_('runrc') + antrc = _getenv_('antrc' 'antrc.cmd') + if mode = '..' then mode = '-r' + else mode = '' + interpret 'call "' || runrc || '"' antrc '"' || mode || '"' +end + +settings = '-Dant.home=' || ANT_HOME '-Djava.home=' || JAVA_HOME + +java = _getenv_('javacmd' 'java') +opts = value('ANT_OPTS',,env) +args = value('ANT_ARGS',,env) +lcp = value('LOCALCLASSPATH',,env) +if lcp\='' then lcp = '-cp' lcp + +java opts lcp 'org.apache.tools.ant.Main' settings args antarg + +x = endlocal() + +return rc + +_testenv_: procedure expose env ANT_HOME JAVA_HOME +ANT_HOME = value('ANT_HOME',,env) +if ANT_HOME = '' then return 0 +JAVA_HOME = value('JAVA_HOME',,env) +if JAVA_HOME = '' then return 0 +cp = translate(value('CLASSPATH',,env)) +if pos(translate(ANT_HOME), cp) = 0 then return 0 +if pos(translate(JAVA_HOME), cp) = 0 then return 0 +return 1 + +_getenv_: procedure expose env +parse arg envar default +if default = '' then default = envar +var = value(translate(envar),,env) +if var = '' then var = default +return var diff --git a/src/script/antenv.cmd b/src/script/antenv.cmd new file mode 100644 index 000000000..22fabea9c --- /dev/null +++ b/src/script/antenv.cmd @@ -0,0 +1,100 @@ +/* + Copyright (c) 2003 The Apache Software Foundation. All rights + reserved. + + Ant environment +*/ + +call RxFuncAdd "SysLoadFuncs", "RexxUtil", "SysLoadFuncs" +call SysLoadFuncs + +/* Prepare the parameters for later use */ +parse arg argv +mode = '' +args = '' +opts = '' +cp = '' +lcp = '' + +do i = 1 to words(argv) + param = word(argv, i) + select + when param='-lcp' then mode = 'l' + when param='-cp' | param='-classpath' then mode = 'c' + when abbrev('-opts', param, 4) then mode = 'o' + when abbrev('-args', param, 4) then mode = 'a' + otherwise + select + when mode = 'a' then args = space(args param, 1) + when mode = 'c' then cp = space(cp param, 1) + when mode = 'l' then lcp = space(lcp param, 1) + when mode = 'o' then opts = space(opts param, 1) + otherwise + say 'Option' param 'ignored' + end + end +end + +env="OS2ENVIRONMENT" +antconf = _getenv_('antconf' 'antconf.cmd') +runrc = _getenv_('runrc') +interpret 'call "' || runrc || '"' '"' || antconf || '"' 'ETC' +ANT_HOME = value('ANT_HOME',,env) +JAVA_HOME = value('JAVA_HOME',,env) +classpath = value('CLASSPATH',,env) +classes = stream(JAVA_HOME || "\lib\classes.zip", "C", "QUERY EXISTS") +if classes \= '' then classpath = prepend(classpath classes) +classes = stream(JAVA_HOME || "\lib\tools.jar", "C", "QUERY EXISTS") +if classes \= '' then classpath = prepend(classpath classes) + +mincp = classpath +call SysFileTree ANT_HOME || '\lib\*.jar', 'jar', 'FO' +do i = 1 to jar.0 + nm = filespec('name', jar.i) + if pos('ant-', nm) == 0 then classpath = prepend(classpath jar.i) +end +if length(classpath) > 512 then do + say 'Classpath is too long, switching to the minimal version...' + say '... some tasks will not work' + classpath = mincp + classpath = prepend(classpath ANT_HOME || '\lib\ant.jar') + classpath = prepend(classpath ANT_HOME || '\lib\optional.jar') +end + +'SET CLASSPATH=' || classpath + +/* Setting classpathes, options and arguments */ +envset = _getenv_('envset') +if cp\='' then interpret 'call "' || envset || '"' '"; CLASSPATH"' '"' || cp || '"' +if lcp\='' then interpret 'call "' || envset || '"' '"; LOCALCLASSPATH"' '"' || lcp || '"' +if opts\='' then interpret 'call "' || envset || '"' '"-D ANT_OPTS"' '"' || opts || '"' +if args\='' then interpret 'call "' || envset || '"' '"ANT_ARGS"' '"' || args || '"' + +exit 0 + +addpath: procedure +parse arg path elem +if elem = '' then do + if path\='' & right(path, 1)\=';' then path = path || ';' + return path +end +if substr(path, length(path)) = ';' then glue = '' +else glue = ';' +if pos(translate(elem), translate(path)) = 0 then path = path || glue || elem || ';' +return path + +prepend: procedure +parse arg path elem +if elem = '' then do + if path\='' & right(path, 1)\=';' then path = path || ';' + return path +end +if pos(translate(elem), translate(path)) = 0 then path = elem || ';' || path +return path + +_getenv_: procedure expose env +parse arg envar default +if default = '' then default = envar +var = value(translate(envar),,env) +if var = '' then var = default +return var diff --git a/src/script/envset.cmd b/src/script/envset.cmd new file mode 100644 index 000000000..5f7ac2f95 --- /dev/null +++ b/src/script/envset.cmd @@ -0,0 +1,119 @@ +/* + + Copyright (c) 2003 The Apache Software Foundation. All rights + reserved. + +SET environment variables +First optional parameter: + ; parameters are considered parts of a path variable, semicolons are + appended to each element if not already present + -D parameters are properties for Java or Makefile etc., -D will be + prepended and the parameters will be separated by a space + =D the same as above but equal sign is not required + , parameters should be comma separated in the environment variable + - parameters should be separated by the next parameter + Other values mean that the first parameter is missing and the environment + variable will be set to the space separated parameters + +Second parameter: name of the environment variable + +Next parameters: values +; implies that the equal sign is considered a part of the parameter and is +not interpreted + +-D requires parameters in the form name=value. If the equal sign is not found, +the parameters are changed to name=expanded_name + +Other options have optional equal sign. If it is found, only the part after +the equal sign will be oprionally expanded. + +If the parameter is the minus sign, the next parameter will not be expanded. +If the parameter is a single dot, it will be replaced with the value of the +environment variable as it existed before envset was invoked. + +For other parameters the batch looks for the environment variable with the +same name (in uppercase). If it is found, it forms the expanded_name. If +the environment variable with such a name does not exist, the expanded_name +will hold the parameter name without case conversion. +*/ + +parse arg mode envar args + +equal = 0 +sep = ' ' + +/* Parse command line parameters */ +select + when mode='-' then do + sep = envar + parse var args envar args + end + when mode=';' then do + sep = '' + equal = -1 + end + when mode='-D' then equal = 1 + when mode='=D' then mode = '-D' + when mode=',' then sep = ',' +otherwise + args = envar args + envar = mode + mode = '' +end + +env = 'OS2ENVIRONMENT' +envar = translate(envar) +orig = value(envar,,env) +newval = '' +expand = 1 + +/* for each parameter... */ +do i = 1 to words(args) + if expand > 0 & word(args, i) = '-' then expand = 0 + else call addval word(args, i) +end + +/* Optionally enclose path variable by quotes */ +if mode = ';' & pos(' ', newval) > 0 then newval = '"' || newval || '"' + +/* Set the new value, 'SET' cannot be used since it does not allow '=' */ +x = value(envar, newval, env) +exit 0 + +addval: procedure expose sep equal orig expand newval mode env +parse arg var + +if var = '.' then expvar = orig +else do + if equal >= 0 then do + parse var var name '=' val + if val = '' then var = name + else var = val + end + if expand = 0 then expvar = var + else expvar = value(translate(var),,env) + if expvar = '' then expvar = var + if equal >= 0 then do + if val = '' then do + parse var expvar key '=' val + if val <> '' then name = key + else do + if equal > 0 then val = key + else name = key + end + end + else val = expvar + if pos(' ', val) > 0 | pos('=', val) > 0 then val = '"' || val || '"' + if val = '' then expvar = name + else expvar = name || '=' || val + end + if mode = '-D' then expvar = '-D' || expvar + if mode = ';' then do + if right(expvar, 1) <> ';' then expvar = expvar || ';' + end +end + +if newval = '' then newval = expvar +else newval = newval || sep || expvar +expand = 1 +return diff --git a/src/script/runrc.cmd b/src/script/runrc.cmd new file mode 100644 index 000000000..8cbb2321f --- /dev/null +++ b/src/script/runrc.cmd @@ -0,0 +1,48 @@ +/* + Copyright (c) 2003 The Apache Software Foundation. All rights + reserved. + + Run RC file, name is in the first arg, second arg is either PATH + ENV or -r or nothing +*/ + +parse arg name path rest + +if name = '' then do + say 'RC file name is missing' + exit 1 +end + +if rest \= '' then do + say 'Too many parameters' + exit 1 +end + +call runit name path +exit 0 + +runit: procedure +parse arg name path dir + +if path \= '' & path \= '-r' then do + dir = value(translate(path),,'OS2ENVIRONMENT') + if dir = '' then return + dir = translate(dir, '\', '/') /* change UNIX-like path to OS/2 */ +end + +if dir = '' then dir = directory() + +if path = '-r' then do /* recursive call */ + subdir = filespec('path', dir) + if subdir \= '\' then do + subdir = left(subdir, length(subdir)-1) + call runit name path filespec('drive', dir) || subdir + end +end + +/* Look for the file and run it */ +if right(dir, 1) \= '\' then dir = dir || '\' +rcfile = stream(dir || name, 'c', 'query exists') +if rcfile \= '' then interpret 'call "' || rcfile || '"' + +return