ant-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hi...@apache.org
Subject svn commit: r1378633 - /ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch
Date Wed, 29 Aug 2012 16:28:39 GMT
Author: hibou
Date: Wed Aug 29 16:28:38 2012
New Revision: 1378633

URL: http://svn.apache.org/viewvc?rev=1378633&view=rev
Log:
Update patch upon Matt suggestions

Modified:
    ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch

Modified: ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch
URL: http://svn.apache.org/viewvc/ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch?rev=1378633&r1=1378632&r2=1378633&view=diff
==============================================================================
--- ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch (original)
+++ ant/sandbox/antdsl/branches/import-experiment/argument-processor.patch Wed Aug 29 16:28:38
2012
@@ -2,7 +2,7 @@ Index: src/main/org/apache/tools/ant/Arg
 ===================================================================
 --- src/main/org/apache/tools/ant/ArgumentProcessor.java	(revision 0)
 +++ src/main/org/apache/tools/ant/ArgumentProcessor.java	(working copy)
-@@ -0,0 +1,80 @@
+@@ -0,0 +1,72 @@
 +/*
 + *  Licensed to the Apache Software Foundation (ASF) under one or more
 + *  contributor license agreements.  See the NOTICE file distributed with
@@ -22,6 +22,7 @@ Index: src/main/org/apache/tools/ant/Arg
 + */
 +package org.apache.tools.ant;
 +
++import java.io.PrintStream;
 +import java.util.List;
 +
 +/**
@@ -37,50 +38,41 @@ Index: src/main/org/apache/tools/ant/Arg
 +public interface ArgumentProcessor {
 +
 +    /**
-+     * Check that the specified argument is handled. It returns 0 if not
-+     * supported. Else it returns the number of expected arguments to read after
-+     * the current one.
++     * Read the arguments from the command line at the specified position
++     * <p>
++     * If the argument is not supported, returns -1. Else, the position of the
++     * first argument not supported.
 +     */
-+    int readArgument(String arg);
++    int readArguments(String[] args, int pos);
 +
 +    /**
-+     * If some arguments matched, this method is called after all arguments were
-+     * parsed. Returns <code>true</code> if Ant should stop there, ie the build
-+     * file not parsed and the project should not be executed.
-+     * <p>
-+     * NB: the size of the argument list might not be the expected one if the
-+     * end user doesn't have provided enough ones.
++     * If some arguments matched with {@link #readArguments(String[], int)},
++     * this method is called after all arguments were parsed. Returns
++     * <code>true</code> if Ant should stop there, ie the build file not parsed
++     * and the project should not be executed.
 +     */
 +    boolean handleArg(List<String> args);
 +
 +    /**
-+     * If some arguments matched, this method is called just before the project
-+     * being configured
-+     * <p>
-+     * NB: the size of the argument list might not be the expected one if the
-+     * end user doesn't have provided enough ones.
++     * If some arguments matched with {@link #readArguments(String[], int)},
++     * this method is called just before the project being configured
 +     */
 +    void prepareConfigure(Project project, List<String> args);
 +
 +    /**
-+     * Handle the arguments, just after the project being configured. Returns
-+     * <code>true</code> if Ant should stop there, ie the build file not parsed
-+     * and the project should not be executed.
-+     * <p>
-+     * NB: the size of the argument list might not be the expected one if the
-+     * end user doesn't have provided enough ones.
++     * Handle the arguments with {@link #readArguments(String[], int)}, just
++     * after the project being configured. Returns <code>true</code> if Ant
++     * should stop there, ie the build file not parsed and the project should
++     * not be executed.
 +     */
 +    boolean handleArg(Project project, List<String> arg);
 +
 +    /**
 +     * Print the usage of the supported arguments
 +     * 
-+     * @param buffer the buffer to populate
-+     * @param lSep the line separator to use
-+     * 
 +     * @see org.apache.tools.ant.Main.printUsage()
 +     */
-+    void printUsage(StringBuffer buffer, String lSep);
++    void printUsage(PrintStream writer);
 +
 +}
 
@@ -102,10 +94,11 @@ Index: src/main/org/apache/tools/ant/Mai
 ===================================================================
 --- src/main/org/apache/tools/ant/Main.java	(revision 1376402)
 +++ src/main/org/apache/tools/ant/Main.java	(working copy)
-@@ -24,12 +24,14 @@
+@@ -24,12 +24,15 @@
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.PrintStream;
++import java.io.PrintWriter;
 +import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.Collections;
@@ -117,7 +110,7 @@ Index: src/main/org/apache/tools/ant/Mai
  import java.util.Map;
  import java.util.Map.Entry;
  import java.util.Properties;
-@@ -152,6 +154,7 @@
+@@ -152,6 +155,7 @@
       */
      private boolean proxy = false;
  
@@ -125,7 +118,7 @@ Index: src/main/org/apache/tools/ant/Mai
  
      private static final GetProperty NOPROPERTIES = new GetProperty(){
          public Object getProperty(String aName) {
-@@ -324,6 +327,8 @@
+@@ -324,6 +328,8 @@
          boolean justPrintVersion = false;
          boolean justPrintDiagnostics = false;
  
@@ -134,7 +127,7 @@ Index: src/main/org/apache/tools/ant/Mai
          for (int i = 0; i < args.length; i++) {
              String arg = args[i];
  
-@@ -399,11 +404,27 @@
+@@ -399,11 +405,29 @@
              } else if (arg.equals("-autoproxy")) {
                  proxy = true;
              } else if (arg.startsWith("-")) {
@@ -145,14 +138,16 @@ Index: src/main/org/apache/tools/ant/Mai
 -                throw new BuildException("");
 +                boolean processed = false;
 +                for (ArgumentProcessor processor : processorRegistry.getProcessors()) {
-+                    int n = processor.readArgument(arg);
-+                    if (n > 0) {
-+                        List<String> extraArgs = new ArrayList<String>();
-+                        extraArgs.add(arg);
-+                        for (int j = 1; j < n && i < args.length - 1; j++)
{
-+                            extraArgs.add(args[++i]);
++                    int newI = processor.readArguments(args, i);
++                    if (newI != -1) {
++                        List<String> extraArgs = extraArguments.get(processor.getClass());
++                        if (extraArgs == null) {
++                            extraArgs = new ArrayList<String>();
++                            extraArguments.put(processor.getClass(), extraArgs);
++                        }
++                        for (; i < newI && i < args.length; i++) {
++                            extraArgs.add(args[i]);
 +                        }
-+                        extraArguments.put(processor.getClass(), extraArgs);
 +                        processed = true;
 +                        break;
 +                    }
@@ -167,7 +162,7 @@ Index: src/main/org/apache/tools/ant/Mai
              } else {
                  // if it's no other arg, it may be the target
                  targets.addElement(arg);
-@@ -726,6 +747,17 @@
+@@ -726,6 +750,17 @@
              return;
          }
  
@@ -185,7 +180,7 @@ Index: src/main/org/apache/tools/ant/Mai
          final Project project = new Project();
          project.setCoreLoader(coreLoader);
  
-@@ -781,8 +813,24 @@
+@@ -781,8 +816,24 @@
                      proxySetup.enableProxies();
                  }
  
@@ -210,18 +205,96 @@ Index: src/main/org/apache/tools/ant/Mai
                  if (projectHelp) {
                      printDescription(project);
                      printTargets(project, msgOutputLevel > Project.MSG_INFO,
-@@ -996,7 +1044,10 @@
-         msg.append("  -noclasspath           Run ant without using CLASSPATH" + lSep);
-         msg.append("  -autoproxy             Java1.5+: use the OS proxy settings"
-                 + lSep);
+@@ -954,50 +1005,45 @@
+      * Prints the usage information for this class to <code>System.out</code>.
+      */
+     private static void printUsage() {
+-        String lSep = System.getProperty("line.separator");
+-        StringBuffer msg = new StringBuffer();
+-        msg.append("ant [options] [target [target2 [target3] ...]]" + lSep);
+-        msg.append("Options: " + lSep);
+-        msg.append("  -help, -h              print this message" + lSep);
+-        msg.append("  -projecthelp, -p       print project help information" + lSep);
+-        msg.append("  -version               print the version information and exit" + lSep);
+-        msg.append("  -diagnostics           print information that might be helpful to"
+ lSep);
+-        msg.append("                         diagnose or report problems." + lSep);
+-        msg.append("  -quiet, -q             be extra quiet" + lSep);
+-        msg.append("  -silent, -S            print nothing but task outputs and build failures"
+ lSep);
+-        msg.append("  -verbose, -v           be extra verbose" + lSep);
+-        msg.append("  -debug, -d             print debugging information" + lSep);
+-        msg.append("  -emacs, -e             produce logging information without adornments"
+-                   + lSep);
+-        msg.append("  -lib <path>            specifies a path to search for jars and
classes"
+-                   + lSep);
+-        msg.append("  -logfile <file>        use given file for log" + lSep);
+-        msg.append("    -l     <file>                ''" + lSep);
+-        msg.append("  -logger <classname>    the class which is to perform logging"
+ lSep);
+-        msg.append("  -listener <classname>  add an instance of class as a project
listener"
+-                   + lSep);
+-        msg.append("  -noinput               do not allow interactive input" + lSep);
+-        msg.append("  -buildfile <file>      use given buildfile" + lSep);
+-        msg.append("    -file    <file>              ''" + lSep);
+-        msg.append("    -f       <file>              ''" + lSep);
+-        msg.append("  -D<property>=<value>   use value for given property" +
lSep);
+-        msg.append("  -keep-going, -k        execute all targets that do not depend" + lSep);
+-        msg.append("                         on failed target(s)" + lSep);
+-        msg.append("  -propertyfile <name>   load all properties from file with -D"
+ lSep);
+-        msg.append("                         properties taking precedence" + lSep);
+-        msg.append("  -inputhandler <class>  the class which will handle input requests"
+ lSep);
+-        msg.append("  -find <file>           (s)earch for buildfile towards the root
of" + lSep);
+-        msg.append("    -s  <file>           the filesystem and use it" + lSep);
+-        msg.append("  -nice  number          A niceness value for the main thread:" + lSep
+-                   + "                         1 (lowest) to 10 (highest); 5 is the default"
+-                   + lSep);
+-        msg.append("  -nouserlib             Run ant without using the jar files from" +
lSep
+-                   + "                         ${user.home}/.ant/lib" + lSep);
+-        msg.append("  -noclasspath           Run ant without using CLASSPATH" + lSep);
+-        msg.append("  -autoproxy             Java1.5+: use the OS proxy settings"
+-                + lSep);
 -        msg.append("  -main <class>          override Ant's normal entry point");
-+        msg.append("  -main <class>          override Ant's normal entry point" +
lSep);
+-        System.out.println(msg.toString());
++        System.out.println("ant [options] [target [target2 [target3] ...]]");
++        System.out.println("Options: ");
++        System.out.println("  -help, -h              print this message");
++        System.out.println("  -projecthelp, -p       print project help information");
++        System.out.println("  -version               print the version information and exit");
++        System.out.println("  -diagnostics           print information that might be helpful
to");
++        System.out.println("                         diagnose or report problems.");
++        System.out.println("  -quiet, -q             be extra quiet");
++        System.out.println("  -silent, -S            print nothing but task outputs and
build failures");
++        System.out.println("  -verbose, -v           be extra verbose");
++        System.out.println("  -debug, -d             print debugging information");
++        System.out.println("  -emacs, -e             produce logging information without
adornments");
++        System.out.println("  -lib <path>            specifies a path to search for
jars and classes");
++        System.out.println("  -logfile <file>        use given file for log");
++        System.out.println("    -l     <file>                ''");
++        System.out.println("  -logger <classname>    the class which is to perform
logging");
++        System.out.println("  -listener <classname>  add an instance of class as a
project listener");
++        System.out.println("  -noinput               do not allow interactive input");
++        System.out.println("  -buildfile <file>      use given buildfile");
++        System.out.println("    -file    <file>              ''");
++        System.out.println("    -f       <file>              ''");
++        System.out.println("  -D<property>=<value>   use value for given property");
++        System.out.println("  -keep-going, -k        execute all targets that do not depend");
++        System.out.println("                         on failed target(s)");
++        System.out.println("  -propertyfile <name>   load all properties from file
with -D");
++        System.out.println("                         properties taking precedence");
++        System.out.println("  -inputhandler <class>  the class which will handle input
requests");
++        System.out.println("  -find <file>           (s)earch for buildfile towards
the root of");
++        System.out.println("    -s  <file>           the filesystem and use it");
++        System.out.println("  -nice  number          A niceness value for the main thread:"
++                + "                         1 (lowest) to 10 (highest); 5 is the default");
++        System.out.println("  -nouserlib             Run ant without using the jar files
from"
++                + "                         ${user.home}/.ant/lib");
++        System.out.println("  -noclasspath           Run ant without using CLASSPATH");
++        System.out.println("  -autoproxy             Java1.5+: use the OS proxy settings");
++        System.out.println("  -main <class>          override Ant's normal entry point");
 +        for (ArgumentProcessor processor : ArgumentProcessorRegistry.getInstance().getProcessors())
{
-+            processor.printUsage(msg, lSep);
++            processor.printUsage(System.out);
 +        }
-         System.out.println(msg.toString());
      }
  
+     /**
 Index: src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java
 ===================================================================
 --- src/main/org/apache/tools/ant/ArgumentProcessorRegistry.java	(revision 0)



Mime
View raw message