ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bode...@apache.org
Subject svn commit: r788677 - in /ant/core/trunk: ./ docs/manual/ docs/manual/CoreTasks/ docs/manual/OptionalTasks/ src/main/org/apache/tools/ant/types/ src/tests/junit/org/apache/tools/ant/types/
Date Fri, 26 Jun 2009 12:41:51 GMT
Author: bodewig
Date: Fri Jun 26 12:41:50 2009
New Revision: 788677

URL: http://svn.apache.org/viewvc?rev=788677&view=rev
Log:
prefix and suffix attributes for command line arguments, PR 47365, submitted by Martin von
Gagern

Modified:
    ant/core/trunk/WHATSNEW
    ant/core/trunk/docs/manual/CoreTasks/javac.html
    ant/core/trunk/docs/manual/CoreTasks/rmic.html
    ant/core/trunk/docs/manual/OptionalTasks/javah.html
    ant/core/trunk/docs/manual/using.html
    ant/core/trunk/src/main/org/apache/tools/ant/types/Commandline.java
    ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java

Modified: ant/core/trunk/WHATSNEW
URL: http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=788677&r1=788676&r2=788677&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Fri Jun 26 12:41:50 2009
@@ -737,6 +737,10 @@
  * <input ...><handler type="secure" /></input> now uses previously undocumented
    SecureInputHandler shipped with Ant 1.7.1.
 
+ * Command line arguments for <exec> and similar tasks can now have
+   optional prefix and suffix attributes.
+   Bugzilla Report 47365
+
 Changes from Ant 1.7.0 TO Ant 1.7.1
 =============================================
 

Modified: ant/core/trunk/docs/manual/CoreTasks/javac.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/javac.html?rev=788677&r1=788676&r2=788677&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/javac.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/javac.html Fri Jun 26 12:41:50 2009
@@ -485,6 +485,17 @@
     <td valign="top">path</td>
   </tr>
   <tr>
+    <td valign="top">prefix</td>
+    <td align="center" rowspan="2">See
+    <a href="../using.html#arg">Command-line Arguments</a>.
+    <em>Since Ant 1.8.</em></td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
+    <td valign="top">suffix</td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
     <td valign="top">compiler</td>
     <td>Only pass the specified argument if the chosen
       compiler implementation matches the value of this attribute.

Modified: ant/core/trunk/docs/manual/CoreTasks/rmic.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/CoreTasks/rmic.html?rev=788677&r1=788676&r2=788677&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/CoreTasks/rmic.html (original)
+++ ant/core/trunk/docs/manual/CoreTasks/rmic.html Fri Jun 26 12:41:50 2009
@@ -245,6 +245,17 @@
     <td valign="top">path</td>
   </tr>
   <tr>
+    <td valign="top">prefix</td>
+    <td align="center" rowspan="2">See
+    <a href="../using.html#arg">Command-line Arguments</a>.
+    <em>Since Ant 1.8.</em></td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
+    <td valign="top">suffix</td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
     <td valign="top">compiler</td>
     <td>Only pass the specified argument if the chosen
       compiler implementation matches the value of this attribute.

Modified: ant/core/trunk/docs/manual/OptionalTasks/javah.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/OptionalTasks/javah.html?rev=788677&r1=788676&r2=788677&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/OptionalTasks/javah.html (original)
+++ ant/core/trunk/docs/manual/OptionalTasks/javah.html Fri Jun 26 12:41:50 2009
@@ -144,6 +144,17 @@
     <td valign="top">path</td>
   </tr>
   <tr>
+    <td valign="top">prefix</td>
+    <td align="center" rowspan="2">See
+    <a href="../using.html#arg">Command-line Arguments</a>.
+    <em>Since Ant 1.8.</em></td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
+    <td valign="top">suffix</td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
     <td valign="top">implementation</td>
     <td>Only pass the specified argument if the chosen compiler
     implementation matches the value of this attribute.  Legal values

Modified: ant/core/trunk/docs/manual/using.html
URL: http://svn.apache.org/viewvc/ant/core/trunk/docs/manual/using.html?rev=788677&r1=788676&r2=788677&view=diff
==============================================================================
--- ant/core/trunk/docs/manual/using.html (original)
+++ ant/core/trunk/docs/manual/using.html Fri Jun 26 12:41:50 2009
@@ -580,6 +580,20 @@
     <td valign="top">line</td>
     <td valign="top">a space-delimited list of command-line arguments.</td>
   </tr>
+  <tr>
+    <td valign="top">prefix</td>
+    <td valign="top">A fixed string to be placed in front of the
+      argument. In the case of a line broken into parts, it will be
+      placed in front of every part. <em>Since Ant 1.8.</em></td>
+    <td valign="top" align="center">No</td>
+  </tr>
+  <tr>
+    <td valign="top">suffix</td>
+    <td valign="top">A fixed string to be placed immediately after the
+      argument. In the case of a line broken into parts, it will be
+      placed after every part. <em>Since Ant 1.8.</em></td>
+    <td valign="top" align="center">No</td>
+  </tr>
 </table>
 
 <p>It is highly recommended to avoid the <code>line</code> version

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/Commandline.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/Commandline.java?rev=788677&r1=788676&r2=788677&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/Commandline.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/Commandline.java Fri Jun 26 12:41:50
2009
@@ -103,6 +103,9 @@
 
         private String[] parts;
 
+        private String prefix = "";
+        private String suffix = "";
+
         /**
          * Set a single commandline argument.
          *
@@ -159,11 +162,41 @@
         }
 
         /**
+         * Set the prefix to be placed in front of every part of the
+         * argument.
+         *
+         * @param prefix fixed prefix string.
+         * @since Ant 1.8.0
+         */
+        public void setPrefix(String prefix) {
+            this.prefix = prefix != null ? prefix : "";
+        }
+
+        /**
+         * Set the suffix to be placed at the end of every part of the
+         * argument.
+         *
+         * @param suffix fixed suffix string.
+         * @since Ant 1.8.0
+         */
+        public void setSuffix(String suffix) {
+            this.suffix = suffix != null ? suffix : "";
+        }
+
+        /**
          * Return the constituent parts of this Argument.
          * @return an array of strings.
          */
         public String[] getParts() {
-            return parts;
+            if (parts == null || parts.length == 0
+                || (prefix.length() == 0 && suffix.length() == 0)) {
+                return parts;
+            }
+            String[] fullParts = new String[parts.length];
+            for (int i = 0; i < fullParts.length; ++i) {
+                fullParts[i] = prefix + parts[i] + suffix;
+            }
+            return fullParts;
         }
     }
 

Modified: ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java?rev=788677&r1=788676&r2=788677&view=diff
==============================================================================
--- ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java (original)
+++ ant/core/trunk/src/tests/junit/org/apache/tools/ant/types/CommandlineTest.java Fri Jun
26 12:41:50 2009
@@ -130,7 +130,7 @@
         assertEquals("1 \'2\"3\'", Commandline.toString(new String[] {"1", "2\"3"}));
     }
 
-    public void testAwkCommand(){
+    public void testAwkCommand() {
         Commandline c = new Commandline();
         c.setExecutable("awk");
         c.createArgument().setValue("'NR == 2 { print $NF }'");
@@ -140,4 +140,24 @@
         assertEquals("awk", s[0]);
         assertEquals("'NR == 2 { print $NF }'", s[1]);
     }
+
+    public void testPrefix() {
+        Commandline c = new Commandline();
+        Commandline.Argument a = c.createArgument();
+        a.setValue("foo");
+        a.setPrefix("-f=");
+        String[] s = c.getCommandline();
+        assertEquals(1, s.length);
+        assertEquals("-f=foo", s[0]);
+    }
+
+    public void testSuffix() {
+        Commandline c = new Commandline();
+        Commandline.Argument a = c.createArgument();
+        a.setValue("foo");
+        a.setSuffix(",1");
+        String[] s = c.getCommandline();
+        assertEquals(1, s.length);
+        assertEquals("foo,1", s[0]);
+    }
 }



Mime
View raw message