"Everitt, Andrew" wrote: > I am willing to bet I'm not the first one to ask this, but I'll do it any > way. Is anyone working on the 'Modern Compile' stuff so that ANT will > work with JDK 1.3? I manage the build procedure here, some of the > developers are itching to use 1.3 but ANT doesn't work with 1.3 yet. If > someone gave me some pointers I could try and do this bit of work but I > don't want to duplicate work in progress.
Two months ago, someone posted a patch to implement a modern 1.3 compile, but it was never committed. Attached, you'll find the original message. I have no idea if or how the patch needs to be updated for the current version of the Javac taskdef. I also don't know why it was never committed in the first place. regards, Michael -- [EMAIL PROTECTED] http://www.sneakerlabs.com
--- Begin Message ---Didn't test it much, but it seems to work.
--- old/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java Sat Mar 4 20:07:02 2000
+++ jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java Sun Mar 19 21:54:05 2000
@@ -56,6 +56,7 @@
import org.apache.tools.ant.*;
+import java.lang.reflect.Method; import java.io.*; import java.util.*;
@@ -86,6 +87,12 @@
public class Javac extends MatchingTask {
+ /**
+ * Integer returned by the "Modern" jdk1.3 compiler to indicate success.
+ */
+ private static final int
+ MODERN_COMPILER_SUCCESS = 0;
+
private File srcDir;
private File destDir;
private String compileClasspath;
@@ -432,6 +439,86 @@
private void doModernCompile() throws BuildException {
project.log("Performing a Modern Compile");
+ String classpath = getCompileClasspath();
+ Vector argList = new Vector();
+
+ if (deprecation == true)
+ argList.addElement("-deprecation");
+
+ argList.addElement("-d");
+ argList.addElement(destDir.getAbsolutePath());
+ argList.addElement("-classpath");
+ argList.addElement(classpath);
+ argList.addElement("-sourcepath");
+ argList.addElement(srcDir.getAbsolutePath());
+ if (target != null) {
+ argList.addElement("-target");
+ argList.addElement(target);
+ }
+ if (debug) {
+ argList.addElement("-g");
+ }
+ if (optimize) {
+ argList.addElement("-O");
+ }
+ if (bootclasspath != null) {
+ argList.addElement("-bootclasspath");
+ argList.addElement(bootclasspath);
+ }
+ if (extdirs != null) {
+ argList.addElement("-extdirs");
+ argList.addElement(extdirs);
+ }
+
+ project.log("Compilation args: " + argList.toString(),
+ project.MSG_VERBOSE);
+
+ String[] args = new String[argList.size() + compileList.size()];
+ int counter = 0;
+
+ for (int i = 0; i < argList.size(); i++) {
+ args[i] = (String)argList.elementAt(i);
+ counter++;
+ }
+
+ // XXX
+ // should be using system independent line feed!
+
+ StringBuffer niceSourceList = new StringBuffer("Files to be compiled:"
+ + "\r\n");
+
+ Enumeration enum = compileList.elements();
+ while (enum.hasMoreElements()) {
+ args[counter] = (String)enum.nextElement();
+ niceSourceList.append(" " + args[counter] + "\r\n");
+ counter++;
+ }
+
+ project.log(niceSourceList.toString(), project.MSG_VERBOSE);
+
+ // This won't build under JDK1.2.2 because the new compiler
+ // doesn't exist there.
+ //com.sun.tools.javac.Main compiler = new com.sun.tools.javac.Main();
+ //if (compiler.compile(args) != 0) {
+
+ // Use reflection to be able to build on all JDKs >= 1.1:
+ try {
+ Class c = Class.forName ("com.sun.tools.javac.Main");
+ Object compiler = c.newInstance ();
+ Method compile = c.getMethod ("compile",
+ new Class [] {(new String [] {}).getClass ()});
+ int result = ((Integer) compile.invoke
+ (compiler, new Object [] {args}))
+ .intValue ();
+ if (result != MODERN_COMPILER_SUCCESS) {
+ String msg =
+ "Compile failed, messages should have been provided.";
+ throw new BuildException(msg);
+ }
+ }
+ catch (Exception ex) {
+ throw new BuildException (ex);
+ }
}
/**
______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
--- End Message ---
