diff --git a/bootstrap.sh b/bootstrap.sh index 360890347..3c171f3c7 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -1,5 +1,7 @@ #!/bin/sh +# You will need to specify JAVA_HOME if compiling with 1.2 or later. + ANT_HOME=. export ANT_HOME diff --git a/docs/index.html b/docs/index.html index ae277354f..20e4dff66 100644 --- a/docs/index.html +++ b/docs/index.html @@ -395,6 +395,38 @@ this should not cause problems.
+You can specify PATH and CLASSPATH variables using both +":" and ";" as separator characters, Ant will +convert it to the correct character of the current operating +system.
+Wherever PATH like values need to be specified a nested element can +be used. This takes the general form of
++ <classpath> + <pathelement path="${classpath}" /> + <pathelement location="lib/helper.jar" /> + </classpath> ++
The location
attribute specifies a single file or
+directory relative to the project's base directory (or an absolute
+filename), while the path
attribute accepts ":"
+or ";" separated lists of locations. The path
+attribute is intended to be used with predefined paths - in any other
+case multiple elements with location
attributes should be
+preferred.
As a shortcut the surrounding PATH element supports path and +location attributes of its own, so
++ <classpath> + <pathelement path="${classpath}" /> + </classpath> ++
can be abreviated to
++ <classpath path="${classpath}" /> ++
Some tasks use directory trees for the task they perform. For instance, the dir directory.
deletes all files with the extension ".bak
" from the current directory
and any sub-directories.
Deletes a directory with all its files and subdirectories.
@@ -1607,6 +1640,19 @@ the one that is currently running Ant.Java
's classpath attribute is a PATH like structure and can also be set via a nested
+classpath element.
+ <java classname="test.Main" args="-h" > + <classpath> + <pathelement location="\test.jar" /> + <pathelement path="${java.class.path}" /> + </classpath> + </java> +
<java classname="test.Main" />
<java classname="test.Main" args="-h" />@@ -1747,21 +1793,12 @@ nested
<src>
element. This is used to specify multiple source
Multiple src
elements may be present and each specifies a source path which will be
searched by Javac for classes to compile.
-Attribute | -Description | -Required | -
src | -A source path. It may contain multiple elements separated with either a ';' or a ':' | -Yes | -
Javac
's srcdir, classpath,
+bootclasspath and extdirs attributes are PATH like structure and can also be set via nested
+src, classpath, bootclasspath and
+extdirs elements respectively.
<javac srcdir="${src}" @@ -2181,6 +2218,13 @@ one group per table. +sourcepath, classpath and bootclasspath
++
Javadoc
's sourcepath, classpath and +bootclasspath attributes are PATH like +structure and can also be set via nested sourcepath, +classpath and bootclasspath elements +respectively.Example
<javadoc packagenames="com.dummy.test.*" sourcepath="src" @@ -2608,6 +2652,11 @@ relative to the base directory.No +Parameters specified as nested elements
+classpath
+
Rmic
's classpath attribute is a PATH like structure and can also be set via a nested +classpath elements.Examples
<rmic classname="com.xyz.FooBar" base="${build}/classes" />runs the rmic compiler for the class
com.xyz.FooBar
. The diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index 3eb957a38..f9bfec796 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -88,26 +88,13 @@ import java.util.*; public class Javac extends MatchingTask { - public class SourcePathElement { - private String path; - - public void setPath(String path) { - this.path = path; - } - - public String getPath() { - return path; - } - }; - /** * Integer returned by the "Modern" jdk1.3 compiler to indicate success. */ private static final int MODERN_COMPILER_SUCCESS = 0; - private Vector srcPathElements = new Vector(); - private Vector srcDirs= new Vector(); + private Path src; private File destDir; private Path compileClasspath; private boolean debug = false; @@ -127,53 +114,22 @@ public class Javac extends MatchingTask { * * @return a nexted src element. */ - public SourcePathElement createSrc() { - SourcePathElement element = new SourcePathElement(); - srcPathElements.addElement(element); - return element; - } - - /** - * Add a single directory to the collection of directories that - * make up the source path. - * - * @param srcDirName the name of the directory to add to the list of source directories. - */ - private void addSrcDir(String srcDirName) { - addSrcDir(project.resolveFile(srcDirName)); - } - - /** - * Add a single directory to the collection of directories that - * make up the source path. - * - * @param srcDir the directory to add to the list of source directories. - */ - private void addSrcDir(File srcDir) { - srcDirs.addElement(srcDir); - } - - /** - * Add a set of source directories specified as path. - * - * @param srcPath the list of source directories. - */ - private void addSrcPath(String srcPath) { - // use a Path tokenizer to find the paths and add them to - // the vector of source paths. - PathTokenizer tokenizer = new PathTokenizer(srcPath); - while (tokenizer.hasMoreTokens()) { - addSrcDir(tokenizer.nextToken()); + public Path createSrc() { + if (src != null) { + src = new Path(); } - } + return src; + } /** * Set the source dirs to find the source Java files. */ - public void setSrcdir(String srcPath) { - // clean out the list of source dirs - srcDirs = new Vector(); - addSrcPath(srcPath); + public void setSrcdir(Path srcDir) { + if (src == null) { + src = srcDir; + } else { + src.append(srcDir); + } } /** @@ -291,23 +247,15 @@ public class Javac extends MatchingTask { public void execute() throws BuildException { // first off, make sure that we've got a srcdir and destdir - // process the source elements into the srcDirs collection - for (Enumeration e = srcPathElements.elements(); e.hasMoreElements(); ) { - SourcePathElement element = (SourcePathElement)e.nextElement(); - addSrcPath(element.getPath()); - } - - if (srcDirs.size() == 0) { + if (src == null) { throw new BuildException("srcdir attribute must be set!"); } - for (Enumeration e = srcDirs.elements(); e.hasMoreElements(); ) { - File srcDir = (File)e.nextElement(); - if (!srcDir.exists()) { - throw new BuildException("srcdir " + srcDir.getPath() + " does not exist!"); - } + String [] list = src.list(); + if (list.length == 0) { + throw new BuildException("srcdir attribute must be set!"); } - + if (destDir == null) { throw new BuildException("destdir attribute must be set!"); } @@ -315,15 +263,19 @@ public class Javac extends MatchingTask { // scan source directories and dest directory to build up both copy lists and // compile lists resetFileLists(); - for (Enumeration e = srcDirs.elements(); e.hasMoreElements(); ) { - File srcDir = (File)e.nextElement(); + for (int i=0; i