diff --git a/bootstrap.sh b/bootstrap.sh index 00fd4a360..3090be30b 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -38,8 +38,8 @@ mkdir -p ${CLASSDIR} echo ... Compiling Ant Classes javac -d ${CLASSDIR} ${TOOLS}/tar/*.java -javac -d ${CLASSDIR} ${TOOLS}/ant/*.java javac -d ${CLASSDIR} ${TOOLS}/ant/types/*.java +javac -d ${CLASSDIR} ${TOOLS}/ant/*.java javac -d ${CLASSDIR} ${TOOLS}/ant/taskdefs/*.java echo ... Copying Required Files diff --git a/build.xml b/build.xml index bcaff660a..a6182d486 100644 --- a/build.xml +++ b/build.xml @@ -69,7 +69,6 @@ debug="on" deprecation="off" optimize="on" > - diff --git a/src/main/org/apache/tools/ant/AntClassLoader.java b/src/main/org/apache/tools/ant/AntClassLoader.java index d56ddaeea..df1c89a0f 100644 --- a/src/main/org/apache/tools/ant/AntClassLoader.java +++ b/src/main/org/apache/tools/ant/AntClassLoader.java @@ -75,7 +75,7 @@ public class AntClassLoader extends ClassLoader { /** * The classpath that is to be used when loading classes using this class loader. */ - private Path classpath; + private org.apache.tools.ant.types.Path classpath; /** * The project to which this class loader belongs. @@ -93,7 +93,8 @@ public class AntClassLoader extends ClassLoader { * @param project the project to ehich this classloader is to belong. * @param classpath the classpath to use to load the classes. */ - public AntClassLoader(Project project, Path classpath) { + public AntClassLoader(Project project, + org.apache.tools.ant.types.Path classpath) { this.project = project; this.classpath = classpath; } diff --git a/src/main/org/apache/tools/ant/IntrospectionHelper.java b/src/main/org/apache/tools/ant/IntrospectionHelper.java index bc0af59f9..b633237f9 100644 --- a/src/main/org/apache/tools/ant/IntrospectionHelper.java +++ b/src/main/org/apache/tools/ant/IntrospectionHelper.java @@ -54,6 +54,8 @@ package org.apache.tools.ant; +import org.apache.tools.ant.types.Path; + import java.lang.reflect.*; import java.io.File; import java.util.*; @@ -447,6 +449,16 @@ public class IntrospectionHelper { }; + // resolve relative paths through Project + } else if (org.apache.tools.ant.types.Path.class.equals(arg)) { + return new AttributeSetter() { + public void set(Project p, Object parent, String value) + throws InvocationTargetException, IllegalAccessException { + m.invoke(parent, new Path[] {new Path(p, value)}); + } + + }; + // EnumeratedAttributes have their own helper class } else if (org.apache.tools.ant.EnumeratedAttribute.class.isAssignableFrom(arg)) { return new AttributeSetter() { diff --git a/src/main/org/apache/tools/ant/Path.java b/src/main/org/apache/tools/ant/Path.java index fc90fdadd..e5ba3e77e 100644 --- a/src/main/org/apache/tools/ant/Path.java +++ b/src/main/org/apache/tools/ant/Path.java @@ -54,176 +54,18 @@ package org.apache.tools.ant; -import java.io.File; -import java.util.Vector; -import java.util.StringTokenizer; -import java.text.CharacterIterator; -import java.text.StringCharacterIterator; - /** - * This object represents a path as used by CLASSPATH or PATH - * environment variable. - * - * - * <sometask>
- *   <somepath> - *     <pathelement location="/path/to/file.jar" /> - *     <pathelement path="/path/to/file2.jar:/path/to/class2;/path/to/class3" /> - *     <pathelement location="/path/to/file3.jar" /> - *     <pathelement location="/path/to/file4.jar" /> - *   </somepath> - * </sometask>
- *
- * - * The object implemention sometask must provide a method called - * createSomepath which returns an instance of Path. - * Nested path definitions are handled by the Path object and must be labeled - * pathelement.

+ * This class has been moved to org.apache.tools.ant.types. * - * The path element takes a parameter path which will be parsed - * and split into single elements. It will usually be used - * to define a path from an environment variable. - * - * @author Thomas.Haas@softwired-inc.com - * @author Stefan Bodewig + * @deprecated This class has been moved to org.apache.tools.ant.types. */ -public class Path { - - private Vector definition; - - public static Path systemClasspath = - new Path(System.getProperty("java.class.path")); - - public Path(String path) { - this(); - setPath(path); - } - - public Path() { - definition = new Vector(); - } - - /** - * Adds a element definition to the path. - * @param location the location of the element to add (must not be - * null nor empty. - */ - public void setLocation(String location) { - if (location != null && location.length() > 0) { - String element = translateFile(location); - if (definition.indexOf(element) == -1) { - definition.addElement(element); - } - } - } - - - /** - * Append the contents of the other Path instance to this. - */ - public void append(Path other) { - String[] l = other.list(); - for (int i=0; iclasses.zip be added to the classpath. */ private Path getCompileClasspath(boolean addRuntime) { - Path classpath = new Path(); + Path classpath = new Path(project); // add dest dir to classpath so that previously compiled and // untouched classes are on classpath @@ -368,20 +371,23 @@ public class Javac extends MatchingTask { if (addRuntime) { if (Project.getJavaVersion() == Project.JAVA_1_1) { addExistingToClasspath(classpath, - new Path(System.getProperty("java.home") + new Path(null, + System.getProperty("java.home") + File.separator + "lib" + File.separator + "classes.zip")); } else { // JDK > 1.1 seems to set java.home to the JRE directory. addExistingToClasspath(classpath, - new Path(System.getProperty("java.home") + new Path(null, + System.getProperty("java.home") + File.separator + "lib" + File.separator + "rt.jar")); // Just keep the old version as well and let addExistingToPath // sort it out. addExistingToClasspath(classpath, - new Path(System.getProperty("java.home") + new Path(null, + System.getProperty("java.home") + File.separator +"jre" + File.separator + "lib" + File.separator + "rt.jar")); @@ -608,7 +614,7 @@ public class Javac extends MatchingTask { private void doJikesCompile() throws BuildException { log("Using jikes compiler", Project.MSG_VERBOSE); - Path classpath = new Path(); + Path classpath = new Path(project); // Jikes doesn't support bootclasspath dir (-bootclasspath) // so we'll emulate it for compatibility and convenience. diff --git a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java index 4993400fc..a06401716 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javadoc.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javadoc.java @@ -54,7 +54,10 @@ package org.apache.tools.ant.taskdefs; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.types.Path; import java.io.*; import java.util.*; @@ -137,7 +140,7 @@ public class Javadoc extends Exec { public Path createPath() { if (path == null) { - path = new Path(); + path = new Path(getProject()); } return path; } @@ -219,7 +222,7 @@ public class Javadoc extends Exec { } public Path createSourcepath() { if (sourcePath == null) { - sourcePath = new Path(); + sourcePath = new Path(project); } return sourcePath; } @@ -278,7 +281,7 @@ public class Javadoc extends Exec { } public Path createClasspath() { if (classpath == null) { - classpath = new Path(); + classpath = new Path(project); } return classpath; } @@ -291,7 +294,7 @@ public class Javadoc extends Exec { } public Path createBootclasspath() { if (bootclasspath == null) { - bootclasspath = new Path(); + bootclasspath = new Path(project); } return bootclasspath; } @@ -448,6 +451,10 @@ public class Javadoc extends Exec { } public void execute() throws BuildException { + if ("javadoc2".equals(taskType)) { + log("!! javadoc2 is deprecated. Use javadoc instead. !!"); + } + if (sourcePath == null || destDir == null ) { String msg = "sourcePath and destDir attributes must be set!"; throw new BuildException(msg); diff --git a/src/main/org/apache/tools/ant/taskdefs/Rmic.java b/src/main/org/apache/tools/ant/taskdefs/Rmic.java index 7920a7709..08cf076ce 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Rmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/Rmic.java @@ -54,7 +54,11 @@ package org.apache.tools.ant.taskdefs; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.types.Path; + import java.io.*; import java.util.StringTokenizer; import java.util.Vector; @@ -136,7 +140,7 @@ public class Rmic extends MatchingTask { */ public Path createClasspath() { if (compileClasspath == null) { - compileClasspath = new Path(); + compileClasspath = new Path(project); } return compileClasspath; } @@ -368,7 +372,7 @@ public class Rmic extends MatchingTask { private String getCompileClasspath(File baseFile) { // add dest dir to classpath so that previously compiled and // untouched classes are on classpath - Path classpath = new Path(baseFile.getAbsolutePath()); + Path classpath = new Path(project, baseFile.getAbsolutePath()); // add our classpath to the mix @@ -383,7 +387,7 @@ public class Rmic extends MatchingTask { if (Project.getJavaVersion().startsWith("1.2")) { String bootcp = System.getProperty("sun.boot.class.path"); if (bootcp != null) { - addExistingToClasspath(classpath, new Path(bootcp)); + addExistingToClasspath(classpath, new Path(project, bootcp)); } } return classpath.toString(); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java index 2c64913b7..4047b59ea 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DDCreator.java @@ -53,8 +53,11 @@ */ package org.apache.tools.ant.taskdefs.optional.ejb; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.*; +import org.apache.tools.ant.types.Path; import java.io.File; @@ -126,7 +129,7 @@ public class DDCreator extends MatchingTask { ddCreatorTask.setFork("yes"); ddCreatorTask.setClassname("org.apache.tools.ant.taskdefs.optional.ejb.DDCreatorHelper"); ddCreatorTask.setArgs(args); - ddCreatorTask.setClasspath(new Path(execClassPath)); + ddCreatorTask.setClasspath(new Path(project, execClassPath)); if (ddCreatorTask.executeJava() != 0) { throw new BuildException("Execution of ddcreator helper failed"); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java index dba337ea6..9e3737fdb 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/Ejbc.java @@ -54,8 +54,11 @@ package org.apache.tools.ant.taskdefs.optional.ejb; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.DirectoryScanner; +import org.apache.tools.ant.Project; import org.apache.tools.ant.taskdefs.*; +import org.apache.tools.ant.types.Path; import java.io.File; @@ -146,7 +149,7 @@ public class Ejbc extends MatchingTask { } helperTask.setArgs(args); - helperTask.setClasspath(new Path(execClassPath)); + helperTask.setClasspath(new Path(project, execClassPath)); if (helperTask.executeJava() != 0) { throw new BuildException("Execution of ejbc helper failed"); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java index f885f1aaf..212acdec0 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLRun.java @@ -54,8 +54,11 @@ package org.apache.tools.ant.taskdefs.optional.ejb; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.*; +import org.apache.tools.ant.types.Path; import java.io.File; @@ -156,7 +159,7 @@ public class WLRun extends Task { jvmArgs += " -Dweblogic.system.propertiesFile=" + weblogicPropertiesFile; weblogicServer.setJvmargs(jvmArgs); - weblogicServer.setClasspath(new Path(execClassPath)); + weblogicServer.setClasspath(new Path(project, execClassPath)); if (weblogicServer.executeJava() != 0) { throw new BuildException("Execution of weblogic server failed"); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLStop.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLStop.java index f575053a1..1add81d0a 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLStop.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WLStop.java @@ -54,8 +54,11 @@ package org.apache.tools.ant.taskdefs.optional.ejb; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.*; +import org.apache.tools.ant.types.Path; import java.io.File; @@ -116,7 +119,7 @@ public class WLStop extends Task { String args = serverURL + " SHUTDOWN " + username + " " + password + " " + delay; weblogicAdmin.setArgs(args); - weblogicAdmin.setClasspath(new Path(execClassPath)); + weblogicAdmin.setClasspath(new Path(project, execClassPath)); weblogicAdmin.execute(); } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java index 8b63b2b50..d6b8f0cdc 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/javacc/JavaCC.java @@ -54,10 +54,13 @@ package org.apache.tools.ant.taskdefs.optional.javacc; -import org.apache.tools.ant.*; +import org.apache.tools.ant.BuildException; +import org.apache.tools.ant.Project; +import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.*; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; +import org.apache.tools.ant.types.Path; import java.io.File; import java.io.IOException; @@ -68,7 +71,7 @@ import java.io.IOException; */ public class JavaCC extends Task { - private Path userclasspath = new Path(); + private Path userclasspath = null; private File metahome = null; private File metaworkingdir = null; private File target = null; @@ -89,6 +92,10 @@ public class JavaCC extends Task { } public Path createUserclasspath() { + if (userclasspath == null) { + userclasspath = new Path(project); + } + return userclasspath; } @@ -126,7 +133,7 @@ public class JavaCC extends Task { throw new BuildException("Userclasspath not set."); } - final Path classpath = cmdl.createClasspath(); + final Path classpath = cmdl.createClasspath(project); classpath.createPathElement().setLocation(metahome.getAbsolutePath() + "/lib/metamatadebug.jar"); classpath.createPathElement().setLocation(metahome.getAbsolutePath() + "/lib/metamata.jar"); classpath.createPathElement().setLocation(metahome.getAbsolutePath() + "/lib/JavaCC.zip"); diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java index 0605d9742..9091c8fc2 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java @@ -55,12 +55,12 @@ package org.apache.tools.ant.taskdefs.optional.junit; import org.apache.tools.ant.BuildException; -import org.apache.tools.ant.Path; import org.apache.tools.ant.Project; import org.apache.tools.ant.Task; import org.apache.tools.ant.taskdefs.*; import org.apache.tools.ant.types.Commandline; import org.apache.tools.ant.types.CommandlineJava; +import org.apache.tools.ant.types.Path; import java.io.File; import java.io.IOException; @@ -104,7 +104,7 @@ public class JUnitTask extends Task { * @param junit path to junit classes. */ public void setJunit(String junit) { - commandline.createClasspath().createPathElement().setLocation(junit); + commandline.createClasspath(project).createPathElement().setLocation(junit); } public void setDefaulthaltonerror(boolean value) { @@ -155,7 +155,7 @@ public class JUnitTask extends Task { public Path createClasspath() { - return commandline.createClasspath(); + return commandline.createClasspath(project); } public JUnitTest createTest() { @@ -189,7 +189,7 @@ public class JUnitTask extends Task { final String oldclasspath = System.getProperty("java.class.path"); - commandline.createClasspath().createPathElement().setPath(oldclasspath); + commandline.createClasspath(project).createPathElement().setPath(oldclasspath); /* * This doesn't work on JDK 1.1, should use a Classloader of our own * anyway --SB diff --git a/src/main/org/apache/tools/ant/types/CommandlineJava.java b/src/main/org/apache/tools/ant/types/CommandlineJava.java index 110496ec0..a004dc4c9 100644 --- a/src/main/org/apache/tools/ant/types/CommandlineJava.java +++ b/src/main/org/apache/tools/ant/types/CommandlineJava.java @@ -54,7 +54,7 @@ package org.apache.tools.ant.types; -import org.apache.tools.ant.Path; +import org.apache.tools.ant.Project; /* * @@ -64,7 +64,7 @@ public class CommandlineJava { private Commandline vmCommand = new Commandline(); private Commandline javaCommand = new Commandline(); - private Path classpath = new Path(); + private Path classpath = null; private String vmVersion; @@ -93,7 +93,10 @@ public class CommandlineJava { javaCommand.setExecutable(classname); } - public Path createClasspath() { + public Path createClasspath(Project p) { + if (classpath == null) { + classpath = new Path(p); + } return classpath; } @@ -103,14 +106,14 @@ public class CommandlineJava { public String[] getCommandline() { int size = vmCommand.size() + javaCommand.size(); - if (classpath.size() > 0) { + if (classpath != null && classpath.size() > 0) { size += 2; } String[] result = new String[size]; System.arraycopy(vmCommand.getCommandline(), 0, result, 0, vmCommand.size()); - if (classpath.size() > 0) { + if (classpath != null && classpath.size() > 0) { result[vmCommand.size()] = "-classpath"; result[vmCommand.size()+1] = classpath.toString(); } @@ -127,7 +130,7 @@ public class CommandlineJava { public int size() { int size = vmCommand.size() + javaCommand.size(); - if (classpath.size() > 0) { + if (classpath != null && classpath.size() > 0) { size += 2; } return size;