You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by eh...@apache.org on 2002/04/01 19:34:36 UTC
cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional NetRexxC.java
ehatcher 02/04/01 09:34:36
Modified: src/main/org/apache/tools/ant/taskdefs/optional
NetRexxC.java
Log:
patch supplied by bechtel@ipcon.de (Patric Bechtel) PR 7657
Revision Changes Path
1.15 +32 -13 jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
Index: NetRexxC.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- NetRexxC.java 25 Feb 2002 17:38:15 -0000 1.14
+++ NetRexxC.java 1 Apr 2002 17:34:36 -0000 1.15
@@ -57,6 +57,8 @@
import java.io.IOException;
import java.io.StringWriter;
import java.io.PrintWriter;
+import java.io.StringReader;
+import java.io.BufferedReader;
import java.util.Vector;
import java.util.Hashtable;
@@ -471,8 +473,8 @@
// if it's a source file, see if the destination class file
// needs to be recreated via compilation
if (filename.toLowerCase().endsWith(".nrx")) {
- File classFile =
- new File(destDir,
+ File classFile =
+ new File(destDir,
filename.substring(0, filename.lastIndexOf('.')) + ".class");
if (!compile || srcFile.lastModified() > classFile.lastModified()) {
@@ -564,27 +566,44 @@
currentProperties.put("java.class.path", classpath);
try {
- StringWriter out = new StringWriter();
+ StringWriter out = new StringWriter();
int rc = COM.ibm.netrexx.process.NetRexxC.
main(new Rexx(compileArgs), new PrintWriter(out));
-
- if (rc > 1) { // 1 is warnings from real NetRexxC
- log(out.toString(), Project.MSG_ERR);
- String msg = "Compile failed, messages should have been provided.";
- throw new BuildException(msg);
+ String sdir=srcDir.getAbsolutePath();
+ String ddir=destDir.getAbsolutePath();
+ int dlen=ddir.length();
+ String l;
+ StringBuffer lb;
+ BufferedReader in=new BufferedReader(new StringReader(out.toString()));
+ log("replacing destdir '"+ddir+"' through sourcedir '"+sdir+"'", Project.MSG_VERBOSE);
+ while ((l=in.readLine())!=null) {
+ lb=new StringBuffer(l);
+ int idx;
+ while ((idx=l.indexOf(ddir))!=-1) { // path is mentioned in the message
+ lb.replace(idx,idx+dlen,sdir);
+ l=lb.toString();
+ }
+ if (l.indexOf("Error:")!=-1) {
+ log(l, Project.MSG_ERR);
+ } else if (l.indexOf("Warning:")!=-1) {
+ log(l, Project.MSG_WARN);
+ } else {
+ log(l, Project.MSG_INFO);
+ }
}
- else if (rc == 1) {
- log(out.toString(), Project.MSG_WARN);
+ if (rc>1) {
+ throw new BuildException("Compile failed, messages should have been provided.");
}
- else {
- log(out.toString(), Project.MSG_INFO);
- }
+ } catch (IOException ioe) {
+ ioe.printStackTrace(); // we would like to know WHY this happened. Should never!
+ throw new BuildException("Unexpected IOException while playing with Strings: "+ioe.toString());
} finally {
// need to reset java.class.path property
// since the NetRexx compiler has no option for the classpath
currentProperties = System.getProperties();
currentProperties.put("java.class.path", currentClassPath);
}
+
}
/**
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>