bodewig 01/06/26 06:42:30
Modified: src/main/org/apache/tools/ant Project.java
src/main/org/apache/tools/ant/taskdefs Rmic.java
src/main/org/apache/tools/ant/taskdefs/rmic
DefaultRmicAdapter.java RmicAdapter.java
webpage/docs faq.html
webpage/xdocs faq.xml
Log:
Some initial work on rmic to make it handle -iiop better (doesn't
detect generated files properly) - doesn't quite work ATM.
Add some extra warning and debugging info to Project.
Revision Changes Path
1.59 +7 -1 jakarta-ant/src/main/org/apache/tools/ant/Project.java
Index: Project.java
===================================================================
RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Project.java,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- Project.java 2001/06/08 10:11:25 1.58
+++ Project.java 2001/06/26 13:42:11 1.59
@@ -242,8 +242,10 @@
public void setProperty(String name, String value) {
// command line properties take precedence
- if (null != userProperties.get(name))
+ if (null != userProperties.get(name)) {
+ log("Override ignored for user property " + name, MSG_VERBOSE);
return;
+ }
log("Setting project property: " + name + " -> " +
value, MSG_DEBUG);
properties.put(name, value);
@@ -1034,6 +1036,10 @@
}
public void addReference(String name, Object value) {
+ if (null != references.get(name)) {
+ log("Overriding previous definition of reference to " + name,
+ MSG_WARN);
+ }
log("Adding reference: " + name + " -> " + value, MSG_DEBUG);
references.put(name,value);
}
1.23 +15 -21
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java
Index: Rmic.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/Rmic.java,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- Rmic.java 2001/03/27 06:36:06 1.22
+++ Rmic.java 2001/06/26 13:42:16 1.23
@@ -418,29 +418,23 @@
String classname,
RmicAdapter adapter)
throws BuildException {
- String stubFileName = classname.replace('.', File.separatorChar)
- + adapter.getStubClassSuffix()+".java";
- File oldStubFile = new File(baseDir, stubFileName);
- File newStubFile = new File(sourceBaseFile, stubFileName);
- try {
- project.copyFile(oldStubFile, newStubFile, filtering);
- oldStubFile.delete();
- } catch (IOException ioe) {
- String msg = "Failed to copy " + oldStubFile + " to " +
- newStubFile + " due to " + ioe.getMessage();
- throw new BuildException(msg, ioe, location);
- }
- if (!"1.2".equals(stubVersion)) {
- String skelFileName = classname.replace('.', File.separatorChar)
- + adapter.getSkelClassSuffix()+".java";
- File oldSkelFile = new File(baseDir, skelFileName);
- File newSkelFile = new File(sourceBaseFile, skelFileName);
+
+ String classFileName =
+ classname.replace('.', File.separatorChar) + ".class";
+ String[] generatedFiles =
+ adapter.getMapper().mapFileName(classFileName);
+
+ for (int i=0; i<generatedFiles.length; i++) {
+ String sourceFileName =
+ classFileName.substring(0, classFileName.length()-6) +
".java";
+ File oldFile = new File(baseDir, sourceFileName);
+ File newFile = new File(sourceBaseFile, sourceFileName);
try {
- project.copyFile(oldSkelFile, newSkelFile, filtering);
- oldSkelFile.delete();
+ project.copyFile(oldFile, newFile, filtering);
+ oldFile.delete();
} catch (IOException ioe) {
- String msg = "Failed to copy " + oldSkelFile + " to " +
- newSkelFile + " due to " + ioe.getMessage();
+ String msg = "Failed to copy " + oldFile + " to " +
+ newFile + " due to " + ioe.getMessage();
throw new BuildException(msg, ioe, location);
}
}
1.5 +46 -29
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
Index: DefaultRmicAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- DefaultRmicAdapter.java 2001/05/03 11:35:20 1.4
+++ DefaultRmicAdapter.java 2001/06/26 13:42:19 1.5
@@ -90,14 +90,18 @@
return attributes;
}
- public String getStubClassSuffix() {
+ protected String getStubClassSuffix() {
return "_Stub";
}
- public String getSkelClassSuffix() {
+ protected String getSkelClassSuffix() {
return "_Skel";
}
+ protected String getTieClassSuffix() {
+ return "_Tie";
+ }
+
/**
* This implementation maps *.class to *getStubClassSuffix().class and -
if
* stubversion is not 1.2 - to *getSkelClassSuffix().class.
@@ -321,22 +325,8 @@
*/
private class RmicFileNameMapper implements FileNameMapper {
- private GlobPatternMapper stubMapper;
- private GlobPatternMapper skelMapper;
+ RmicFileNameMapper() {}
- RmicFileNameMapper() {
- stubMapper = new GlobPatternMapper();
- stubMapper.setFrom("*.class");
- stubMapper.setTo("*"+getStubClassSuffix()+".class");
-
- // no _Skel file in stub version 1.2
- if (!"1.2".equals(attributes.getStubVersion())) {
- skelMapper = new GlobPatternMapper();
- skelMapper.setFrom("*.class");
- skelMapper.setTo("*"+getSkelClassSuffix()+".class");
- }
- }
-
/**
* Empty implementation.
*/
@@ -347,28 +337,55 @@
public void setTo(String s) {}
public String[] mapFileName(String name) {
- String[] stubName = stubMapper.mapFileName(name);
-
- if (stubName == null
+ if (name == null
+ || !name.endsWith(".class")
|| name.endsWith(getStubClassSuffix()+".class")
- || name.endsWith(getSkelClassSuffix()+".class")) {
- // Not a .class file
+ || name.endsWith(getSkelClassSuffix()+".class")
+ || name.endsWith(getTieClassSuffix()+".class")) {
+ // Not a .class file or the one we'd generate
return null;
}
- String classname = name.replace(File.separatorChar, '.');
- classname = classname.substring(0, classname.indexOf(".class"));
+ String base = name.substring(0, name.indexOf(".class"));
+ String classname = base.replace(File.separatorChar, '.');
if (attributes.getVerify() &&
!attributes.isValidRmiRemote(classname)) {
return null;
}
- if (skelMapper != null) {
+
+ if (!attributes.getIiop()) {
+ if ("1.2".equals(attributes.getStubVersion())) {
+ return new String[] {
+ base + getStubClassSuffix() + ".class"
+ };
+ } else {
+ return new String[] {
+ base + getStubClassSuffix() + ".class",
+ base + getSkelClassSuffix() + ".class",
+ };
+ }
+ } else {
+ int lastSlash = base.lastIndexOf("/");
+
+ String dirname = "";
+ /*
+ * I know, this is not necessary, but I prefer it explicit
(SB)
+ */
+ int index = -1;
+ if (lastSlash == -1) {
+ // no package
+ index = 0;
+ } else {
+ index = lastSlash + 1;
+ dirname = base.substring(0, index);
+ }
+
+ String filename = base.substring(index);
+
return new String[] {
- stubName[0],
- skelMapper.mapFileName(name)[0]
+ dirname + "_" + filename + getStubClassSuffix() +
".class",
+ dirname + "_" + filename + getTieClassSuffix() + ".class"
};
- } else {
- return stubName;
}
}
}
1.3 +0 -12
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java
Index: RmicAdapter.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RmicAdapter.java 2001/03/19 11:22:51 1.2
+++ RmicAdapter.java 2001/06/26 13:42:20 1.3
@@ -93,18 +93,6 @@
*/
public FileNameMapper getMapper();
- /**
- * Difference between original class file name and the generated
- * stub class.
- */
- public String getStubClassSuffix();
-
- /**
- * Difference between original class file name and the generated
- * skel class.
- */
- public String getSkelClassSuffix();
-
/**
* The CLASSPATH this rmic process will use.
*/
1.10 +2 -2 jakarta-ant/webpage/docs/faq.html
Index: faq.html
===================================================================
RCS file: /home/cvs/jakarta-ant/webpage/docs/faq.html,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- faq.html 2001/06/26 09:38:39 1.9
+++ faq.html 2001/06/26 13:42:25 1.10
@@ -136,7 +136,7 @@
<blockquote>
<ul>
<li><a href="#always-recompiles">
- Why does Ant always recompile all my Java files
+ Why does Ant always recompile all my Java files?
</a></li>
</ul>
</blockquote>
@@ -387,7 +387,7 @@
<tr><td bgcolor="#828DA6">
<font color="#ffffff" face="arial,helvetica,sanserif">
<strong>
- Why does Ant always recompile all my Java files
+ Why does Ant always recompile all my Java files?
</strong>
</font>
</td></tr>
1.8 +1 -1 jakarta-ant/webpage/xdocs/faq.xml
Index: faq.xml
===================================================================
RCS file: /home/cvs/jakarta-ant/webpage/xdocs/faq.xml,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- faq.xml 2001/06/26 09:38:48 1.7
+++ faq.xml 2001/06/26 13:42:28 1.8
@@ -114,7 +114,7 @@
<faqsection title="Using Ant">
<faq id="always-recompiles">
- <question>Why does Ant always recompile all my Java files</question>
+ <question>Why does Ant always recompile all my Java files?</question>
<answer>
<p>In order to find out which files should be compiled, Ant