Author: antoine
Date: Mon Feb 22 02:11:10 2010
New Revision: 912463

URL: http://svn.apache.org/viewvc?rev=912463&view=rev
Log:
Bug 48788 -  add removeKeepExtension option to NetRexxC task - patch submitted 
by Patric Bechtel (bechtel at ipcon dot de)

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/OptionalTasks/netrexxc.html
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java

Modified: ant/core/trunk/WHATSNEW
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=912463&r1=912462&r2=912463&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Mon Feb 22 02:11:10 2010
@@ -47,6 +47,9 @@
 
  * The <zip> 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
 ======================================

Modified: ant/core/trunk/docs/manual/OptionalTasks/netrexxc.html
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/netrexxc.html?rev=912463&r1=912462&r2=912463&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/netrexxc.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/netrexxc.html Mon Feb 22 02:11:10 
2010
@@ -98,7 +98,7 @@
   <tr>
     <td valign="top">console</td>
     <td valign="top">Whether or not messages should be displayed on the
-      'console'</td>
+      'console'. Note that this task will rely on the default value for 
filtering compile messages.</td>
     <td valign="top" align="center">No</td>
   </tr>
   <tr>
@@ -109,7 +109,8 @@
   <tr>
     <td valign="top">decimal</td>
     <td valign="top">Whether decimal arithmetic should be used for the
-      NetRexx code</td>
+      NetRexx code. Setting this to off will report decimal arithmetic
+      as an error, for performance critical applications.</td>
     <td valign="top" align="center">No</td>
   </tr>
   <tr>
@@ -177,7 +178,7 @@
     <td valign="top">keep</td>
     <td valign="top">Sets whether the generated java source file should be kept
       after compilation. The generated files will have an extension of
-      .java.keep, <b>not</b> .java</td>
+      .java.keep, <b>not</b> .java. Use removeKeepExtension to change 
that.</td>
     <td valign="top" align="center">No</td>
   </tr>
   <tr>
@@ -187,6 +188,13 @@
     <td valign="top" align="center">No</td>
   </tr>
   <tr>
+    <td valign="top">removeKeepExtension</td>
+    <td valign="top">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.</td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
     <td valign="top">replace</td>
     <td valign="top">Whether the generated .java file should be replaced
       when compiling</td>
@@ -283,33 +291,33 @@
     <td valign="top">suppressMethodArgumentNotUsed</td>
     <td valign="top">Tells whether we should filter out the
       &amp;Method argument not used&amp; messages in strictargs mode.</td>
-    <td valign="top" align="center">no</td>
+    <td valign="top" align="center">No</td>
   </tr>
   <tr>
     <td valign="top">suppressPrivatePropertyNotUsed</td>
     <td valign="top">Tells whether we should filter out the
       &amp;Private Property defined, but not used&amp; messages in strictargs 
mode.</td>
-    <td valign="top" align="center">no</td>
+    <td valign="top" align="center">No</td>
   </tr>
   <tr>
     <td valign="top">suppressVariableNotUsed</td>
     <td valign="top">Tells whether we should filter out the
       &amp;Variable set but not used&amp; messages in strictargs mode.
       Please be careful with this one, as you can hide errors behind it!</td>
-    <td valign="top" align="center">no</td>
+    <td valign="top" align="center">No</td>
   </tr>
   <tr>
     <td valign="top">suppressExceptionNotSignalled</td>
     <td valign="top">Tells whether we should filter out the
       &amp;Exception is declared, but not signaled within the method&amp;
       messages in strictsignal mode.</td>
-    <td valign="top" align="center">no</td>
+    <td valign="top" align="center">No</td>
   </tr>
   <tr>
     <td valign="top">suppressDeprecation</td>
     <td valign="top">Tells whether we should filter out any 
deprecation-messages
       of the compiler out.</td>
-    <td valign="top" align="center">no</td>
+    <td valign="top" align="center">No</td>
   </tr>
 </table>
 <h3>Examples</h3>

Modified: 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java
URL: 
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java?rev=912463&r1=912462&r2=912463&view=diff
==============================================================================
--- 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java 
(original)
+++ 
ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/optional/NetRexxC.java 
Mon Feb 22 02:11:10 2010
@@ -73,6 +73,7 @@
  * <li>suppressVariableNotUsed</li>
  * <li>suppressExceptionNotSignalled</li>
  * <li>suppressDeprecation</li>
+ * <li>removeKeepExtension</li>
  * </ul>
  * Of these arguments, the <b>srcdir</b> argument is required.
  *
@@ -126,6 +127,7 @@
     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 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setBinary(boolean binary) {
@@ -162,8 +166,8 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setComments(boolean comments) {
@@ -172,9 +176,9 @@
 
 
     /**
-     * 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 <code>boolean</code> value.
      */
     public void setCompact(boolean compact) {
@@ -183,10 +187,10 @@
 
 
     /**
-     * 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 <code>boolean</code> value.
      */
     public void setCompile(boolean compile) {
@@ -198,9 +202,10 @@
 
 
     /**
-     * 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 <code>boolean</code> value.
      */
     public void setConsole(boolean console) {
@@ -210,6 +215,8 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setCrossref(boolean crossref) {
@@ -219,9 +226,10 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setDecimal(boolean decimal) {
@@ -249,8 +257,8 @@
 
 
     /**
-     * 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 <code>boolean</code> value.
      */
@@ -262,6 +270,8 @@
     /**
      * 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 <code>boolean</code> value.
      */
     public void setFormat(boolean format) {
@@ -270,9 +280,8 @@
 
 
     /**
-     * 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 <code>boolean</code> value.
      */
     public void setJava(boolean java) {
@@ -283,9 +292,11 @@
     /**
      * Sets whether the generated java source file should be kept after
      * compilation. The generated files will have an extension of .java.keep,
-     * <b>not</b> .java Valid true values are "on" or "true". Anything else
-     * sets the flag to false. The default value is false.
+     * <b>not</b> .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 <code>boolean</code> value.
+     * @see #setRemoveKeepExtension(boolean)
      */
     public void setKeep(boolean keep) {
         this.keep = keep;
@@ -294,6 +305,8 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setLogo(boolean logo) {
@@ -302,9 +315,9 @@
 
 
     /**
-     * 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 <code>boolean</code> value.
      */
     public void setReplace(boolean replace) {
@@ -314,8 +327,9 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setSavelog(boolean savelog) {
@@ -325,9 +339,9 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setSourcedir(boolean sourcedir) {
@@ -347,9 +361,9 @@
     /**
      * Tells the NetRexx compiler that method calls always need parentheses,
      * even if no arguments are needed, e.g. <code>aStringVar.getBytes</code>
-     * vs. <code>aStringVar.getBytes()</code> Valid true values are "on" or
-     * "true". Anything else sets the flag to false. The default value is
-     * false.
+     * vs. <code>aStringVar.getBytes()</code>.
+     * Valid true values are "yes", "on" or "true". Anything else sets the 
flag to false.
+     * The default value is false.
      * @param strictargs a <code>boolean</code> value.
      */
     public void setStrictargs(boolean strictargs) {
@@ -359,6 +373,8 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setStrictassign(boolean strictassign) {
@@ -368,6 +384,8 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setStrictcase(boolean strictcase) {
@@ -378,8 +396,9 @@
     /**
      * Sets whether classes need to be imported explicitly using an 
<code>import</code>
      * 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 <code>boolean</code> value.
      */
     public void setStrictimport(boolean strictimport) {
@@ -389,8 +408,9 @@
 
     /**
      * Sets whether local properties need to be qualified explicitly using
-     * <code>this</code> Valid true values are "on" or "true". Anything else
-     * sets the flag to false. The default value is false.
+     * <code>this</code>.
+     * Valid true values are "yes", "on" or "true". Anything else sets the 
flag to false.
+     * The default value is false.
      * @param strictprops a <code>boolean</code> value.
      */
     public void setStrictprops(boolean strictprops) {
@@ -401,6 +421,8 @@
     /**
      * 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 <code>boolean</code> value.
      */
     public void setStrictsignal(boolean strictsignal) {
@@ -409,9 +431,9 @@
 
 
     /**
-     * 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 <code>boolean</code> value.
      */
     public void setSymbols(boolean symbols) {
@@ -421,8 +443,8 @@
 
     /**
      * 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 <code>boolean</code> value.
      */
     public void setTime(boolean time) {
@@ -454,9 +476,9 @@
 
 
     /**
-     * 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 <code>boolean</code> value.
      */
     public void setUtf8(boolean utf8) {
@@ -539,6 +561,16 @@
 
 
     /**
+     * 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
      * control of all netrexxc-tasks.
@@ -642,6 +674,9 @@
         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 @@
                  + (compileList.size() == 1 ? "" : "s")
                  + " to " + destDir);
             doNetRexxCompile();
+            if (removeKeepExtension && (!compile || keep)) {
+                removeKeepExtensions();
+            }
         }
     }
 
@@ -695,8 +733,18 @@
                 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 @@
     }
 
 
+    /**
+     * 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);


Reply via email to