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'
[mjc2wsl.git] / build.xml
index 0b12de1..25fb262 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