You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ru...@locus.apache.org on 2000/01/09 01:39:39 UTC
cvs commit: jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs Javac.java JikesOutputParser.java
rubys 00/01/08 16:39:39
Modified: ant/src/main/org/apache/tools/ant/taskdefs Javac.java
JikesOutputParser.java
Log:
Additional Jikes options ("build.compiler.emacs" and
"build.compiler.warnings") as well as classpath checking
enhancements.
Submitted by: Sebastian Kanthak <se...@muehlheim.de>
Revision Changes Path
1.19 +75 -12 jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs/Javac.java
Index: Javac.java
===================================================================
RCS file: /home/cvs/jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs/Javac.java,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Javac.java 2000/01/04 02:29:40 1.18
+++ Javac.java 2000/01/09 00:39:38 1.19
@@ -315,29 +315,49 @@
//classpath.append(sourceDir.getAbsolutePath());
//classpath.append(File.pathSeparator);
classpath.append(destDir.getAbsolutePath());
- classpath.append(File.pathSeparator);
// add our classpath to the mix
if (compileClasspath != null) {
- StringTokenizer tok = new StringTokenizer(compileClasspath,
- System.getProperty("path.separator"), false);
- while (tok.hasMoreTokens()) {
- File f = project.resolveFile(tok.nextToken());
- if (f.exists()) {
- classpath.append(f.getAbsolutePath());
- classpath.append(File.pathSeparator);
- }
- }
+ addExistingToClasspath(classpath,compileClasspath);
}
// add the system classpath
- classpath.append(System.getProperty("java.class.path"));
+ addExistingToClasspath(classpath,System.getProperty("java.class.path"));
return classpath.toString();
}
+ /**
+ * 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(StringBuffer target,String source) {
+ StringTokenizer tok = new StringTokenizer(source,
+ System.getProperty("path.separator"), false);
+ while (tok.hasMoreTokens()) {
+ File f = project.resolveFile(tok.nextToken());
+
+ if (f.exists()) {
+ target.append(File.pathSeparator);
+ target.append(f.getAbsolutePath());
+ } else {
+ project.log("Dropping from classpath: "+
+ f.getAbsolutePath(),project.MSG_VERBOSE);
+ }
+ }
+
+ }
+
+
/**
* Peforms a copmile using the classic compiler that shipped with
* JDK 1.1 and 1.2.
@@ -469,6 +489,49 @@
if (optimize) {
argList.addElement("-O");
}
+
+ /**
+ * XXX
+ * Perhaps we shouldn't use properties for these
+ * two options (emacs mode and warnings),
+ * but include it in the javac directive?
+ */
+
+ /**
+ * Jikes has the nice feature to print error
+ * messages in a form readable by emacs, so
+ * that emcas can directly set the cursor
+ * to the place, where the error occured.
+ */
+ boolean emacsMode = false;
+ String emacsProperty = project.getProperty("build.compiler.emacs");
+ if (emacsProperty != null &&
+ (emacsProperty.equalsIgnoreCase("on") ||
+ emacsProperty.equalsIgnoreCase("true"))
+ ) {
+ emacsMode = true;
+ }
+
+ /**
+ * Jikes issues more warnings that javac, for
+ * example, when you have files in your classpath
+ * that don't exist. As this is often the case, these
+ * warning can be pretty annoying.
+ */
+ boolean warnings = true;
+ String warningsProperty = project.getProperty("build.compiler.warnings");
+ if (warningsProperty != null &&
+ (warningsProperty.equalsIgnoreCase("off") ||
+ warningsProperty.equalsIgnoreCase("false"))
+ ) {
+ warnings = false;
+ }
+
+ if (emacsMode)
+ argList.addElement("+E");
+
+ if (!warnings)
+ argList.addElement("-nowarn");
project.log("Compilation args: " + argList.toString(),
project.MSG_VERBOSE);
@@ -499,7 +562,7 @@
// XXX
// provide the compiler a different message sink - namely our own
- JikesOutputParser jop = new JikesOutputParser(project);
+ JikesOutputParser jop = new JikesOutputParser(project,emacsMode);
Jikes compiler = new Jikes(jop,"jikes");
compiler.compile(args);
1.2 +26 -4 jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java
Index: JikesOutputParser.java
===================================================================
RCS file: /home/cvs/jakarta-tools/ant/src/main/org/apache/tools/ant/taskdefs/JikesOutputParser.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- JikesOutputParser.java 2000/01/04 02:18:06 1.1
+++ JikesOutputParser.java 2000/01/09 00:39:38 1.2
@@ -17,15 +17,16 @@
public class JikesOutputParser {
protected Project project;
protected boolean errorFlag = false; // no errors so far
- protected int errors,warnings;
+ protected boolean emacsMode;
/**
* Construct a new Parser object
* @param project - project in whichs context we are called
*/
- protected JikesOutputParser(Project project) {
+ protected JikesOutputParser(Project project, boolean emacsMode) {
super();
this.project = project;
+ this.emacsMode = emacsMode;
}
/**
@@ -33,6 +34,13 @@
* @param reader - Reader used to read jikes's output
*/
protected void parseOutput(BufferedReader reader) throws IOException {
+ if (emacsMode)
+ parseEmacsOutput(reader);
+ else
+ parseStandardOutput(reader);
+ }
+
+ private void parseStandardOutput(BufferedReader reader) throws IOException {
String line;
String lower;
// We assume, that every output, jike does, stands for an error/warning
@@ -51,14 +59,28 @@
}
}
+ private void parseEmacsOutput(BufferedReader reader) throws IOException {
+ // This may change, if we add advanced parsing capabilities.
+ parseStandardOutput(reader);
+ }
+
private void logWarning(String line) {
- project.log("",Project.MSG_WARN); // Empty lines from jikes are alredy eaten, so print new ones
+ // Empty lines from jikes are alredy eaten, so print new ones
+ if (!emacsMode) {
+ project.log("",Project.MSG_WARN);
+ }
+
project.log(line,Project.MSG_WARN);
}
private void logError(String line) {
errorFlag = true;
- project.log("",Project.MSG_ERR); // see above
+
+ // Empty lines from jikes are alredy eaten, so print new ones
+ if (!emacsMode) {
+ project.log("",Project.MSG_ERR);
+ }
+
project.log(line,Project.MSG_ERR);
}