- changed build script. get rid of mobile-test shell scripts

- use git hash as version number for test builds
This commit is contained in:
Philipp Schaefer
2013-10-22 12:52:11 +02:00
parent 437a33f1d5
commit 48e4af33ea
5 changed files with 80 additions and 27 deletions

View File

@ -88,7 +88,7 @@
-->
<!-- allow the package name to be overridden when building -->
<property name="override.package.name" value="com.cradle.iitc_mobile"/>
<property name="override.package.name" value="com.cradle.iitc_mobile.test"/>
<!-- Puts the project's resources into the output package file
This actually can create multiple resource package in case
@ -125,6 +125,80 @@
</do-only-if-not-library>
</target>
<target name="-pre-build" depends="-custom-git-version,-custom-manifest-version,-test-setup">
</target>
<!-- Packages the application. -->
<target name="-post-build">
<antcall target="-custom-restore-manifest"/>
<antcall target="-test-revert"/>
</target>
<!-- Custom targets -->
<target name="-custom-git-version">
<exec executable="sh" outputproperty="git.commits">
<arg value="-c" />
<arg value="git log --pretty=format:'' | wc -l" />
</exec>
<echo>git.commits: ${git.commits}</echo>
<exec executable="git" outputproperty="git.version">
<arg value="rev-parse" />
<arg value="--short" />
<arg value="HEAD" />
</exec>
<echo>git.version: ${git.version}</echo>
</target>
<target name="-custom-manifest-version">
<echo>Creating backup of AndroidManifest.xml</echo>
<copy file="AndroidManifest.xml" tofile="AndroidManifest.xml.antbak" preservelastmodified="true" />
<replaceregexp
file="AndroidManifest.xml"
match='android:versionCode="(\d+)"'
replace='android:versionCode="${git.commits}"' />
<replaceregexp
file="AndroidManifest.xml"
match='android:versionName="(\d+\.\d+\.\d+)"'
replace='android:versionName="\1.${git.version}"' />
</target>
<target name="-custom-restore-manifest">
<echo>Restoring backup of AndroidManifest.xml</echo>
<move file="AndroidManifest.xml.antbak"
tofile="AndroidManifest.xml"
preservelastmodified="true"
overwrite="true" />
</target>
<target name="-test-setup">
<echo>Creating backup of strings.xml and preferences.xml</echo>
<copy file="res/values/strings.xml" tofile="strings.xml.antbak" preservelastmodified="true" />
<copy file="res/xml/preferences.xml" tofile="preferences.xml.antbak" preservelastmodified="true" />
<replaceregexp
file="res/values/strings.xml"
match='IITC Mobile'
replace='IITCm Test'/>
<replaceregexp
file="res/xml/preferences.xml"
match='targetPackage="com.cradle.iitc_mobile"'
replace='targetPackage="com.cradle.iitc_mobile.test"'/>
</target>
<target name="-test-revert">
<echo>Restoring backup of strings.xml and preferences.xml</echo>
<move file="strings.xml.antbak"
tofile="res/values/strings.xml"
preservelastmodified="true"
overwrite="true" />
<move file="preferences.xml.antbak"
tofile="res/xml/preferences.xml"
preservelastmodified="true"
overwrite="true" />
</target>
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />