diff --git a/WHATSNEW b/WHATSNEW index ea3b7c031..2d6a7d077 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -47,6 +47,9 @@ Other changes: * The family of tasks has been sped up for bigger archives. Bugzilla Report 48755. + + * Add removeKeepExtension option to NetRexxC task. + Bugzilla Report 48788. Changes from Ant 1.8.0RC1 TO Ant 1.8.0 ====================================== diff --git a/docs/manual/OptionalTasks/netrexxc.html b/docs/manual/OptionalTasks/netrexxc.html index 88215de2e..c336b7cd3 100644 --- a/docs/manual/OptionalTasks/netrexxc.html +++ b/docs/manual/OptionalTasks/netrexxc.html @@ -98,7 +98,7 @@ or from the command line as
console Whether or not messages should be displayed on the - 'console' + 'console'. Note that this task will rely on the default value for filtering compile messages. No @@ -109,7 +109,8 @@ or from the command line as
decimal Whether decimal arithmetic should be used for the - NetRexx code + NetRexx code. Setting this to off will report decimal arithmetic + as an error, for performance critical applications. No @@ -177,7 +178,7 @@ or from the command line as
keep Sets whether the generated java source file should be kept after compilation. The generated files will have an extension of - .java.keep, not .java + .java.keep, not .java. Use removeKeepExtension to change that. No @@ -186,6 +187,13 @@ or from the command line as
compiling No + + removeKeepExtension + Tells wether the trailing .keep in nocompile-mode should + be removed so that the resulting java source really ends on .java. This + facilitates the use of the javadoc tool lateron. + No + replace Whether the generated .java file should be replaced @@ -283,33 +291,33 @@ or from the command line as
suppressMethodArgumentNotUsed Tells whether we should filter out the &Method argument not used& messages in strictargs mode. - no + No suppressPrivatePropertyNotUsed Tells whether we should filter out the &Private Property defined, but not used& messages in strictargs mode. - no + No suppressVariableNotUsed Tells whether we should filter out the &Variable set but not used& messages in strictargs mode. Please be careful with this one, as you can hide errors behind it! - no + No suppressExceptionNotSignalled Tells whether we should filter out the &Exception is declared, but not signaled within the method& messages in strictsignal mode. - no + No suppressDeprecation Tells whether we should filter out any deprecation-messages of the compiler out. - no + No

Examples

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java index 9399f9bff..ab7209469 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java @@ -73,6 +73,7 @@ import org.apache.tools.ant.util.FileUtils; *
  • suppressVariableNotUsed
  • *
  • suppressExceptionNotSignalled
  • *
  • suppressDeprecation
  • + *
  • removeKeepExtension
  • * * Of these arguments, the srcdir argument is required. * @@ -126,6 +127,7 @@ public class NetRexxC extends MatchingTask { private boolean suppressVariableNotUsed = false; private boolean suppressExceptionNotSignalled = false; private boolean suppressDeprecation = false; + private boolean removeKeepExtension = false; // constants for the messages to suppress by flags and their corresponding properties static final String MSG_METHOD_ARGUMENT_NOT_USED @@ -144,6 +146,8 @@ public class NetRexxC extends MatchingTask { /** * Set whether literals are treated as binary, rather than NetRexx types. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default is false. * @param binary a boolean value. */ public void setBinary(boolean binary) { @@ -162,8 +166,8 @@ public class NetRexxC extends MatchingTask { /** * Set whether comments are passed through to the generated java source. - * Valid true values are "on" or "true". Anything else sets the flag to - * false. The default value is false + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param comments a boolean value. */ public void setComments(boolean comments) { @@ -172,9 +176,9 @@ public class NetRexxC extends MatchingTask { /** - * Set whether error messages come out in compact or verbose format. Valid - * true values are "on" or "true". Anything else sets the flag to false. - * The default value is false + * Set whether error messages come out in compact or verbose format. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is true. * @param compact a boolean value. */ public void setCompact(boolean compact) { @@ -183,10 +187,10 @@ public class NetRexxC extends MatchingTask { /** - * Set whether the NetRexx compiler should compile the generated java code - * Valid true values are "on" or "true". Anything else sets the flag to - * false. The default value is true. Setting this flag to false, will - * automatically set the keep flag to true. + * Set whether the NetRexx compiler should compile the generated java code. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is true. + * Setting this flag to false, will automatically set the keep flag to true. * @param compile a boolean value. */ public void setCompile(boolean compile) { @@ -198,9 +202,10 @@ public class NetRexxC extends MatchingTask { /** - * Set whether or not messages should be displayed on the 'console' Valid - * true values are "on" or "true". Anything else sets the flag to false. - * The default value is true. + * Set whether or not compiler messages should be displayed on the 'console'. + * Note that this task will rely on the default value for filtering compile messages. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param console a boolean value. */ public void setConsole(boolean console) { @@ -210,6 +215,8 @@ public class NetRexxC extends MatchingTask { /** * Whether variable cross references are generated. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param crossref a boolean value. */ public void setCrossref(boolean crossref) { @@ -219,9 +226,10 @@ public class NetRexxC extends MatchingTask { /** * Set whether decimal arithmetic should be used for the netrexx code. - * Binary arithmetic is used when this flag is turned off. Valid true - * values are "on" or "true". Anything else sets the flag to false. The - * default value is true. + * Setting this to off will report decimal arithmetic as an error, for + * performance critical applications. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is true. * @param decimal a boolean value. */ public void setDecimal(boolean decimal) { @@ -249,8 +257,8 @@ public class NetRexxC extends MatchingTask { /** - * Sets whether variables must be declared explicitly before use. Valid - * true values are "on" or "true". Anything else sets the flag to false. + * Sets whether variables must be declared explicitly before use. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. * The default value is false. * @param explicit a boolean value. */ @@ -262,6 +270,8 @@ public class NetRexxC extends MatchingTask { /** * Whether the generated java code is formatted nicely or left to match * NetRexx line numbers for call stack debugging. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value false. * @param format a boolean value. */ public void setFormat(boolean format) { @@ -270,9 +280,8 @@ public class NetRexxC extends MatchingTask { /** - * Whether the generated java code is produced Valid true values are "on" - * or "true". Anything else sets the flag to false. The default value is - * false. + * Whether the generated java code is produced. + * This is not implemented yet. * @param java a boolean value. */ public void setJava(boolean java) { @@ -283,9 +292,11 @@ public class NetRexxC extends MatchingTask { /** * Sets whether the generated java source file should be kept after * compilation. The generated files will have an extension of .java.keep, - * not .java Valid true values are "on" or "true". Anything else - * sets the flag to false. The default value is false. + * not .java. See setRemoveKeepExtension + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param keep a boolean value. + * @see #setRemoveKeepExtension(boolean) */ public void setKeep(boolean keep) { this.keep = keep; @@ -294,6 +305,8 @@ public class NetRexxC extends MatchingTask { /** * Whether the compiler text logo is displayed when compiling. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param logo a boolean value. */ public void setLogo(boolean logo) { @@ -302,9 +315,9 @@ public class NetRexxC extends MatchingTask { /** - * Whether the generated .java file should be replaced when compiling - * Valid true values are "on" or "true". Anything else sets the flag to - * false. The default value is false. + * Whether the generated .java file should be replaced when compiling. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param replace a boolean value. */ public void setReplace(boolean replace) { @@ -314,8 +327,9 @@ public class NetRexxC extends MatchingTask { /** * Sets whether the compiler messages will be written to NetRexxC.log as - * well as to the console Valid true values are "on" or "true". Anything - * else sets the flag to false. The default value is false. + * well as to the console. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param savelog a boolean value. */ public void setSavelog(boolean savelog) { @@ -325,9 +339,9 @@ public class NetRexxC extends MatchingTask { /** * Tells the NetRexx compiler to store the class files in the same - * directory as the source files. The alternative is the working directory - * Valid true values are "on" or "true". Anything else sets the flag to - * false. The default value is true. + * directory as the source files. The alternative is the working directory. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is true. * @param sourcedir a boolean value. */ public void setSourcedir(boolean sourcedir) { @@ -347,9 +361,9 @@ public class NetRexxC extends MatchingTask { /** * Tells the NetRexx compiler that method calls always need parentheses, * even if no arguments are needed, e.g. aStringVar.getBytes - * vs. aStringVar.getBytes() Valid true values are "on" or - * "true". Anything else sets the flag to false. The default value is - * false. + * vs. aStringVar.getBytes(). + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param strictargs a boolean value. */ public void setStrictargs(boolean strictargs) { @@ -359,6 +373,8 @@ public class NetRexxC extends MatchingTask { /** * Tells the NetRexx compile that assignments must match exactly on type. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param strictassign a boolean value. */ public void setStrictassign(boolean strictassign) { @@ -368,6 +384,8 @@ public class NetRexxC extends MatchingTask { /** * Specifies whether the NetRexx compiler should be case sensitive or not. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param strictcase a boolean value. */ public void setStrictcase(boolean strictcase) { @@ -378,8 +396,9 @@ public class NetRexxC extends MatchingTask { /** * Sets whether classes need to be imported explicitly using an import * statement. By default the NetRexx compiler will import certain packages - * automatically Valid true values are "on" or "true". Anything else sets - * the flag to false. The default value is false. + * automatically. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param strictimport a boolean value. */ public void setStrictimport(boolean strictimport) { @@ -389,8 +408,9 @@ public class NetRexxC extends MatchingTask { /** * Sets whether local properties need to be qualified explicitly using - * this Valid true values are "on" or "true". Anything else - * sets the flag to false. The default value is false. + * this. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param strictprops a boolean value. */ public void setStrictprops(boolean strictprops) { @@ -401,6 +421,8 @@ public class NetRexxC extends MatchingTask { /** * Whether the compiler should force catching of exceptions by explicitly * named types. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false * @param strictsignal a boolean value. */ public void setStrictsignal(boolean strictsignal) { @@ -409,9 +431,9 @@ public class NetRexxC extends MatchingTask { /** - * Sets whether debug symbols should be generated into the class file - * Valid true values are "on" or "true". Anything else sets the flag to - * false. The default value is false. + * Sets whether debug symbols should be generated into the class file. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param symbols a boolean value. */ public void setSymbols(boolean symbols) { @@ -421,8 +443,8 @@ public class NetRexxC extends MatchingTask { /** * Asks the NetRexx compiler to print compilation times to the console - * Valid true values are "on" or "true". Anything else sets the flag to - * false. The default value is false. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param time a boolean value. */ public void setTime(boolean time) { @@ -454,9 +476,9 @@ public class NetRexxC extends MatchingTask { /** - * Tells the NetRexx compiler that the source is in UTF8 Valid true values - * are "on" or "true". Anything else sets the flag to false. The default - * value is false. + * Tells the NetRexx compiler that the source is in UTF8. + * Valid true values are "yes", "on" or "true". Anything else sets the flag to false. + * The default value is false. * @param utf8 a boolean value. */ public void setUtf8(boolean utf8) { @@ -538,6 +560,16 @@ public class NetRexxC extends MatchingTask { } + /** + * Tells wether the trailing .keep in nocompile-mode should be removed + * so that the resulting java source really ends on .java. + * This facilitates the use of the javadoc tool lateron. + */ + public void setRemoveKeepExtension(boolean removeKeepExtension) { + this.removeKeepExtension = removeKeepExtension; + } + + /** * init-Method sets defaults from Properties. That way, when ant is called * with arguments like -Dant.netrexxc.verbose=verbose5 one can easily take @@ -642,6 +674,9 @@ public class NetRexxC extends MatchingTask { if ((p = getProject().getProperty("ant.netrexxc.suppressDeprecation")) != null) { this.suppressDeprecation = Project.toBoolean(p); } + if ((p = getProject().getProperty("ant.netrexxc.removeKeepExtension")) != null) { + this.removeKeepExtension = Project.toBoolean(p); + } } @@ -674,6 +709,9 @@ public class NetRexxC extends MatchingTask { + (compileList.size() == 1 ? "" : "s") + " to " + destDir); doNetRexxCompile(); + if (removeKeepExtension && (!compile || keep)) { + removeKeepExtensions(); + } } } @@ -695,8 +733,18 @@ public class NetRexxC extends MatchingTask { File classFile = new File(destDir, filename.substring(0, filename.lastIndexOf('.')) + ".class"); + File javaFile = + new File(destDir, + filename.substring(0, filename.lastIndexOf('.')) + + (removeKeepExtension ? ".java" : ".java.keep")); - if (!compile || srcFile.lastModified() > classFile.lastModified()) { + // nocompile case tests against .java[.keep] file + if (!compile && srcFile.lastModified() > javaFile.lastModified()) { + filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); + compileList.addElement(destFile.getAbsolutePath()); + } + // compile case tests against .class file + else if (compile && srcFile.lastModified() > classFile.lastModified()) { filecopyList.put(srcFile.getAbsolutePath(), destFile.getAbsolutePath()); compileList.addElement(destFile.getAbsolutePath()); } @@ -735,6 +783,30 @@ public class NetRexxC extends MatchingTask { } + /** + * Rename .java.keep files (back) to .java. The netrexxc renames all + * .java files to .java.keep if either -keep or -nocompile option is set. + */ + private void removeKeepExtensions() { + if (compileList.size() > 0) { + log("Removing .keep extension on " + compileList.size() + " file" + + (compileList.size() == 1 ? "" : "s")); + Enumeration e = compileList.elements(); + while (e.hasMoreElements()) { + String nrxName = (String) e.nextElement(); + String baseName = nrxName.substring(0, nrxName.lastIndexOf('.')); + File fromFile = new File(baseName + ".java.keep"); + File toFile = new File(baseName + ".java"); + if (fromFile.renameTo(toFile)) { + log("Successfully renamed " + fromFile + " to " + toFile, Project.MSG_VERBOSE); + } else { + log("Failed to rename " + fromFile + " to " + toFile); + } + } + } + } + + /** Performs a compile using the NetRexx 1.1.x compiler */ private void doNetRexxCompile() throws BuildException { log("Using NetRexx compiler", Project.MSG_VERBOSE);