diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java b/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java index ae6b16611..674bc5b2d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/DefaultRmicAdapter.java @@ -43,19 +43,32 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { 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 */ @@ -196,35 +209,13 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { 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 +252,40 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { return cmd; } + /** + * 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. @@ -386,7 +411,7 @@ public abstract class DefaultRmicAdapter implements RmicAdapter { 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" }; diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java index bde37393c..573943860 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/SunRmic.java @@ -52,7 +52,7 @@ public class SunRmic extends DefaultRmicAdapter { 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: "; diff --git a/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java b/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java index 5682bec95..80dc0aa36 100644 --- a/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java +++ b/src/main/org/apache/tools/ant/taskdefs/rmic/WLRmic.java @@ -19,6 +19,9 @@ package org.apache.tools.ant.taskdefs.rmic; import java.lang.reflect.Method; +import java.util.List; +import java.util.ArrayList; + import org.apache.tools.ant.AntClassLoader; import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; @@ -40,9 +43,7 @@ public class WLRmic extends DefaultRmicAdapter { /** 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 +51,7 @@ public class WLRmic extends DefaultRmicAdapter { public static final String WL_RMI_STUB_SUFFIX = "_WLStub"; /** The skeleton suffix */ public static final String WL_RMI_SKEL_SUFFIX = "_WLSkel"; + public static final String UNSUPPORTED_STUB_OPTION = "Unsupported stub option: "; /** * Carry out the rmic compilation. @@ -116,4 +118,19 @@ public class WLRmic extends DefaultRmicAdapter { 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; + } + }