You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ru...@locus.apache.org on 2000/02/27 02:47:47 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs Available.java FixCRLF.java Javac.java
rubys 00/02/26 17:47:47
Modified: src/main/org/apache/tools/ant/taskdefs Available.java
FixCRLF.java Javac.java
Log:
Emulate extdirs feature with Jikes compiler.
Also fix two files to compile with the more strict Jikes compiler.
Submitted by: Sebastian Kanthak <se...@muehlheim.de>
Revision Changes Path
1.3 +1 -5 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java
Index: Available.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Available.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- Available.java 2000/02/16 14:31:45 1.2
+++ Available.java 2000/02/27 01:47:46 1.3
@@ -112,11 +112,7 @@
}
private boolean checkResource(String resource) {
- try {
- return (ClassLoader.getSystemResource(resource) != null);
- } catch (Exception e) {
- return false;
- }
+ return (ClassLoader.getSystemResource(resource) != null);
}
private boolean checkClass(String classname) {
1.5 +4 -4 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java
Index: FixCRLF.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/FixCRLF.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- FixCRLF.java 2000/02/13 21:44:00 1.4
+++ FixCRLF.java 2000/02/27 01:47:46 1.5
@@ -281,13 +281,13 @@
for (int k=0; k<count; k++) {
switch (indata[k]) {
- case ' ':
+ case (byte)' ':
// advance column
if (addtab == 0) outdata[o++]=(byte)' ';
col++;
break;
- case '\t':
+ case (byte)'\t':
if (addtab == 0) {
// treat like any other character
outdata[o++]=(byte)'\t';
@@ -298,7 +298,7 @@
}
break;
- case '\r':
+ case (byte)'\r':
if (addcr == 0) {
// treat like any other character
outdata[o++]=(byte)'\r';
@@ -306,7 +306,7 @@
}
break;
- case '\n':
+ case (byte)'\n':
// start a new line (optional CR followed by LF)
if (addcr == +1) outdata[o++]=(byte)'\r';
outdata[o++]=(byte)'\n';
1.7 +52 -6 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java
Index: Javac.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Javac.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- Javac.java 2000/02/14 12:19:27 1.6
+++ Javac.java 2000/02/27 01:47:46 1.7
@@ -436,7 +436,19 @@
private void doJikesCompile() throws BuildException {
project.log("Using jikes compiler",project.MSG_VERBOSE);
- String classpath = getCompileClasspath();
+
+ StringBuffer classpath = new StringBuffer();
+ classpath.append(getCompileClasspath());
+
+ // Jikes doesn't support an extension dir (-extdir)
+ // so we'll emulate it for compatibility and convenience.
+ addExtdirsToClasspath(classpath);
+
+ // Jikes has no option for source-path so we
+ // will add it to classpath.
+ classpath.append(File.pathSeparator);
+ classpath.append(srcDir.getAbsolutePath());
+
Vector argList = new Vector();
if (deprecation == true)
@@ -449,11 +461,8 @@
argList.addElement("-d");
argList.addElement(destDir.getAbsolutePath());
argList.addElement("-classpath");
- // Jikes has no option for source-path so we
- // will add it to classpath.
- // XXX is this correct?
- argList.addElement(classpath+File.pathSeparator +
- srcDir.getAbsolutePath());
+ argList.addElement(classpath.toString());
+
if (debug) {
argList.addElement("-g");
}
@@ -542,4 +551,41 @@
throw new BuildException(msg);
}
}
+
+ class JarFilenameFilter implements FilenameFilter {
+ public boolean accept(File dir,String name) {
+ return name.endsWith(".jar");
+ }
+ }
+
+ /**
+ * Emulation of extdirs feature in java >= 1.2.
+ * This method adds all jar archives in the given
+ * directories (but not in sub-directories!) to the classpath,
+ * so that you don't have to specify them all one by one.
+ * @param classpath - stringbuffer to append jar files to
+ */
+ private void addExtdirsToClasspath(StringBuffer classpath) {
+ // FIXME
+ // Should we scan files recursively? How does
+ // javac handle this?
+
+ if (extdirs != null) {
+ StringTokenizer tok = new StringTokenizer(extdirs,
+ File.pathSeparator,
+ false);
+ while (tok.hasMoreTokens()) {
+ File dir = project.resolveFile(tok.nextToken());
+ String[] files = dir.list(new JarFilenameFilter());
+ for (int i=0 ; i < files.length ; i++) {
+ File f = new File(dir,files[i]);
+ if (f.exists() && f.isFile()) {
+ classpath.append(File.pathSeparator);
+ classpath.append(f.getAbsolutePath());
+ }
+ }
+ }
+ }
+ }
}
+