version info: option --version v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Mon, 16 Dec 2013 20:39:07 +0100
branchv_0
changeset 18 7900bb1666f6
parent 17 d8ab8aece6f2
child 19 873669135d97
version info: option --version
.hgignore
java/sql-dk/build.xml
java/sql-dk/data/info/globalcode/sql/dk/license.txt
java/sql-dk/nbproject/build-impl.xml
java/sql-dk/nbproject/genfiles.properties
java/sql-dk/nbproject/project.properties
java/sql-dk/nbproject/project.xml
java/sql-dk/src/info/globalcode/sql/dk/Constants.java
java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java
java/sql-dk/src/info/globalcode/sql/dk/license.txt
java/sql-dk/version-info.sh
--- a/.hgignore	Mon Dec 16 20:20:54 2013 +0100
+++ b/.hgignore	Mon Dec 16 20:39:07 2013 +0100
@@ -5,3 +5,5 @@
 java/sql-dk/dist/
 java/sql-dk/build/
 java/sql-dk/nbproject/private/
+
+java/sql-dk/data/info/globalcode/sql/dk/version.txt
--- a/java/sql-dk/build.xml	Mon Dec 16 20:20:54 2013 +0100
+++ b/java/sql-dk/build.xml	Mon Dec 16 20:39:07 2013 +0100
@@ -70,5 +70,10 @@
     properties which you can use, check the target you are overriding in the
     nbproject/build-impl.xml file. 
 
-    -->
+	-->
+	
+	<target name="-pre-compile">
+		<exec executable="./version-info.sh" output="data/info/globalcode/sql/dk/version.txt"/>
+	</target>
+	
 </project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/java/sql-dk/data/info/globalcode/sql/dk/license.txt	Mon Dec 16 20:39:07 2013 +0100
@@ -0,0 +1,1 @@
+../../../../../../../license/gpl.txt
\ No newline at end of file
--- a/java/sql-dk/nbproject/build-impl.xml	Mon Dec 16 20:20:54 2013 +0100
+++ b/java/sql-dk/nbproject/build-impl.xml	Mon Dec 16 20:39:07 2013 +0100
@@ -141,6 +141,7 @@
         <condition property="have.sources">
             <or>
                 <available file="${src.dir}"/>
+                <available file="${src.data.dir}"/>
             </or>
         </condition>
         <condition property="netbeans.home+have.tests">
@@ -229,6 +230,7 @@
     </target>
     <target depends="-pre-init,-init-private,-init-user,-init-project,-do-init" name="-init-check">
         <fail unless="src.dir">Must set src.dir</fail>
+        <fail unless="src.data.dir">Must set src.data.dir</fail>
         <fail unless="test.src.dir">Must set test.src.dir</fail>
         <fail unless="build.dir">Must set build.dir</fail>
         <fail unless="dist.dir">Must set dist.dir</fail>
@@ -250,7 +252,7 @@
     </target>
     <target depends="-init-ap-cmdline-properties" if="ap.supported.internal" name="-init-macrodef-javac-with-processors">
         <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
-            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${src.dir}:${src.data.dir}" name="srcdir"/>
             <attribute default="${build.classes.dir}" name="destdir"/>
             <attribute default="${javac.classpath}" name="classpath"/>
             <attribute default="${javac.processorpath}" name="processorpath"/>
@@ -290,7 +292,7 @@
     </target>
     <target depends="-init-ap-cmdline-properties" name="-init-macrodef-javac-without-processors" unless="ap.supported.internal">
         <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/3">
-            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${src.dir}:${src.data.dir}" name="srcdir"/>
             <attribute default="${build.classes.dir}" name="destdir"/>
             <attribute default="${javac.classpath}" name="classpath"/>
             <attribute default="${javac.processorpath}" name="processorpath"/>
@@ -322,7 +324,7 @@
     </target>
     <target depends="-init-macrodef-javac-with-processors,-init-macrodef-javac-without-processors" name="-init-macrodef-javac">
         <macrodef name="depend" uri="http://www.netbeans.org/ns/j2se-project/3">
-            <attribute default="${src.dir}" name="srcdir"/>
+            <attribute default="${src.dir}:${src.data.dir}" name="srcdir"/>
             <attribute default="${build.classes.dir}" name="destdir"/>
             <attribute default="${javac.classpath}" name="classpath"/>
             <sequential>
@@ -920,12 +922,13 @@
                 <include name="*"/>
             </dirset>
         </pathconvert>
-        <j2seproject3:depend srcdir="${src.dir}:${build.generated.subdirs}"/>
+        <j2seproject3:depend srcdir="${src.dir}:${src.data.dir}:${build.generated.subdirs}"/>
     </target>
     <target depends="init,deps-jar,-pre-pre-compile,-pre-compile, -copy-persistence-xml,-compile-depend" if="have.sources" name="-do-compile">
         <j2seproject3:javac gensrcdir="${build.generated.sources.dir}"/>
         <copy todir="${build.classes.dir}">
             <fileset dir="${src.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
+            <fileset dir="${src.data.dir}" excludes="${build.classes.excludes},${excludes}" includes="${includes}"/>
         </copy>
     </target>
     <target if="has.persistence.xml" name="-copy-persistence-xml">
@@ -946,7 +949,7 @@
     <target depends="init,deps-jar,-pre-pre-compile" name="-do-compile-single">
         <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail>
         <j2seproject3:force-recompile/>
-        <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}"/>
+        <j2seproject3:javac excludes="" gensrcdir="${build.generated.sources.dir}" includes="${javac.includes}" sourcepath="${src.dir}:${src.data.dir}"/>
     </target>
     <target name="-post-compile-single">
         <!-- Empty placeholder for easier customization. -->
@@ -1210,6 +1213,9 @@
             <fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
                 <filename name="**/*.java"/>
             </fileset>
+            <fileset dir="${src.data.dir}" excludes="*.java,${excludes}" includes="${includes}">
+                <filename name="**/*.java"/>
+            </fileset>
             <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
                 <include name="**/*.java"/>
                 <exclude name="*.java"/>
@@ -1220,6 +1226,9 @@
             <fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
                 <filename name="**/doc-files/**"/>
             </fileset>
+            <fileset dir="${src.data.dir}" excludes="${excludes}" includes="${includes}">
+                <filename name="**/doc-files/**"/>
+            </fileset>
             <fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
                 <include name="**/doc-files/**"/>
             </fileset>
--- a/java/sql-dk/nbproject/genfiles.properties	Mon Dec 16 20:20:54 2013 +0100
+++ b/java/sql-dk/nbproject/genfiles.properties	Mon Dec 16 20:39:07 2013 +0100
@@ -1,8 +1,8 @@
-build.xml.data.CRC32=c64bb3a1
+build.xml.data.CRC32=b51b939b
 build.xml.script.CRC32=f55b3340
 build.xml.stylesheet.CRC32=28e38971@1.56.1.46
 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
 # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
-nbproject/build-impl.xml.data.CRC32=c64bb3a1
-nbproject/build-impl.xml.script.CRC32=4453928c
+nbproject/build-impl.xml.data.CRC32=b51b939b
+nbproject/build-impl.xml.script.CRC32=53c1d5ab
 nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46
--- a/java/sql-dk/nbproject/project.properties	Mon Dec 16 20:20:54 2013 +0100
+++ b/java/sql-dk/nbproject/project.properties	Mon Dec 16 20:39:07 2013 +0100
@@ -1,9 +1,10 @@
 annotation.processing.enabled=true
 annotation.processing.enabled.in.editor=false
-annotation.processing.processor.options=
 annotation.processing.processors.list=
 annotation.processing.run.all.processors=true
 annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
+application.title=sql-dk
+application.vendor=fiki
 build.classes.dir=${build.dir}/classes
 build.classes.excludes=**/*.java,**/*.form
 # This directory is removed when the project is cleaned:
@@ -24,6 +25,7 @@
 dist.dir=dist
 dist.jar=${dist.dir}/sql-dk.jar
 dist.javadoc.dir=${dist.dir}/javadoc
+endorsed.classpath=
 excludes=
 includes=**
 jar.compress=false
@@ -68,5 +70,6 @@
     ${javac.test.classpath}:\
     ${build.test.classes.dir}
 source.encoding=UTF-8
+src.data.dir=data
 src.dir=src
 test.src.dir=test
--- a/java/sql-dk/nbproject/project.xml	Mon Dec 16 20:20:54 2013 +0100
+++ b/java/sql-dk/nbproject/project.xml	Mon Dec 16 20:39:07 2013 +0100
@@ -6,6 +6,7 @@
             <name>sql-dk</name>
             <source-roots>
                 <root id="src.dir"/>
+                <root id="src.data.dir"/>
             </source-roots>
             <test-roots>
                 <root id="test.src.dir"/>
--- a/java/sql-dk/src/info/globalcode/sql/dk/Constants.java	Mon Dec 16 20:20:54 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/Constants.java	Mon Dec 16 20:39:07 2013 +0100
@@ -24,6 +24,8 @@
 public class Constants {
 
 	public static final String WEBSITE = "https://sql-dk.globalcode.info/";
+	public static final String LICENSE_FILE = "info/globalcode/sql/dk/license.txt";
+	public static final String VERSION_FILE = "info/globalcode/sql/dk/version.txt";
 
 	private Constants() {
 	}
--- a/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Mon Dec 16 20:20:54 2013 +0100
+++ b/java/sql-dk/src/info/globalcode/sql/dk/InfoLister.java	Mon Dec 16 20:39:07 2013 +0100
@@ -52,13 +52,13 @@
 					println("TODO: show some help");
 					break;
 				case LICENSE:
-					printLicense();
+					printResource(Constants.LICENSE_FILE);
 					break;
 				case TYPES:
 					println("TODO: list supported types");
 					break;
 				case VERSION:
-					println("TODO: show version");
+					printResource(Constants.VERSION_FILE);
 					break;
 				case DATABASES:
 					println("TODO: list databases");
@@ -72,10 +72,10 @@
 		}
 	}
 
-	private void printLicense() {
-		try (BufferedReader license = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream("info/globalcode/sql/dk/license.txt")))) {
+	private void printResource(String fileName) {
+		try (BufferedReader reader = new BufferedReader(new InputStreamReader(getClass().getClassLoader().getResourceAsStream(fileName)))) {
 			while (true) {
-				String line = license.readLine();
+				String line = reader.readLine();
 				if (line == null) {
 					break;
 				} else {
@@ -83,7 +83,7 @@
 				}
 			}
 		} catch (Exception e) {
-			log.log(Level.SEVERE, "Unable to print license. See our website for license information.", e);
+			log.log(Level.SEVERE, "Unable to print this info. Please see our website for it: " + Constants.WEBSITE, e);
 		}
 	}
 
--- a/java/sql-dk/src/info/globalcode/sql/dk/license.txt	Mon Dec 16 20:20:54 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-../../../../../../../license/gpl.txt
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/java/sql-dk/version-info.sh	Mon Dec 16 20:39:07 2013 +0100
@@ -0,0 +1,5 @@
+#!/bin/bash
+
+echo -n "Mercurial: "; hg identify || echo "n/a";
+echo -n "Compiled:  "; date --rfc-3339=seconds;
+