gitweb on Svarog

projekti pod git sistemom za održavanje verzija -- projects under the git version control system
ant - added build task for versioning by using 'git describe'
authorDoni Pracner <quinnuendo@gmail.com>
Sat, 26 Jul 2014 18:51:10 +0000 (20:51 +0200)
committerDoni Pracner <quinnuendo@gmail.com>
Sat, 26 Jul 2014 18:51:19 +0000 (20:51 +0200)
build.xml

index 0b12de113a40a64e4955301fa722c6effdfa8e41..25fb262a581d920bf903c2f379587d1b2c6cad3d 100644 (file)
--- a/build.xml
+++ b/build.xml
             <fileset dir="${log.dir}"/>
         </delete>
     </target>
+       
+       <!-- version tasks
+       based on ideas by Jesper Öqvist http://llbit.se/?p=1876 -->
     
+       <!-- this target is only run if the 'version' property is undefined -->
+       
+       <target name="update-version-string" unless="version">
+               <!-- get a new version string using git describe if possible -->
+               <echo message="Updating version string..."/>
+               <exec executable="git" outputproperty="version"
+                       failifexecutionfails="false">
+                       <arg value="describe"/>
+               </exec>
+               <antcall target="-store-version-string"/>
+               <!-- ensure version is defined even if git was not available -->
+               <property file="${res.dir}/version.properties"/>
+       </target>
     
+       <target name="-store-version-string" if="version">
+               <!-- store the new  version string in the correct property file -->
+               <echo message="version=${version}"/>
+               <propertyfile file="${res.dir}/version.properties">
+                       <entry key="version" value="${version}"/>
+               </propertyfile>
+               <exec executable="git" failifexecutionfails="false">
+                       <arg value="update-index"/>
+                       <arg value="--assume-unchanged"/>
+                       <arg value="${res.dir}/version.properties"/>
+               </exec>
+       </target>
+       
     <!-- mjc2wsl related tasks -->
     
-    <target name="build" depends="init" description="build the mjc2wsl tool">
+    <target name="build" depends="init,update-version-string" description="build the mjc2wsl tool">
         <javac srcdir="${mjc2wsl.src.dir}" destdir="${mjc2wsl.class.dir}" includeAntRuntime='no' />
     </target>
 
Svarog.pmf.uns.ac.rs/gitweb maintanance Doni Pracner