Browse Source

Removed all nested <classpathref> elements in favor of <classpath

refid="...">.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267970 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
ff810113da
8 changed files with 61 additions and 290 deletions
  1. +7
    -5
      build.xml
  2. +11
    -21
      docs/index.html
  3. +2
    -4
      docs/junit.html
  4. +4
    -43
      src/main/org/apache/tools/ant/taskdefs/Java.java
  5. +11
    -54
      src/main/org/apache/tools/ant/taskdefs/Javac.java
  6. +14
    -76
      src/main/org/apache/tools/ant/taskdefs/Javadoc.java
  7. +11
    -64
      src/main/org/apache/tools/ant/taskdefs/Rmic.java
  8. +1
    -23
      src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java

+ 7
- 5
build.xml View File

@@ -27,7 +27,8 @@
<property name="build.tests" value="${build.dir}/testcases"/> <property name="build.tests" value="${build.dir}/testcases"/>
<property name="ant.dist.dir" value="../dist/ant"/> <property name="ant.dist.dir" value="../dist/ant"/>


<property name="classpath" value=""/>
<path id="classpath">
</path>
<property name="packages" value="org.apache.tools.*"/> <property name="packages" value="org.apache.tools.*"/>
<property name="manifest" value="src/etc/manifest"/> <property name="manifest" value="src/etc/manifest"/>


@@ -79,10 +80,11 @@


<javac srcdir="${src.dir}" <javac srcdir="${src.dir}"
destdir="${build.classes}" destdir="${build.classes}"
classpath="${classpath}"
debug="on" debug="on"
deprecation="off" deprecation="off"
optimize="on" > optimize="on" >
<classpath refid="classpath" />

<exclude name="**/Script.java" unless="bsf.present" /> <exclude name="**/Script.java" unless="bsf.present" />
<exclude name="**/NetRexxC.java" unless="netrexx.present" /> <exclude name="**/NetRexxC.java" unless="netrexx.present" />
<exclude name="**/XslpLiaison.java" unless="xslp.present" /> <exclude name="**/XslpLiaison.java" unless="xslp.present" />
@@ -282,7 +284,7 @@
optimize="on" > optimize="on" >
<classpath> <classpath>
<pathelement location="${lib.dir}/${name}.jar" /> <pathelement location="${lib.dir}/${name}.jar" />
<pathelement path="${classpath}" />
<path refid="classpath" />
</classpath> </classpath>
<include name="**/*.java"/> <include name="**/*.java"/>
<exclude name="**/AllJUnitTests.java" unless="junit.present" /> <exclude name="**/AllJUnitTests.java" unless="junit.present" />
@@ -308,7 +310,7 @@
<classpath> <classpath>
<pathelement location="${lib.dir}/${name}.jar" /> <pathelement location="${lib.dir}/${name}.jar" />
<pathelement location="${build.tests}" /> <pathelement location="${build.tests}" />
<pathelement path="${classpath}" />
<path refid="classpath" />
<pathelement path="${java.class.path}" /> <pathelement path="${java.class.path}" />
</classpath> </classpath>


@@ -328,7 +330,7 @@
<classpath> <classpath>
<pathelement location="${lib.dir}/${name}.jar" /> <pathelement location="${lib.dir}/${name}.jar" />
<pathelement location="${build.tests}" /> <pathelement location="${build.tests}" />
<pathelement path="${classpath}" />
<path refid="classpath" />
<pathelement path="${java.class.path}" /> <pathelement path="${java.class.path}" />
</classpath> </classpath>
</java> </java>


+ 11
- 21
docs/index.html View File

@@ -573,13 +573,13 @@ example.</p>


&lt;target ... &gt; &lt;target ... &gt;
&lt;rmic ...&gt; &lt;rmic ...&gt;
&lt;classpathref refid=&quot;project.class.path&quot; /&gt;
&lt;classpath refid=&quot;project.class.path&quot; /&gt;
&lt;/rmic&gt; &lt;/rmic&gt;
&lt;/target&gt; &lt;/target&gt;


&lt;target ... &gt; &lt;target ... &gt;
&lt;javac ...&gt; &lt;javac ...&gt;
&lt;classpathref refid=&quot;project.class.path&quot; /&gt;
&lt;classpath refid=&quot;project.class.path&quot; /&gt;
&lt;/javac&gt; &lt;/javac&gt;
&lt;/target&gt; &lt;/target&gt;
&lt;/project&gt; &lt;/project&gt;
@@ -2263,12 +2263,10 @@ the one that is currently running Ant.</p>
<p>Use nested <code>&lt;arg&gt;</code> and <code>&lt;jvmarg&gt;</code> <p>Use nested <code>&lt;arg&gt;</code> and <code>&lt;jvmarg&gt;</code>
elements to specify arguments for the or the forked VM. See <a elements to specify arguments for the or the forked VM. See <a
href="index.html#arg">Command line arguments</a>.</p> href="index.html#arg">Command line arguments</a>.</p>
<h4>classpath and classpathref</h4>
<h4>classpath</h4>
<p><code>Java</code>'s <em>classpath</em> attribute is a <a <p><code>Java</code>'s <em>classpath</em> attribute is a <a
href="#path">PATH like structure</a> and can also be set via a nested href="#path">PATH like structure</a> and can also be set via a nested
<em>classpath</em> element. PATHs defined elsewhere can be
<a href="#references">referred</a> to via nested <em>classpathref</em>
elements.</p>
<em>classpath</em> element.</p>
<h5>Example</h5> <h5>Example</h5>
<pre> <pre>
&lt;java classname=&quot;test.Main&quot; &gt; &lt;java classname=&quot;test.Main&quot; &gt;
@@ -2429,14 +2427,12 @@ supports all attributes of <code>&lt;fileset&gt;</code>
<code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>, <code>&lt;include&gt;</code>, <code>&lt;exclude&gt;</code>,
<code>&lt;patternset&gt;</code> and <code>&lt;patternsetref&gt;</code> <code>&lt;patternset&gt;</code> and <code>&lt;patternsetref&gt;</code>
elements.</p> elements.</p>
<h4>src, classpath, classpathref, bootclasspath, bootclasspathref and extdirs</h4>
<h4>src, classpath, bootclasspath and extdirs</h4>
<p><code>Javac</code>'s <em>srcdir</em>, <em>classpath</em>, <p><code>Javac</code>'s <em>srcdir</em>, <em>classpath</em>,
<em>bootclasspath</em> and <em>extdirs</em> attributes are <a <em>bootclasspath</em> and <em>extdirs</em> attributes are <a
href="#path">PATH like structure</a> and can also be set via nested href="#path">PATH like structure</a> and can also be set via nested
<em>src</em>, <em>classpath</em>, <em>bootclasspath</em> and <em>src</em>, <em>classpath</em>, <em>bootclasspath</em> and
<em>extdirs</em> elements respectively. PATHs defined elsewhere can be
<a href="#references">referred</a> to via nested <em>classpathref</em>
and <em>bootclasspathref</em> elements.</p>
<em>extdirs</em> elements respectively.</p>


<h3>Examples</h3> <h3>Examples</h3>
<pre> &lt;javac srcdir=&quot;${src}&quot; <pre> &lt;javac srcdir=&quot;${src}&quot;
@@ -2525,8 +2521,7 @@ instead.</p>
<td valign="top">Specify where to find source files</td> <td valign="top">Specify where to find source files</td>
<td align="center" valign="top">all</td> <td align="center" valign="top">all</td>
<td align="center" rowspan="2">At least one of the two or nested <td align="center" rowspan="2">At least one of the two or nested
<code>&lt;sourcepath&gt;</code> or
<code>&lt;sourcepathref&gt;</code></td>
<code>&lt;sourcepath&gt;</code></td>
</tr> </tr>
<tr> <tr>
<td valign="top">sourcepathref</td> <td valign="top">sourcepathref</td>
@@ -2885,15 +2880,12 @@ arguments.</p>
</tr> </tr>
</table> </table>


<h4>sourcepath, classpath, bootclasspath, sourcepathref, classpathref
and bootclasspathref</h4>
<h4>sourcepath, classpath and bootclasspath</h4>
<p><code>Javadoc</code>'s <em>sourcepath</em>, <em>classpath</em> and <p><code>Javadoc</code>'s <em>sourcepath</em>, <em>classpath</em> and
<em>bootclasspath</em> attributes are <a href="#path">PATH like <em>bootclasspath</em> attributes are <a href="#path">PATH like
structure</a> and can also be set via nested <em>sourcepath</em>, structure</a> and can also be set via nested <em>sourcepath</em>,
<em>classpath</em> and <em>bootclasspath</em> elements <em>classpath</em> and <em>bootclasspath</em> elements
respectively. PATHs defined elsewhere can be <a
href="#references">referred</a> to via nested <em>sourcepathref</em>,
<em>classpathref</em> and <em>bootclasspathref</em> elements.</p>
respectively.</p>


<h3>Example</h3> <h3>Example</h3>
<pre> &lt;javadoc packagenames=&quot;com.dummy.test.*&quot; <pre> &lt;javadoc packagenames=&quot;com.dummy.test.*&quot;
@@ -3300,12 +3292,10 @@ elements.</p>
</tr> </tr>
</table> </table>
<h3>Parameters specified as nested elements</h3> <h3>Parameters specified as nested elements</h3>
<h4>classpath and classpathref</h4>
<h4>classpath</h4>
<p><code>Rmic</code>'s <em>classpath</em> attribute is a <a <p><code>Rmic</code>'s <em>classpath</em> attribute is a <a
href="#path">PATH like structure</a> and can also be set via a nested href="#path">PATH like structure</a> and can also be set via a nested
<em>classpath</em> elements. PATHs defined elsewhere can be
<a href="#references">referred</a> to via nested <em>classpathref</em>
elements.</p>
<em>classpath</em> elements.</p>
<h3>Examples</h3> <h3>Examples</h3>
<pre> &lt;rmic classname=&quot;com.xyz.FooBar&quot; base=&quot;${build}/classes&quot; /&gt;</pre> <pre> &lt;rmic classname=&quot;com.xyz.FooBar&quot; base=&quot;${build}/classes&quot; /&gt;</pre>
<p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The <p>runs the rmic compiler for the class <code>com.xyz.FooBar</code>. The


+ 2
- 4
docs/junit.html View File

@@ -70,10 +70,8 @@ elements</a>.</p>


<p><code>junit</code> supports a nested <code>&lt;classpath&gt;</code> <p><code>junit</code> supports a nested <code>&lt;classpath&gt;</code>
element, that represents a <a href="index.html#path">PATH like element, that represents a <a href="index.html#path">PATH like
structure</a>. PATHs defined elsewhere can be <a
href="index.html#references">referred</a> to via nested
<code>&lt;classpathref&gt;</code> elements. The value is ignored if
<code>fork</code> is disabled.</p>
structure</a>. The value is ignored if <code>fork</code> is
disabled.</p>


<h4>jvmarg</h4> <h4>jvmarg</h4>




+ 4
- 43
src/main/org/apache/tools/ant/taskdefs/Java.java View File

@@ -80,7 +80,6 @@ public class Java extends Task {
private boolean fork = false; private boolean fork = false;
private File dir = null; private File dir = null;
private boolean failOnError = false; private boolean failOnError = false;
private Vector classpathReferences = new Vector();
/** /**
* Do the execution. * Do the execution.
@@ -136,23 +135,14 @@ public class Java extends Task {
* Creates a nested classpath element * Creates a nested classpath element
*/ */
public Path createClasspath() { public Path createClasspath() {
return cmdl.createClasspath(project);
return cmdl.createClasspath(project).createPath();
} }


/** /**
* 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.
* Adds a reference to a CLASSPATH defined elsewhere.
*/ */
public void setClasspathRef(Reference r) { public void setClasspathRef(Reference r) {
classpathReferences.addElement(r);
createClasspath().setRefid(r);
} }


/** /**
@@ -242,10 +232,7 @@ public class Java extends Task {
private void run(CommandlineJava command) throws BuildException { private void run(CommandlineJava command) throws BuildException {
ExecuteJava exe = new ExecuteJava(); ExecuteJava exe = new ExecuteJava();
exe.setJavaCommand(command.getJavaCommand()); exe.setJavaCommand(command.getJavaCommand());
Path p = new Path(project);
p.append(command.getClasspath());
addReferencesToPath(classpathReferences, p);
exe.setClasspath(p);
exe.setClasspath(command.getClasspath());
exe.execute(project); exe.execute(project);
} }


@@ -279,33 +266,7 @@ public class Java extends Task {
for (int i=0; i<args.size(); i++) { for (int i=0; i<args.size(); i++) {
cmdj.createArgument().setValue((String) args.elementAt(i)); cmdj.createArgument().setValue((String) args.elementAt(i));
} }
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); 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);
}
}
}
} }

+ 11
- 54
src/main/org/apache/tools/ant/taskdefs/Javac.java View File

@@ -102,13 +102,11 @@ public class Javac extends MatchingTask {
private File destDir; private File destDir;
private Path compileClasspath; private Path compileClasspath;
private String encoding; private String encoding;
private Vector classpathReferences = new Vector();
private boolean debug = false; private boolean debug = false;
private boolean optimize = false; private boolean optimize = false;
private boolean deprecation = false; private boolean deprecation = false;
private String target; private String target;
private Path bootclasspath; private Path bootclasspath;
private Vector bootClasspathReferences = new Vector();
private Path extdirs; private Path extdirs;
private static String lSep = System.getProperty("line.separator"); private static String lSep = System.getProperty("line.separator");


@@ -124,7 +122,7 @@ public class Javac extends MatchingTask {
if (src == null) { if (src == null) {
src = new Path(project); src = new Path(project);
} }
return src;
return src.createPath();
} }


/** /**
@@ -164,23 +162,14 @@ public class Javac extends MatchingTask {
if (compileClasspath == null) { if (compileClasspath == null) {
compileClasspath = new Path(project); compileClasspath = new Path(project);
} }
return compileClasspath;
return compileClasspath.createPath();
} }


/** /**
* 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.
* Adds a reference to a CLASSPATH defined elsewhere.
*/ */
public void setClasspathRef(Reference r) { public void setClasspathRef(Reference r) {
classpathReferences.addElement(r);
createClasspath().setRefid(r);
} }


/** /**
@@ -202,23 +191,14 @@ public class Javac extends MatchingTask {
if (bootclasspath == null) { if (bootclasspath == null) {
bootclasspath = new Path(project); bootclasspath = new Path(project);
} }
return bootclasspath;
}

/**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <classpathref> element.
*/
public void addBootClasspathRef(Reference r) {
bootClasspathReferences.addElement(r);
return bootclasspath.createPath();
} }


/** /**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <classpathref> element.
* Adds a reference to a CLASSPATH defined elsewhere.
*/ */
public void setBootClasspathRef(Reference r) { public void setBootClasspathRef(Reference r) {
bootClasspathReferences.addElement(r);
createBootclasspath().setRefid(r);
} }


/** /**
@@ -240,7 +220,7 @@ public class Javac extends MatchingTask {
if (extdirs == null) { if (extdirs == null) {
extdirs = new Path(project); extdirs = new Path(project);
} }
return extdirs;
return extdirs.createPath();
} }


/** /**
@@ -408,7 +388,6 @@ public class Javac extends MatchingTask {
if (compileClasspath != null) { if (compileClasspath != null) {
classpath.addExisting(compileClasspath); classpath.addExisting(compileClasspath);
} }
addReferencesToPath(classpathReferences, classpath);


// add the system classpath // add the system classpath


@@ -534,8 +513,7 @@ public class Javac extends MatchingTask {
if (optimize) { if (optimize) {
cmd.createArgument().setValue("-O"); cmd.createArgument().setValue("-O");
} }
if (bootclasspath != null || bootClasspathReferences.size() > 0) {
addReferencesToPath(bootClasspathReferences, createBootclasspath());
if (bootclasspath != null) {
cmd.createArgument().setValue("-bootclasspath"); cmd.createArgument().setValue("-bootclasspath");
cmd.createArgument().setPath(bootclasspath); cmd.createArgument().setPath(bootclasspath);
} }
@@ -589,8 +567,7 @@ public class Javac extends MatchingTask {


// Jikes doesn't support bootclasspath dir (-bootclasspath) // Jikes doesn't support bootclasspath dir (-bootclasspath)
// so we'll emulate it for compatibility and convenience. // so we'll emulate it for compatibility and convenience.
if (bootclasspath != null || bootClasspathReferences.size() > 0) {
addReferencesToPath(bootClasspathReferences, createBootclasspath());
if (bootclasspath != null) {
classpath.append(bootclasspath); classpath.append(bootclasspath);
} }


@@ -776,25 +753,6 @@ public class Javac extends MatchingTask {
} }
} }


/**
* 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);
}
}
}
private void doJvcCompile() throws BuildException { private void doJvcCompile() throws BuildException {
log("Using jvc compiler", Project.MSG_VERBOSE); log("Using jvc compiler", Project.MSG_VERBOSE);


@@ -802,8 +760,7 @@ public class Javac extends MatchingTask {


// jvc doesn't support bootclasspath dir (-bootclasspath) // jvc doesn't support bootclasspath dir (-bootclasspath)
// so we'll emulate it for compatibility and convenience. // so we'll emulate it for compatibility and convenience.
if (bootclasspath != null || bootClasspathReferences.size() > 0) {
addReferencesToPath(bootClasspathReferences, createBootclasspath());
if (bootclasspath != null) {
classpath.append(bootclasspath); classpath.append(bootclasspath);
} }




+ 14
- 76
src/main/org/apache/tools/ant/taskdefs/Javadoc.java View File

@@ -120,7 +120,6 @@ public class Javadoc extends Task {
private Path path; private Path path;
private Vector params = new Vector(); private Vector params = new Vector();
private Vector pathRefs = new Vector();


public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
@@ -139,7 +138,6 @@ public class Javadoc extends Task {
} }


public Path getPath() { public Path getPath() {
addReferencesToPath(pathRefs, path);
return path; return path;
} }
@@ -147,23 +145,14 @@ public class Javadoc extends Task {
if (path == null) { if (path == null) {
path = new Path(getProject()); path = new Path(getProject());
} }
return path;
}

/**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <pathref> element.
*/
public void addPathRef(Reference r) {
pathRefs.addElement(r);
return path.createPath();
} }


/** /**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <pathref> element.
* Adds a reference to a CLASSPATH defined elsewhere.
*/ */
public void setPathRef(Reference r) { public void setPathRef(Reference r) {
pathRefs.addElement(r);
createPath().setRefid(r);
} }


public DocletParam createParam() { public DocletParam createParam() {
@@ -216,9 +205,6 @@ public class Javadoc extends Task {
private String packageList = null; private String packageList = null;
private Vector links = new Vector(2); private Vector links = new Vector(2);
private Vector groups = 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){ public void setMaxmemory(String max){
if(javadoc1){ if(javadoc1){
@@ -243,22 +229,14 @@ public class Javadoc extends Task {
if (sourcePath == null) { if (sourcePath == null) {
sourcePath = new Path(project); sourcePath = new Path(project);
} }
return sourcePath;
}
/**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <sourcepathref> element.
*/
public void addSourcepathRef(Reference r) {
sourcepathReferences.addElement(r);
return sourcePath.createPath();
} }


/** /**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <sourcepathref> element.
* Adds a reference to a CLASSPATH defined elsewhere.
*/ */
public void setSourcepathRef(Reference r) { public void setSourcepathRef(Reference r) {
sourcepathReferences.addElement(r);
createSourcepath().setRefid(r);
} }


public void setDestdir(File dir) { public void setDestdir(File dir) {
@@ -306,7 +284,7 @@ public class Javadoc extends Task {
if (doclet == null) { if (doclet == null) {
doclet = new DocletInfo(); doclet = new DocletInfo();
} }
doclet.setPathRef(r);
doclet.createPath().setRefid(r);
} }


public DocletInfo createDoclet() { public DocletInfo createDoclet() {
@@ -328,22 +306,14 @@ public class Javadoc extends Task {
if (classpath == null) { if (classpath == null) {
classpath = new Path(project); classpath = new Path(project);
} }
return classpath;
}
/**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <classpathref> element.
*/
public void addClasspathRef(Reference r) {
classpathReferences.addElement(r);
return classpath.createPath();
} }


/** /**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <classpathref> element.
* Adds a reference to a CLASSPATH defined elsewhere.
*/ */
public void setClasspathRef(Reference r) { public void setClasspathRef(Reference r) {
classpathReferences.addElement(r);
createClasspath().setRefid(r);
} }


public void setBootclasspath(Path src) { public void setBootclasspath(Path src) {
@@ -357,22 +327,14 @@ public class Javadoc extends Task {
if (bootclasspath == null) { if (bootclasspath == null) {
bootclasspath = new Path(project); bootclasspath = new Path(project);
} }
return bootclasspath;
}
/**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <bootclasspathref> element.
*/
public void addBootClasspathRef(Reference r) {
classpathReferences.addElement(r);
return bootclasspath.createPath();
} }


/** /**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <bootclasspathref> element.
* Adds a reference to a CLASSPATH defined elsewhere.
*/ */
public void setBootClasspathRef(Reference r) { public void setBootClasspathRef(Reference r) {
classpathReferences.addElement(r);
createBootclasspath().setRefid(r);
} }


public void setExtdirs(String src) { public void setExtdirs(String src) {
@@ -598,9 +560,6 @@ public class Javadoc extends Task {
if (classpath == null) if (classpath == null)
classpath = Path.systemClasspath; classpath = Path.systemClasspath;


addReferencesToPath(classpathReferences, classpath);
addReferencesToPath(sourcepathReferences, sourcePath);

if (!javadoc1) { if (!javadoc1) {
toExecute.createArgument().setValue("-classpath"); toExecute.createArgument().setValue("-classpath");
toExecute.createArgument().setPath(classpath); toExecute.createArgument().setPath(classpath);
@@ -655,9 +614,7 @@ public class Javadoc extends Task {
} }
} }
} }
if (bootclasspath != null || bootClasspathReferences.size() > 0) {
addReferencesToPath(bootClasspathReferences,
createBootclasspath());
if (bootclasspath != null) {
toExecute.createArgument().setValue("-bootclasspath"); toExecute.createArgument().setValue("-bootclasspath");
toExecute.createArgument().setPath(bootclasspath); toExecute.createArgument().setPath(bootclasspath);
} }
@@ -781,25 +738,6 @@ 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 * 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 * with the packages found in that path subdirs matching one of the given


+ 11
- 64
src/main/org/apache/tools/ant/taskdefs/Rmic.java View File

@@ -97,19 +97,11 @@ public class Rmic extends MatchingTask {
private boolean filtering = false; private boolean filtering = false;


private Vector compileList = new Vector(); private Vector compileList = new Vector();
private Vector classpathReferences = new Vector();


public void setBase(String base) { public void setBase(String base) {
this.base = base; this.base = base;
} }


public void XsetClass(String classname) {
log("The class attribute is deprecated. " +
"Please use the classname attribute.",
Project.MSG_WARN);
this.classname = classname;
}

public void setClassname(String classname) { public void setClassname(String classname) {
this.classname = classname; this.classname = classname;
} }
@@ -122,8 +114,8 @@ public class Rmic extends MatchingTask {
this.stubVersion = stubVersion; this.stubVersion = stubVersion;
} }


public void setFiltering(String filter) {
filtering = Project.toBoolean(filter);
public void setFiltering(boolean filter) {
filtering = filter;
} }


/** /**
@@ -138,37 +130,28 @@ public class Rmic extends MatchingTask {
} }


/** /**
* Maybe creates a nested classpath element.
* Creates a nested classpath element.
*/ */
public Path createClasspath() { public Path createClasspath() {
if (compileClasspath == null) { if (compileClasspath == null) {
compileClasspath = new Path(project); compileClasspath = new Path(project);
} }
return compileClasspath;
}

/**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <classpathref> element.
*/
public void addClasspathRef(Reference r) {
classpathReferences.addElement(r);
return compileClasspath.createPath();
} }


/** /**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <classpathref> element.
* Adds a reference to a CLASSPATH defined elsewhere.
*/ */
public void setClasspathRef(Reference r) { public void setClasspathRef(Reference r) {
classpathReferences.addElement(r);
createClasspath().setRefid(r);
} }


/** /**
* Indicates that the classes found by the directory match should be * Indicates that the classes found by the directory match should be
* checked to see if they implement java.rmi.Remote. * 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);
public void setVerify(boolean verify) {
this.verify = verify;
} }


public void execute() throws BuildException { public void execute() throws BuildException {
@@ -189,18 +172,6 @@ public class Rmic extends MatchingTask {
} }
Path 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 // scan base dirs to build up compile lists only if a
// specific classname is not given // specific classname is not given
if (classname == null) { if (classname == null) {
@@ -406,45 +377,21 @@ public class Rmic extends MatchingTask {
// add our classpath to the mix // add our classpath to the mix


if (compileClasspath != null) { if (compileClasspath != null) {
addExistingToClasspath(classpath,compileClasspath);
classpath.addExisting(compileClasspath);
} }


// add the system classpath // add the system classpath
addExistingToClasspath(classpath, Path.systemClasspath);
classpath.addExisting(Path.systemClasspath);


// in jdk 1.2, the system classes are not on the visible classpath. // in jdk 1.2, the system classes are not on the visible classpath.
if (Project.getJavaVersion().startsWith("1.2")) { if (Project.getJavaVersion().startsWith("1.2")) {
String bootcp = System.getProperty("sun.boot.class.path"); String bootcp = System.getProperty("sun.boot.class.path");
if (bootcp != null) { if (bootcp != null) {
addExistingToClasspath(classpath, new Path(project, bootcp));
classpath.addExisting(new Path(project, bootcp));
} }
} }
return classpath; return classpath;
} }


/**
* Takes a classpath-like string, and adds each element of
* this string to a new classpath, if the components exist.
* Components that don't exist, aren't added.
* We do this, because jikes issues warnings for non-existant
* files/dirs in his classpath, and these warnings are pretty
* annoying.
* @param target - target classpath
* @param source - source classpath
* to get file objects.
*/
private void addExistingToClasspath(Path target, Path source) {
String[] list = source.list();
for (int i=0; i<list.length; i++) {
File f = project.resolveFile(list[i]);

if (f.exists()) {
target.setLocation(f);
} else {
log("Dropping from classpath: "+
f.getAbsolutePath(), Project.MSG_VERBOSE);
}
}
}
} }



+ 1
- 23
src/main/org/apache/tools/ant/taskdefs/optional/junit/JUnitTask.java View File

@@ -88,7 +88,6 @@ import java.util.Vector;
public class JUnitTask extends Task { public class JUnitTask extends Task {


private CommandlineJava commandline = new CommandlineJava(); private CommandlineJava commandline = new CommandlineJava();
private Vector classpathReferences = new Vector();
private Vector tests = new Vector(); private Vector tests = new Vector();
private Vector batchTests = new Vector(); private Vector batchTests = new Vector();
private Vector formatters = new Vector(); private Vector formatters = new Vector();
@@ -134,16 +133,8 @@ public class JUnitTask extends Task {
return commandline.createVmArgument(); return commandline.createVmArgument();
} }


/**
* Adds a reference to a CLASSPATH defined elsewhere - nested
* <classpathref> element.
*/
public void addClasspathRef(Reference r) {
classpathReferences.addElement(r);
}

public Path createClasspath() { public Path createClasspath() {
return commandline.createClasspath(project);
return commandline.createClasspath(project).createPath();
} }


public void addTest(JUnitTest test) { public void addTest(JUnitTest test) {
@@ -180,19 +171,6 @@ public class JUnitTask extends Task {
boolean errorOccurred = false; boolean errorOccurred = false;
boolean failureOccurred = false; boolean failureOccurred = false;


Path classpath = commandline.createClasspath(project);
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);
}
}

Enumeration list = batchTests.elements(); Enumeration list = batchTests.elements();
while (list.hasMoreElements()) { while (list.hasMoreElements()) {
BatchTest test = (BatchTest)list.nextElement(); BatchTest test = (BatchTest)list.nextElement();


Loading…
Cancel
Save