You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by ke...@apache.org on 2007/11/08 05:57:11 UTC
svn commit: r593012 - in
/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic:
DefaultRmicAdapter.java SunRmic.java WLRmic.java
Author: kevj
Date: Wed Nov 7 20:57:11 2007
New Revision: 593012
URL: http://svn.apache.org/viewvc?rev=593012&view=rev
Log:
-merge rmic fix (bug#41349) from trunk
Modified:
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java?rev=593012&r1=593011&r2=593012&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java Wed Nov 7 20:57:11 2007
@@ -29,6 +29,7 @@
import org.apache.tools.ant.types.Commandline;
import org.apache.tools.ant.types.Path;
import org.apache.tools.ant.util.FileNameMapper;
+import org.apache.tools.ant.util.StringUtils;
/**
* This is the default implementation for the RmicAdapter interface.
@@ -39,23 +40,36 @@
*/
public abstract class DefaultRmicAdapter implements RmicAdapter {
- private Rmic attributes;
+ private Rmic attributes;
private FileNameMapper mapper;
private static final Random RAND = new Random();
- /** suffix denoting a stub file */
+ /** suffix denoting a stub file: {@value} */
public static final String RMI_STUB_SUFFIX = "_Stub";
- /** suffix denoting a skel file */
+ /** suffix denoting a skel file: {@value} */
public static final String RMI_SKEL_SUFFIX = "_Skel";
- /** suffix denoting a tie file */
+ /** suffix denoting a tie file: {@value} */
public static final String RMI_TIE_SUFFIX = "_Tie";
- /** arg for compat */
+ /** arg for compat: {@value} */
public static final String STUB_COMPAT = "-vcompat";
- /** arg for 1.1 */
+ /** arg for 1.1: {@value} */
public static final String STUB_1_1 = "-v1.1";
- /** arg for 1.2 */
+ /** arg for 1.2: {@value} */
public static final String STUB_1_2 = "-v1.2";
/**
+ * option for stub 1.1 in the rmic task: {@value}
+ */
+ public static final String STUB_OPTION_1_1 = "1.1";
+ /**
+ * option for stub 1.2 in the rmic task: {@value}
+ */
+ public static final String STUB_OPTION_1_2 = "1.2";
+ /**
+ * option for stub compat in the rmic task: {@value}
+ */
+ public static final String STUB_OPTION_COMPAT = "compat";
+
+ /**
* Default constructor
*/
public DefaultRmicAdapter() {
@@ -195,35 +209,13 @@
cmd.createArgument().setValue("-classpath");
cmd.createArgument().setPath(classpath);
-
- //handle the many different stub options.
- String stubVersion = attributes.getStubVersion();
- //default is compatibility
- String stubOption = null;
- if (null != stubVersion) {
- if ("1.1".equals(stubVersion)) {
- stubOption = STUB_1_1;
- } else if ("1.2".equals(stubVersion)) {
- stubOption = STUB_1_2;
- } else if ("compat".equals(stubVersion)) {
- stubOption = STUB_COMPAT;
- } else {
- //anything else
- attributes.log("Unknown stub option " + stubVersion);
- //do nothing with the value? or go -v+stubVersion??
- }
- }
- //for java1.5+, we generate compatible stubs, that is, unless
- //the caller asked for IDL or IIOP support.
- if (stubOption == null
- && !attributes.getIiop()
- && !attributes.getIdl()) {
- stubOption = STUB_COMPAT;
- }
+ String stubOption = addStubVersionOptions();
if (stubOption != null) {
//set the non-null stubOption
cmd.createArgument().setValue(stubOption);
}
+
+
if (null != attributes.getSourceBase()) {
cmd.createArgument().setValue("-keepgenerated");
}
@@ -261,6 +253,40 @@
}
/**
+ * This is an override point; get the stub version off the rmic command and
+ * translate that into a compiler-specific argument
+ * @return a string to use for the stub version; can be null
+ * @since Ant1.7.1
+ */
+ protected String addStubVersionOptions() {
+ //handle the many different stub options.
+ String stubVersion = attributes.getStubVersion();
+ //default is compatibility
+ String stubOption = null;
+ if (null != stubVersion) {
+ if (STUB_OPTION_1_1.equals(stubVersion)) {
+ stubOption = STUB_1_1;
+ } else if (STUB_OPTION_1_2.equals(stubVersion)) {
+ stubOption = STUB_1_2;
+ } else if (STUB_OPTION_COMPAT.equals(stubVersion)) {
+ stubOption = STUB_COMPAT;
+ } else {
+ //anything else
+ attributes.log("Unknown stub option " + stubVersion);
+ //do nothing with the value? or go -v+stubVersion??
+ }
+ }
+ //for java1.5+, we generate compatible stubs, that is, unless
+ //the caller asked for IDL or IIOP support.
+ if (stubOption == null
+ && !attributes.getIiop()
+ && !attributes.getIdl()) {
+ stubOption = STUB_COMPAT;
+ }
+ return stubOption;
+ }
+
+ /**
* Preprocess the compiler arguments in any way you see fit.
* This is to allow compiler adapters to validate or filter the arguments.
* The base implementation returns the original compiler arguments unchanged.
@@ -365,7 +391,7 @@
}
// we know that name.endsWith(".class")
- String base = name.substring(0, name.length() - ".class".length());
+ String base = StringUtils.removeSuffix(name, ".class");
String classname = base.replace(File.separatorChar, '.');
if (attributes.getVerify()
@@ -385,7 +411,7 @@
if (!attributes.getIiop() && !attributes.getIdl()) {
// JRMP with simple naming convention
- if ("1.2".equals(attributes.getStubVersion())) {
+ if (STUB_OPTION_1_2.equals(attributes.getStubVersion())) {
target = new String[] {
base + getStubClassSuffix() + ".class"
};
Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java?rev=593012&r1=593011&r2=593012&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java Wed Nov 7 20:57:11 2007
@@ -52,7 +52,7 @@
public static final String ERROR_NO_RMIC_ON_CLASSPATH = "Cannot use SUN rmic, as it is not "
+ "available. A common solution is to "
+ "set the environment variable "
- + "JAVA_HOME or CLASSPATH.";
+ + "JAVA_HOME";
/** Error message to use when there is an error starting the sun rmic compiler */
public static final String ERROR_RMIC_FAILED = "Error starting SUN rmic: ";
Modified: ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java
URL: http://svn.apache.org/viewvc/ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java?rev=593012&r1=593011&r2=593012&view=diff
==============================================================================
--- ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java (original)
+++ ant/core/branches/ANT_17_BRANCH/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java Wed Nov 7 20:57:11 2007
@@ -40,9 +40,7 @@
/** The error string to use if not able to find the weblogic rmic */
public static final String ERROR_NO_WLRMIC_ON_CLASSPATH =
"Cannot use WebLogic rmic, as it is not "
- + "available. A common solution is to "
- + "set the environment variable "
- + "CLASSPATH.";
+ + "available. Add it to Ant's classpath with the -lib option";
/** The error string to use if not able to start the weblogic rmic */
public static final String ERROR_WLRMIC_FAILED = "Error starting WebLogic rmic: ";
@@ -50,6 +48,8 @@
public static final String WL_RMI_STUB_SUFFIX = "_WLStub";
/** The skeleton suffix */
public static final String WL_RMI_SKEL_SUFFIX = "_WLSkel";
+ /** unsupported error message */
+ public static final String UNSUPPORTED_STUB_OPTION = "Unsupported stub option: ";
/**
* Carry out the rmic compilation.
@@ -116,4 +116,19 @@
protected String[] preprocessCompilerArgs(String[] compilerArgs) {
return filterJvmCompilerArgs(compilerArgs);
}
-}
+
+ /**
+ * This is an override point; no stub version is returned. If any
+ * stub option is set, a warning is printed.
+ * @return null, for no stub version
+ */
+ protected String addStubVersionOptions() {
+ //handle the many different stub options.
+ String stubVersion = getRmic().getStubVersion();
+ if (null != stubVersion) {
+ getRmic().log(UNSUPPORTED_STUB_OPTION + stubVersion,
+ Project.MSG_WARN);
+ }
+ return null;
+ }
+}
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org