defined at another place in the same project. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267896 13f79535-47bb-0310-9956-ffa450edef68master
| @@ -61,6 +61,7 @@ import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.CommandlineJava; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Reference; | |||
| import java.io.File; | |||
| import java.io.IOException; | |||
| @@ -79,6 +80,7 @@ public class Java extends Task { | |||
| private boolean fork = false; | |||
| private File dir = null; | |||
| private boolean failOnError = false; | |||
| private Vector classpathReferences = new Vector(); | |||
| /** | |||
| * Do the execution. | |||
| @@ -137,6 +139,22 @@ public class Java extends Task { | |||
| return cmdl.createClasspath(project); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void addClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void setClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Set the class name. | |||
| */ | |||
| @@ -218,7 +236,10 @@ public class Java extends Task { | |||
| private void run(CommandlineJava command) throws BuildException { | |||
| ExecuteJava exe = new ExecuteJava(); | |||
| exe.setJavaCommand(command.getJavaCommand()); | |||
| exe.setClasspath(command.getClasspath()); | |||
| Path p = new Path(project); | |||
| p.append(command.getClasspath()); | |||
| addReferencesToPath(classpathReferences, p); | |||
| exe.setClasspath(p); | |||
| exe.execute(project); | |||
| } | |||
| @@ -252,10 +273,33 @@ public class Java extends Task { | |||
| for (int i=0; i<args.size(); i++) { | |||
| cmdj.createArgument().setValue((String) args.elementAt(i)); | |||
| } | |||
| if (cmdl.getClasspath() != null) { | |||
| cmdj.createClasspath(project).append(cmdl.getClasspath()); | |||
| if (cmdl.getClasspath() != null || classpathReferences.size() > 0) { | |||
| Path p = cmdj.createClasspath(project); | |||
| if (cmdl.getClasspath() != null) { | |||
| p.append(cmdl.getClasspath()); | |||
| } | |||
| addReferencesToPath(classpathReferences, p); | |||
| } | |||
| run(cmdj); | |||
| } | |||
| /** | |||
| * Appends the referenced Path instances to the other path. | |||
| * | |||
| * @param v Vector of Reference objects referring to Path objects. | |||
| * @param p Path to append to. | |||
| */ | |||
| private void addReferencesToPath(Vector v, Path p) { | |||
| for (int i=0; i<v.size(); i++) { | |||
| Reference r = (Reference) v.elementAt(i); | |||
| Object o = r.getReferencedObject(project); | |||
| if (o instanceof Path) { | |||
| p.append((Path) o); | |||
| } else { | |||
| String msg = r.getRefId()+" doesn\'t denote a classpath"; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -100,11 +100,13 @@ public class Javac extends MatchingTask { | |||
| private Path src; | |||
| private File destDir; | |||
| private Path compileClasspath; | |||
| private Vector classpathReferences = new Vector(); | |||
| private boolean debug = false; | |||
| private boolean optimize = false; | |||
| private boolean deprecation = false; | |||
| private String target; | |||
| private Path bootclasspath; | |||
| private Vector bootClasspathReferences = new Vector(); | |||
| private Path extdirs; | |||
| private static String lSep = System.getProperty("line.separator"); | |||
| @@ -163,6 +165,22 @@ public class Javac extends MatchingTask { | |||
| return compileClasspath; | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void addClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void setClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Sets the bootclasspath that will be used to compile the classes | |||
| * against. | |||
| @@ -185,6 +203,22 @@ public class Javac extends MatchingTask { | |||
| return bootclasspath; | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void addBootClasspathRef(Reference r) { | |||
| bootClasspathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void setBootClasspathRef(Reference r) { | |||
| bootClasspathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Sets the extension directories that will be used during the | |||
| * compilation. | |||
| @@ -355,6 +389,7 @@ public class Javac extends MatchingTask { | |||
| if (compileClasspath != null) { | |||
| addExistingToClasspath(classpath,compileClasspath); | |||
| } | |||
| addReferencesToPath(classpathReferences, classpath); | |||
| // add the system classpath | |||
| @@ -505,7 +540,8 @@ public class Javac extends MatchingTask { | |||
| if (optimize) { | |||
| cmd.createArgument().setValue("-O"); | |||
| } | |||
| if (bootclasspath != null) { | |||
| if (bootclasspath != null || bootClasspathReferences.size() > 0) { | |||
| addReferencesToPath(bootClasspathReferences, createBootclasspath()); | |||
| cmd.createArgument().setValue("-bootclasspath"); | |||
| cmd.createArgument().setPath(bootclasspath); | |||
| } | |||
| @@ -559,7 +595,8 @@ public class Javac extends MatchingTask { | |||
| // Jikes doesn't support bootclasspath dir (-bootclasspath) | |||
| // so we'll emulate it for compatibility and convenience. | |||
| if (bootclasspath != null) { | |||
| if (bootclasspath != null || bootClasspathReferences.size() > 0) { | |||
| addReferencesToPath(bootClasspathReferences, createBootclasspath()); | |||
| classpath.append(bootclasspath); | |||
| } | |||
| @@ -713,7 +750,7 @@ public class Javac extends MatchingTask { | |||
| /** | |||
| * Emulation of extdirs feature in java >= 1.2. | |||
| * This method adds all file in the given | |||
| * This method adds all files in the given | |||
| * directories (but not in sub-directories!) to the classpath, | |||
| * so that you don't have to specify them all one by one. | |||
| * @param classpath - Path to append files to | |||
| @@ -740,5 +777,25 @@ public class Javac extends MatchingTask { | |||
| classpath.addFileset(fs); | |||
| } | |||
| } | |||
| /** | |||
| * Appends the referenced Path instances to the other path. | |||
| * | |||
| * @param v Vector of Reference objects referring to Path objects. | |||
| * @param p Path to append to. | |||
| */ | |||
| private void addReferencesToPath(Vector v, Path p) { | |||
| for (int i=0; i<v.size(); i++) { | |||
| Reference r = (Reference) v.elementAt(i); | |||
| Object o = r.getReferencedObject(project); | |||
| if (o instanceof Path) { | |||
| p.append((Path) o); | |||
| } else { | |||
| String msg = r.getRefId()+" doesn\'t denote a classpath"; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @@ -60,6 +60,7 @@ import org.apache.tools.ant.Project; | |||
| import org.apache.tools.ant.Task; | |||
| import org.apache.tools.ant.types.Commandline; | |||
| import org.apache.tools.ant.types.Path; | |||
| import org.apache.tools.ant.types.Reference; | |||
| import java.io.*; | |||
| import java.util.*; | |||
| @@ -119,7 +120,8 @@ public class Javadoc extends Task { | |||
| private Path path; | |||
| private Vector params = new Vector(); | |||
| private Vector pathRefs = new Vector(); | |||
| public void setName(String name) { | |||
| this.name = name; | |||
| } | |||
| @@ -137,6 +139,7 @@ public class Javadoc extends Task { | |||
| } | |||
| public Path getPath() { | |||
| addReferencesToPath(pathRefs, path); | |||
| return path; | |||
| } | |||
| @@ -147,6 +150,22 @@ public class Javadoc extends Task { | |||
| return path; | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <pathref> element. | |||
| */ | |||
| public void addPathRef(Reference r) { | |||
| pathRefs.addElement(r); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <pathref> element. | |||
| */ | |||
| public void setPathRef(Reference r) { | |||
| pathRefs.addElement(r); | |||
| } | |||
| public DocletParam createParam() { | |||
| DocletParam param = new DocletParam(); | |||
| params.addElement(param); | |||
| @@ -196,7 +215,9 @@ public class Javadoc extends Task { | |||
| private String packageList = null; | |||
| private Vector links = new Vector(2); | |||
| private Vector groups = new Vector(2); | |||
| private Vector classpathReferences = new Vector(); | |||
| private Vector bootClasspathReferences = new Vector(); | |||
| private Vector sourcepathReferences = new Vector(); | |||
| public void setMaxmemory(String max){ | |||
| if(javadoc1){ | |||
| @@ -223,6 +244,22 @@ public class Javadoc extends Task { | |||
| } | |||
| return sourcePath; | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <sourcepathref> element. | |||
| */ | |||
| public void addSourcepathRef(Reference r) { | |||
| sourcepathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <sourcepathref> element. | |||
| */ | |||
| public void setSourcepathRef(Reference r) { | |||
| sourcepathReferences.addElement(r); | |||
| } | |||
| public void setDestdir(File dir) { | |||
| cmd.createArgument().setValue("-d"); | |||
| cmd.createArgument().setFile(dir); | |||
| @@ -266,6 +303,13 @@ public class Javadoc extends Task { | |||
| doclet.setPath(src); | |||
| } | |||
| public void setDocletPathRef(Reference r) { | |||
| if (doclet == null) { | |||
| doclet = new DocletInfo(); | |||
| } | |||
| doclet.setPathRef(r); | |||
| } | |||
| public DocletInfo createDoclet() { | |||
| doclet = new DocletInfo(); | |||
| return doclet; | |||
| @@ -287,6 +331,22 @@ public class Javadoc extends Task { | |||
| } | |||
| return classpath; | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void addClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void setClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| public void setBootclasspath(Path src) { | |||
| if (bootclasspath == null) { | |||
| bootclasspath = src; | |||
| @@ -300,6 +360,22 @@ public class Javadoc extends Task { | |||
| } | |||
| return bootclasspath; | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <bootclasspathref> element. | |||
| */ | |||
| public void addBootClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <bootclasspathref> element. | |||
| */ | |||
| public void setBootClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| public void setExtdirs(String src) { | |||
| if (!javadoc1) { | |||
| cmd.createArgument().setValue("-extdirs"); | |||
| @@ -522,14 +598,14 @@ public class Javadoc extends Task { | |||
| if (classpath == null) | |||
| classpath = Path.systemClasspath; | |||
| addReferencesToPath(classpathReferences, classpath); | |||
| addReferencesToPath(sourcepathReferences, sourcePath); | |||
| if ( (!javadoc1) || (sourcePath == null) ) { | |||
| if (!javadoc1) { | |||
| cmd.createArgument().setValue("-classpath"); | |||
| cmd.createArgument().setPath(classpath); | |||
| if (sourcePath != null) { | |||
| cmd.createArgument().setValue("-sourcepath"); | |||
| cmd.createArgument().setPath(sourcePath); | |||
| } | |||
| cmd.createArgument().setValue("-sourcepath"); | |||
| cmd.createArgument().setPath(sourcePath); | |||
| } else { | |||
| cmd.createArgument().setValue("-classpath"); | |||
| cmd.createArgument().setValue(sourcePath.toString() + | |||
| @@ -570,7 +646,9 @@ public class Javadoc extends Task { | |||
| } | |||
| } | |||
| } | |||
| if (bootclasspath != null) { | |||
| if (bootclasspath != null || bootClasspathReferences.size() > 0) { | |||
| addReferencesToPath(bootClasspathReferences, | |||
| createBootclasspath()); | |||
| cmd.createArgument().setValue("-bootclasspath"); | |||
| cmd.createArgument().setPath(bootclasspath); | |||
| } | |||
| @@ -694,6 +772,25 @@ public class Javadoc extends Task { | |||
| } | |||
| } | |||
| /** | |||
| * Appends the referenced Path instances to the other path. | |||
| * | |||
| * @param v Vector of Reference objects referring to Path objects. | |||
| * @param p Path to append to. | |||
| */ | |||
| private void addReferencesToPath(Vector v, Path p) { | |||
| for (int i=0; i<v.size(); i++) { | |||
| Reference r = (Reference) v.elementAt(i); | |||
| Object o = r.getReferencedObject(project); | |||
| if (o instanceof Path) { | |||
| p.append((Path) o); | |||
| } else { | |||
| String msg = r.getRefId()+" doesn\'t denote a classpath"; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| } | |||
| } | |||
| /** | |||
| * Given a source path, a list of package patterns, fill the given list | |||
| * with the packages found in that path subdirs matching one of the given | |||
| @@ -58,6 +58,7 @@ 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 org.apache.tools.ant.types.Reference; | |||
| import java.io.*; | |||
| import java.util.StringTokenizer; | |||
| @@ -96,6 +97,7 @@ public class Rmic extends MatchingTask { | |||
| private boolean filtering = false; | |||
| private Vector compileList = new Vector(); | |||
| private Vector classpathReferences = new Vector(); | |||
| public void setBase(String base) { | |||
| this.base = base; | |||
| @@ -136,7 +138,7 @@ public class Rmic extends MatchingTask { | |||
| } | |||
| /** | |||
| * Maybe creates a nesetd classpath element. | |||
| * Maybe creates a nested classpath element. | |||
| */ | |||
| public Path createClasspath() { | |||
| if (compileClasspath == null) { | |||
| @@ -145,11 +147,26 @@ public class Rmic extends MatchingTask { | |||
| return compileClasspath; | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void addClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Adds a reference to a CLASSPATH defined elsewhere - nested | |||
| * <classpathref> element. | |||
| */ | |||
| public void setClasspathRef(Reference r) { | |||
| classpathReferences.addElement(r); | |||
| } | |||
| /** | |||
| * Indicates that the classes found by the directory match should be | |||
| * checked to see if they implement java.rmi.Remote. | |||
| * This defaults to false if not set. | |||
| */ | |||
| * This defaults to false if not set. */ | |||
| public void setVerify(String verify) { | |||
| this.verify = Project.toBoolean(verify); | |||
| } | |||
| @@ -170,7 +187,19 @@ public class Rmic extends MatchingTask { | |||
| if (null != sourceBase) { | |||
| sourceBaseFile = project.resolveFile(sourceBase); | |||
| } | |||
| String classpath = getCompileClasspath(baseDir); | |||
| Path classpath = getCompileClasspath(baseDir); | |||
| for (int i=0; i<classpathReferences.size(); i++) { | |||
| Reference r = (Reference) classpathReferences.elementAt(i); | |||
| Object o = r.getReferencedObject(project); | |||
| if (o instanceof Path) { | |||
| classpath.append((Path) o); | |||
| } else { | |||
| String msg = r.getRefId()+" doesn\'t denote a classpath"; | |||
| throw new BuildException(msg, location); | |||
| } | |||
| } | |||
| // scan base dirs to build up compile lists only if a | |||
| // specific classname is not given | |||
| @@ -193,7 +222,7 @@ public class Rmic extends MatchingTask { | |||
| args[i++] = "-d"; | |||
| args[i++] = baseDir.getAbsolutePath(); | |||
| args[i++] = "-classpath"; | |||
| args[i++] = classpath; | |||
| args[i++] = classpath.toString(); | |||
| if (null != stubVersion) { | |||
| if ("1.1".equals(stubVersion)) | |||
| args[i++] = "-v1.1"; | |||
| @@ -369,7 +398,7 @@ public class Rmic extends MatchingTask { | |||
| // XXX | |||
| // we need a way to not use the current classpath. | |||
| private String getCompileClasspath(File baseFile) { | |||
| private Path getCompileClasspath(File baseFile) { | |||
| // add dest dir to classpath so that previously compiled and | |||
| // untouched classes are on classpath | |||
| Path classpath = new Path(project, baseFile.getAbsolutePath()); | |||
| @@ -390,7 +419,7 @@ public class Rmic extends MatchingTask { | |||
| addExistingToClasspath(classpath, new Path(project, bootcp)); | |||
| } | |||
| } | |||
| return classpath.toString(); | |||
| return classpath; | |||
| } | |||
| /** | |||
| @@ -108,7 +108,6 @@ public class Commandline { | |||
| public class Argument { | |||
| private String[] parts; | |||
| private Reference pathRef; | |||
| /** | |||
| * Sets a single commandline argument. | |||