ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Erik Hatcher" <jakarta-...@ehatchersolutions.com>
Subject Re: cvs commit: jakarta-ant/docs/manual running.html
Date Fri, 01 Feb 2002 22:33:26 GMT
Peter gave the thumbs up, so I figured I'd commit it... but of course if
there are any objections speak up.

I made sure that -D properties take ultimate precedence, which I felt was
mandatory for this change to be worthwhile.

    Erik

----- Original Message -----
From: <ehatcher@apache.org>
To: <jakarta-ant-cvs@apache.org>
Sent: Friday, February 01, 2002 5:27 PM
Subject: cvs commit: jakarta-ant/docs/manual running.html


> ehatcher    02/02/01 14:27:38
>
>   Modified:    src/main/org/apache/tools/ant Main.java
>                docs/manual running.html
>   Log:
>   Add -propertyfile command-line option.
>
>   Revision  Changes    Path
>   1.54      +42 -2     jakarta-ant/src/main/org/apache/tools/ant/Main.java
>
>   Index: Main.java
>   ===================================================================
>   RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/Main.java,v
>   retrieving revision 1.53
>   retrieving revision 1.54
>   diff -u -r1.53 -r1.54
>   --- Main.java 10 Jan 2002 11:21:19 -0000 1.53
>   +++ Main.java 1 Feb 2002 22:27:38 -0000 1.54
>   @@ -55,6 +55,7 @@
>    package org.apache.tools.ant;
>
>    import java.io.File;
>   +import java.io.FileInputStream;
>    import java.io.PrintStream;
>    import java.io.FileOutputStream;
>    import java.io.IOException;
>   @@ -100,6 +101,9 @@
>
>        /** Names of classes to add as listeners to project */
>        private Vector listeners = new Vector(5);
>   +
>   +    /** File names of property files to load on startup */
>   +    private Vector propertyFiles = new Vector(5);
>
>        /**
>         * The Ant logger class. There may be only one logger. It will have
the
>   @@ -294,6 +298,16 @@
>                    } else {
>                        searchForThis = DEFAULT_BUILD_FILENAME;
>                    }
>   +            } else if (arg.startsWith("-propertyfile")) {
>   +                try {
>   +                    propertyFiles.addElement(args[i+1]);
>   +                    i++;
>   +                } catch (ArrayIndexOutOfBoundsException aioobe) {
>   +                    String msg = "You must specify a property filename
when " +
>   +                        "using the -propertyfile argument";
>   +                    System.out.println(msg);
>   +                    return;
>   +                }
>                } else if (arg.startsWith("-")) {
>                    // we don't have any more args to recognize!
>                    String msg = "Unknown argument: " + arg;
>   @@ -304,9 +318,8 @@
>                    // if it's no other arg, it may be the target
>                    targets.addElement(arg);
>                }
>   -
>            }
>   -
>   +
>            // if buildFile was not specified on the command line,
>            if (buildFile == null) {
>                // but -find then search for it
>   @@ -332,6 +345,31 @@
>                throw new BuildException("Build failed");
>            }
>
>   +        // Load the property files specified by -propertyfile
>   +        for (int propertyFileIndex=0;
>   +             propertyFileIndex < propertyFiles.size();
>   +             propertyFileIndex++) {
>   +            String filename = (String)
propertyFiles.elementAt(propertyFileIndex);
>   +            Properties props = new Properties();
>   +            try {
>   +                FileInputStream fis = new FileInputStream(filename);
>   +                props.load(fis);
>   +            }
>   +            catch (IOException e) {
>   +                System.out.println("Could not load property file "
>   +                   + filename + ": " + e.getMessage());
>   +            }
>   +
>   +            // ensure that -D properties take precedence
>   +            Enumeration propertyNames = props.propertyNames();
>   +            while (propertyNames.hasMoreElements()) {
>   +                String name = (String) propertyNames.nextElement();
>   +                if (definedProps.getProperty(name) == null) {
>   +                    definedProps.put(name, props.getProperty(name));
>   +                }
>   +            }
>   +        }
>   +
>            readyToRun = true;
>        }
>
>   @@ -576,6 +614,8 @@
>            msg.append("  -listener <classname>  add an instance of class
as a project listener" + lSep);
>            msg.append("  -buildfile <file>      use given buildfile" +
lSep);
>            msg.append("  -D<property>=<value>   use value for given
property" + lSep);
>   +        msg.append("  -propertyfile <name>   load all properties from
file with -D" + lSep);
>   +        msg.append("                         properties taking
precedence" + lSep);
>            msg.append("  -find <file>           search for buildfile
towards the root of the" + lSep);
>            msg.append("                         filesystem and use it" +
lSep);
>            System.out.println(msg.toString());
>
>
>
>   1.9       +16 -13    jakarta-ant/docs/manual/running.html
>
>   Index: running.html
>   ===================================================================
>   RCS file: /home/cvs/jakarta-ant/docs/manual/running.html,v
>   retrieving revision 1.8
>   retrieving revision 1.9
>   diff -u -r1.8 -r1.9
>   --- running.html 10 Jan 2002 08:48:28 -0000 1.8
>   +++ running.html 1 Feb 2002 22:27:38 -0000 1.9
>   @@ -62,19 +62,22 @@
>    <h3><a name="options">Command-line Options Summary</a></h3>
>    <pre>ant [options] [target [target2 [target3] ...]]
>    Options:
>   --help                  print this message
>   --projecthelp           print project help information
>   --version               print the version information and exit
>   --quiet                 be extra quiet
>   --verbose               be extra verbose
>   --debug                 print debugging information
>   --emacs                 produce logging information without adornments
>   --logfile <i>file</i>          use given file for log output
>   --logger <i>classname</i>      the class that is to perform logging
>   --listener <i>classname</i>    add an instance of class as a project
listener
>   --buildfile <i>file</i>        use specified buildfile
>   --find <i>file</i>             search for buildfile towards the root of
the filesystem and use the first one found
>   --D<i>property</i>=<i>value</i>       set <i>property</i>
to
<i>value</i>
>   +  -help                  print this message
>   +  -projecthelp           print project help information
>   +  -version               print the version information and exit
>   +  -quiet                 be extra quiet
>   +  -verbose               be extra verbose
>   +  -debug                 print debugging information
>   +  -emacs                 produce logging information without adornments
>   +  -logfile &lt;file&gt;        use given file for log
>   +  -logger &lt;classname&gt;    the class which is to perform logging
>   +  -listener &lt;classname&gt;  add an instance of class as a project
listener
>   +  -buildfile &lt;file&gt;      use given buildfile
>   +  -D&lt;property&gt;=&lt;value&gt;   use value for given property
>   +  -propertyfile &lt;name&gt;   load all properties from file with -D
>   +                         properties taking precedence
>   +  -find &lt;file&gt;           search for buildfile towards the root of
the
>   +                         filesystem and use it
>    </pre>
>    <p>For more information about <code>-logger</code> and
>    <code>-listener</code> see the section <a
>
>
>
>
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message