From: <js...@us...> - 2006-11-24 07:56:12
|
Revision: 19 http://svn.sourceforge.net/jcontracts/?rev=19&view=rev Author: jstuyts Date: 2006-11-23 23:56:11 -0800 (Thu, 23 Nov 2006) Log Message: ----------- Changed the way the version number is handled. The correct version will now be set during builds so no Java code has to be changed. Modified Paths: -------------- trunk/build.xml trunk/source/java/net/sf/jcontracts/icontract/HelpOption.java Added Paths: ----------- trunk/source/java/net/sf/jcontracts/icontract/version.txt Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2006-11-24 07:36:06 UTC (rev 18) +++ trunk/build.xml 2006-11-24 07:56:11 UTC (rev 19) @@ -40,6 +40,8 @@ <include name="**/*.properties" /> </fileset> </copy> + <echo file="build/ant/classes/net/sf/jcontracts/icontract/version.txt" >${project.version} +</echo> </target> <target name="jar" description="Create the JAR file." depends="compile"> Modified: trunk/source/java/net/sf/jcontracts/icontract/HelpOption.java =================================================================== --- trunk/source/java/net/sf/jcontracts/icontract/HelpOption.java 2006-11-24 07:36:06 UTC (rev 18) +++ trunk/source/java/net/sf/jcontracts/icontract/HelpOption.java 2006-11-24 07:56:11 UTC (rev 19) @@ -1,13 +1,45 @@ package net.sf.jcontracts.icontract; import org.apache.log4j.Logger; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; import java.io.PrintStream; +import java.io.Reader; import java.util.Vector; public class HelpOption extends ParameterOption { - public static final String VERSION = "for JDK 1.5, Java Contract Suite v1.01.00b02-dev"; - public static final String NAME = "h"; + public static final String VERSION; + private static final String VERSION_RESOURCE_NAME = "version.txt"; + public static final String NAME = "h"; + + static { + try { + InputStream versionStream = HelpOption.class.getResourceAsStream(VERSION_RESOURCE_NAME); + try { + Reader versionReader = new InputStreamReader(versionStream, "US-ASCII"); + try { + BufferedReader bufferedReader = new BufferedReader(versionReader); + try { + VERSION = bufferedReader.readLine(); + } finally { + bufferedReader.close(); + } + } finally { + versionReader.close(); + } + } finally { + versionStream.close(); + } + } catch (IOException e) { + IllegalStateException exception = new IllegalStateException("Unable to read version number"); + exception.initCause(e); + throw exception; + } + } public HelpOption(String name, Vector arguments) { super(name, arguments); Added: trunk/source/java/net/sf/jcontracts/icontract/version.txt =================================================================== --- trunk/source/java/net/sf/jcontracts/icontract/version.txt (rev 0) +++ trunk/source/java/net/sf/jcontracts/icontract/version.txt 2006-11-24 07:56:11 UTC (rev 19) @@ -0,0 +1,6 @@ +dev +This file must be stored using the US-ASCII (or +compatible) encoding. Only the first line is read. + +The file will be replaced during the build with a file +containing the actual version number. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |