Browse Source

Added -version switch.

Suggested by:	Peter Donald <donaldp@mad.scientist.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@267704 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 25 years ago
parent
commit
017c6059a3
4 changed files with 40 additions and 1 deletions
  1. +9
    -0
      build.xml
  2. +1
    -1
      docs/index.html
  3. +28
    -0
      src/main/org/apache/tools/ant/Main.java
  4. +2
    -0
      src/main/org/apache/tools/ant/version.txt

+ 9
- 0
build.xml View File

@@ -48,6 +48,7 @@
<!-- =================================================================== -->
<target name="prepare">
<mkdir dir="${build.dir}"/>
<tstamp />
</target>

<!-- =================================================================== -->
@@ -66,12 +67,20 @@
<exclude name="**/NetRexxC.java" unless="netrexx.present" />
<exclude name="**/XslpLiaison.java" unless="xslp.present" />
<exclude name="**/XalanLiaison.java" unless="xalan.present" />
<exclude name="**/version.txt" />
</javac>
<copydir src="${src.dir}" dest="${build.classes}">
<include name="**/defaultManifest.mf" />
<include name="**/*.properties" />
</copydir>

<filter token="VERSION" value="${version}" />
<filter token="DATE" value="${TODAY}" />
<filter token="TIME" value="${TSTAMP}" />
<copydir src="${src.dir}" dest="${build.classes}" filtering="on">
<include name="**/version.txt" />
</copydir>
</target>

<!-- =================================================================== -->


+ 1
- 1
docs/index.html View File

@@ -479,10 +479,10 @@ If you do not want these default excludes applied, you may disable them with the
<li><a href="#exec">Exec</a></li>
<li><a href="#expand">Expand</a></li>
<li><a href="#filter">Filter</a></li>
<li><a href="#fixcrlf">FixCRLF</a></li>
<li><a href="#get">Get</a></li>
<li><a href="#gunzip">GUnzip</a></li>
<li><a href="#gzip">GZip</a></li>
<li><a href="#fixcrlf">FixCRLF</a></li>
<li><a href="#jar">Jar</a></li>
<li><a href="#java">Java</a></li>
<li><a href="#javac">Javac</a></li>


+ 28
- 0
src/main/org/apache/tools/ant/Main.java View File

@@ -116,6 +116,9 @@ public class Main {
if (arg.equals("-help") || arg.equals("help")) {
printUsage();
return;
} else if (arg.equals("-version")) {
printVersion();
return;
} else if (arg.equals("-quiet") || arg.equals("-q") || arg.equals("q")) {
msgOutputLevel = Project.MSG_WARN;
} else if (arg.equals("-verbose") || arg.equals("-v") || arg.equals("v")) {
@@ -328,6 +331,7 @@ public class Main {
msg.append("ant [options] [target]" + lSep);
msg.append("Options: " + lSep);
msg.append(" -help print this message" + lSep);
msg.append(" -version print the version information and exit" + lSep);
msg.append(" -quiet be extra quiet" + lSep);
msg.append(" -verbose be extra verbose" + lSep);
msg.append(" -logfile <file> use given file for log" + lSep);
@@ -336,4 +340,28 @@ public class Main {
msg.append(" -D<property>=<value> use value for given property" + lSep);
System.out.println(msg.toString());
}

private static void printVersion() {
try {
Properties props = new Properties();
InputStream in =
Main.class.getResourceAsStream("/org/apache/tools/ant/version.txt");
props.load(in);
in.close();
String lSep = System.getProperty("line.separator");
StringBuffer msg = new StringBuffer();
msg.append("Ant version ");
msg.append(props.getProperty("VERSION"));
msg.append(" compiled on ");
msg.append(props.getProperty("DATE"));
msg.append(lSep);
System.out.println(msg.toString());
} catch (IOException ioe) {
System.err.println("Could not load the version information.");
System.err.println(ioe.getMessage());
} catch (NullPointerException npe) {
System.err.println("Could not load the version information.");
}
}
}

+ 2
- 0
src/main/org/apache/tools/ant/version.txt View File

@@ -0,0 +1,2 @@
VERSION=@VERSION@
DATE=@DATE@

Loading…
Cancel
Save