The Java task supports setting a classpath for Java programs, but it doesn't support setting a bootclasspath (necessary to allow vendor classes to take priority over standard Java classes). I've attached a patch that will allow you to set bootclasspaths either directly, or via references.

(The most common reason to use a bootclasspath is when you're using a CORBA ORB such as Visibroker or JacORB with Java 1.3, because Sun's implementation of the CORBA Java mapping didn't implement the latest OMG specification for the ORB class. If you need to use the full capabilities of your ORB, you need to be able to place your vendor's jar(s) in the classpath before rt.jar.)

Caveats:

* This only works if you fork the VM (ie: set fork="yes")

* This patch uses -Xbootclasspath:<path>, which is available starting with Sun's JDK 1.2. A more clever implementation would recognize an older JDK and rearrange the classpath to include the bootclasspath and the JDK jars; on the other hand, older JDKs don't *need* to set a bootclasspath.

- Craig -

--
============= Excellence is a journey, not a destination =============
======== W. Craig Trader <[EMAIL PROTECTED]> 703.367.2079 ========
Index: docs/manual/CoreTasks/java.html
===================================================================
RCS file: /home/cvspublic/jakarta-ant/docs/manual/CoreTasks/java.html,v
retrieving revision 1.10
diff -u -r1.10 java.html
--- docs/manual/CoreTasks/java.html     3 Feb 2002 22:00:42 -0000       1.10
+++ docs/manual/CoreTasks/java.html     21 Feb 2002 19:30:29 -0000
@@ -51,6 +51,18 @@
     <td align="center" valign="top">No</td>
   </tr>
   <tr>
+    <td valign="top">bootclasspath</td>
+    <td valign="top">the boot classpath to use.  This depends upon the JVM to 
support
+      the <b>-Xbootclasspath:<i>path</i></b> parameter.</td>
+    <td align="center" valign="top">No</td>
+  </tr>
+  <tr>
+    <td valign="top">bootclasspathref</td>
+    <td valign="top">the boot classpath to use, given as <a
+      href="../using.html#references">reference</a> to a PATH defined 
elsewhere.</td>
+    <td align="center" valign="top">No</td>
+  </tr>
+  <tr>
     <td valign="top">fork</td>
     <td valign="top">if enabled triggers the class execution in another VM
       (disabled by default)</td>
Index: src/main/org/apache/tools/ant/taskdefs/Java.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Java.java,v
retrieving revision 1.32
diff -u -r1.32 Java.java
--- src/main/org/apache/tools/ant/taskdefs/Java.java    29 Jan 2002 16:20:20 
-0000      1.32
+++ src/main/org/apache/tools/ant/taskdefs/Java.java    21 Feb 2002 19:30:33 
-0000
@@ -169,6 +169,27 @@
     }
 
     /**
+     * Set the classpath to be used for this compilation.
+     */
+    public void setBootclasspath(Path s) {
+        createBootclasspath().append(s);
+    }
+
+    /**
+     * Creates a nested classpath element
+     */
+    public Path createBootclasspath() {
+        return cmdl.createBootClasspath(project).createPath();
+    }
+
+    /**
+     * Adds a reference to a CLASSPATH defined elsewhere.
+     */
+    public void setBootclasspathRef(Reference r) {
+        createBootclasspath().setRefid(r);
+    }
+
+    /**
      * set the jar name...
      */
     public void setJar(File jarfile) throws BuildException {
Index: src/main/org/apache/tools/ant/types/CommandlineJava.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/types/CommandlineJava.java,v
retrieving revision 1.28
diff -u -r1.28 CommandlineJava.java
--- src/main/org/apache/tools/ant/types/CommandlineJava.java    15 Feb 2002 
15:05:41 -0000      1.28
+++ src/main/org/apache/tools/ant/types/CommandlineJava.java    21 Feb 2002 
19:30:33 -0000
@@ -77,6 +77,7 @@
     private Commandline javaCommand = new Commandline();
     private SysProperties sysProperties = new SysProperties();
     private Path classpath = null;
+    private Path bootclasspath = null;
     private String vmVersion;
     private String maxMemory = null;
 
@@ -223,6 +224,13 @@
         return classpath;
     }
 
+    public Path createBootClasspath(Project p) {
+        if (bootclasspath == null) {
+            bootclasspath = new Path(p);
+        }
+        return bootclasspath;
+    }
+
     public String getVmversion() {
         return vmVersion;
     }
@@ -247,6 +255,10 @@
                              result, pos, sysProperties.size());
             pos += sysProperties.size();
         }
+        // bootclasspath is a vm option too..
+        if (bootclasspath != null && bootclasspath.toString().trim().length() 
> 0) {
+            result[pos++] = "-Xbootclasspath:" + bootclasspath.toString();
+        }
         // classpath is a vm option too..
         Path fullClasspath = classpath != null ? 
classpath.concatSystemClasspath("ignore") : null;
         if (fullClasspath != null && fullClasspath.toString().trim().length() 
> 0) {
@@ -301,6 +313,10 @@
      */
     public int size() {
         int size = getActualVMCommand().size() + javaCommand.size() + 
sysProperties.size();
+        // bootclasspath is "-Xbootclasspath:<classpath>" -> 1 args
+        if (bootclasspath != null && bootclasspath.toString().trim().length() 
> 0) {
+            size += 1;
+        }
         // classpath is "-classpath <classpath>" -> 2 args
         Path fullClasspath = classpath != null ? 
classpath.concatSystemClasspath("ignore") : null;
         if (fullClasspath != null && fullClasspath.toString().trim().length() 
> 0) {

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to