Browse Source

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.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269231 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
68fb37b1a2
6 changed files with 71 additions and 66 deletions
  1. +7
    -1
      src/main/org/apache/tools/ant/Project.java
  2. +15
    -21
      src/main/org/apache/tools/ant/taskdefs/Rmic.java
  3. +46
    -29
      src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
  4. +0
    -12
      src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java
  5. +2
    -2
      webpage/docs/faq.html
  6. +1
    -1
      webpage/xdocs/faq.xml

+ 7
- 1
src/main/org/apache/tools/ant/Project.java View File

@@ -242,8 +242,10 @@ public class Project {

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 class Project {
}

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);
}


+ 15
- 21
src/main/org/apache/tools/ant/taskdefs/Rmic.java View File

@@ -418,29 +418,23 @@ public class Rmic extends MatchingTask {
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);
}
}


+ 46
- 29
src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java View File

@@ -90,14 +90,18 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
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,21 +325,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
*/
private class RmicFileNameMapper implements FileNameMapper {

private GlobPatternMapper stubMapper;
private GlobPatternMapper skelMapper;

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");
}
}
RmicFileNameMapper() {}

/**
* Empty implementation.
@@ -347,28 +337,55 @@ public abstract class DefaultRmicAdapter implements RmicAdapter {
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;
}
}
}


+ 0
- 12
src/main/org/apache/tools/ant/taskdefs/rmic/RmicAdapter.java View File

@@ -93,18 +93,6 @@ public interface RmicAdapter {
*/
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.
*/


+ 2
- 2
webpage/docs/faq.html View File

@@ -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
- 1
webpage/xdocs/faq.xml View File

@@ -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


Loading…
Cancel
Save