From 62961601adedbb9d3f2a577dea164b076cae662b Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 4 Sep 2000 14:06:34 +0000 Subject: [PATCH] Added support for jvc (Microsofts Java compiler) to . Submitted by: Nico Seessle git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267953 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 + docs/index.html | 2 + .../org/apache/tools/ant/taskdefs/Javac.java | 55 +++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/WHATSNEW b/WHATSNEW index 581c4b1a3..3cc6bd1d5 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -30,6 +30,8 @@ behavior has been dropped. * task syntax has been changed significantly +* build.compiler supports now jvc as well. + Other changes: -------------- diff --git a/docs/index.html b/docs/index.html index 5502dea25..a2ec67fc7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2258,6 +2258,8 @@ inclusion/exclusion of files works, and how to write patterns.

  • jikes (the Jikes compiler)
  • +
  • jvc (the Command-Line Compiler from Microsoft's SDK for Java / + Visual J++)
  • For JDK 1.1/1.2 is classic the default. For JDK 1.3 is modern the default.

    Parameters

    diff --git a/src/main/org/apache/tools/ant/taskdefs/Javac.java b/src/main/org/apache/tools/ant/taskdefs/Javac.java index fff37ff6e..98c7cfb04 100644 --- a/src/main/org/apache/tools/ant/taskdefs/Javac.java +++ b/src/main/org/apache/tools/ant/taskdefs/Javac.java @@ -326,6 +326,8 @@ public class Javac extends MatchingTask { doModernCompile(); } else if (compiler.equalsIgnoreCase("jikes")) { doJikesCompile(); + } else if (compiler.equalsIgnoreCase("jvc")) { + doJvcCompile(); } else { String msg = "Don't know how to use compiler " + compiler; throw new BuildException(msg); @@ -776,5 +778,58 @@ public class Javac extends MatchingTask { } } + private void doJvcCompile() throws BuildException { + log("Using jvc compiler", Project.MSG_VERBOSE); + + Path classpath = new Path(project); + + // jvc doesn't support bootclasspath dir (-bootclasspath) + // so we'll emulate it for compatibility and convenience. + if (bootclasspath != null || bootClasspathReferences.size() > 0) { + addReferencesToPath(bootClasspathReferences, createBootclasspath()); + classpath.append(bootclasspath); + } + + classpath.append(getCompileClasspath(true)); + + // jvc doesn't support an extension dir (-extdir) + // so we'll emulate it for compatibility and convenience. + addExtdirsToClasspath(classpath); + + // jvc has no option for source-path so we + // will add it to classpath. + classpath.append(src); + + Commandline cmd = new Commandline(); + cmd.setExecutable("jvc"); + + cmd.createArgument().setValue("/d"); + cmd.createArgument().setFile(destDir); + // Add the Classpath before the "internal" one. + cmd.createArgument().setValue("/cp:p"); + cmd.createArgument().setPath(classpath); + + // Enable MS-Extensions and ... + cmd.createArgument().setValue("/x-"); + // ... do not display a Message about this. + cmd.createArgument().setValue("/nomessage"); + // Do not display Logo + cmd.createArgument().setValue("/nologo"); + + if (debug) { + cmd.createArgument().setValue("/g"); + } + if (optimize) { + cmd.createArgument().setValue("/O"); + } + + int firstFileName = cmd.size(); + logAndAddFilesToCompile(cmd); + + if (executeJikesCompile(cmd.getCommandline(), firstFileName) != 0) { + String msg = "Compile failed, messages should have been provided."; + throw new BuildException(msg); + } + } }