build.xml
===========================================================================
<?xml version="1.0" encoding="UTF-8"?>
<project
name="tzb-ard-application"
default="help" >
<!-- ################################################################## -->
<!-- ################################################################## -->
<!-- Introduce the ant extension command package ant-contrib, so that ant supports for loops -->
<taskdef resource="net/sf/antcontrib/antcontrib.properties" >
<classpath>
<pathelement location="${ant.home}/exlib/ant-contrib-1.0b3.jar" />
</classpath>
</taskdef>
<!-- ################################################################## -->
<!-- ################################################################## -->
<!-- Environment configuration parameters (sdk.dir) -->
<property file="local.properties" />
<!-- Project configuration parameters (proguard, target, library) -->
<property file="project.properties" />
<!-- Compile configuration parameters (keystore, channel) -->
<property file="ant.properties" />
<!-- ################################################################## -->
<!-- ################################################################## -->
<!-- Environment variable configuration in the system-->
<property environment="env" />
<!-- SDK directory -->
<condition
property="sdk.dir"
value="${env.ANDROID_HOME}" >
<isset property="env.ANDROID_HOME" />
</condition>
<fail
message="sdk.dir is missing."
unless="sdk.dir" />
<!-- SDK specified platform directory -->
<property name="sdk.platform.dir" value="${sdk.dir}/platforms/android-23" />
<!-- tools directory in SDK -->
<property name="sdk.tools" value="${sdk.dir}/tools" />
<!-- The tools directory in the SDK specified platform-->
<property name="sdk.platform.tools" value="${sdk.dir}/platform-tools" />
<!-- ################################################################## -->
<!-- ################################################################## -->
<import
file="custom_rules.xml"
optional="true" />
<import file="${sdk.dir}/tools/ant/build.xml" />
<!-- ################################################################## -->
<!-- ################################################################## -->
<!-- application name-->
<property
name="app.name"
value="${ant.project.name}" />
<!-- Get current time-->
<tstamp>
<format
pattern="yyyyMMddHHmm"
property="current_time" />
<format
pattern="yyyyMMdd"
property="current_date" />
<format
pattern="yyMMdd"
property="app.version.code" />
</tstamp>
<!-- output log -->
<record
name="ant.log"
append="no"
loglevel="verbose" />
<!-- ################################################################## -->
<!-- ################################################################## -->
<!-- Channel package packaging script ant deploy 1. Clean up the compilation directory 2. Modify the interface address 3. Modify the version information 4. Modify the Key information-->
<target name="deploy" depends="clean,modify_service,modify_version,modify_key">
<!-- 5. Modify channel information-->
<foreach
delimiter=","
list="${app.market.channels.release}"
param="channel_info"
target="modify_manifest" >
</foreach>
</target>
<!-- Channel package packaging script ant prepare 1. Clean up the compilation directory 2. Modify the interface address 3. Modify the version information 4. Modify the Key information-->
<target name="prepare" depends="clean,modify_service_prepare,modify_version,modify_key_test">
<!-- 5. Modify channel information-->
<foreach
delimiter=","
list="${app.market.channels.test}"
param="channel_info"
target="modify_manifest" >
</foreach>
</target>
<!-- Channel package packaging script ant test 1. Clean up the compilation directory 2. Modify the interface address 3. Modify the version information 4. Modify the Key information-->
<target name="test" depends="clean,modify_service_test,modify_version,modify_key_test">
<!-- 5. Modify channel information-->
<foreach
delimiter=","
list="${app.market.channels.test}"
param="channel_info"
target="modify_manifest" >
</foreach>
</target>
<!-- Channel package packaging script ant test 1. Clean up the compilation directory 2. Modify the interface address 3. Modify the version information 4. Modify the Key information-->
<target name="debug" depends="clean,modify_service_debug,modify_version,modify_key_test">
<!-- 5. Modify channel information-->
<foreach
delimiter=","
list="${app.market.channels.test}"
param="channel_info"
target="modify_manifest" >
</foreach>
</target>
<!-- ################################################################## -->
<!-- ################################################################## -->
<!-- Modify the interface address in AppConfig.java-->
<target name="modify_service" >
<!-- Modify interface address-->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="public static final String COMM_URL_HEADER = "(.*)";" />
<substitution expression="public static final String COMM_URL_HEADER = "${app.service.url.release}";" />
<fileset
you=""
includes="src\com\tziba\mobile\ard\AppConfig.java" />
</replaceregexp>
</target>
<!-- Modify the interface address in AppConfig.java-pre-production-->
<target name="modify_service_prepare" >
<!-- Modify interface address-->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="public static final String COMM_URL_HEADER = "(.*)";" />
<substitution expression="public static final String COMM_URL_HEADER = "${app.service.url.prepare}";" />
<fileset
you=""
includes="src\com\tziba\mobile\ard\AppConfig.java" />
</replaceregexp>
</target>
<!-- Modify the interface address in AppConfig.java--test-->
<target name="modify_service_test" >
<!-- Modify interface address-->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="public static final String COMM_URL_HEADER = "(.*)";" />
<substitution expression="public static final String COMM_URL_HEADER = "${app.service.url.test}";" />
<fileset
you=""
includes="src\com\tziba\mobile\ard\AppConfig.java" />
</replaceregexp>
</target>
<!-- Modify the interface address in AppConfig.java-debugging-->
<target name="modify_service_debug" >
<!-- Modify interface address-->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="public static final String COMM_URL_HEADER = "(.*)";" />
<substitution expression="public static final String COMM_URL_HEADER = "${app.service.url.debug}";" />
<fileset
you=""
includes="src\com\tziba\mobile\ard\AppConfig.java" />
</replaceregexp>
</target>
<!-- Modify the version in AndroidManifest.xml-->
<target name="modify_version" >
<!-- Modified version Code -->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="android:versionCode="(.*)"" />
<substitution expression="android:versionCode="${app.version.code}"" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
<!-- Modified Version Name -->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="android:versionName="(.*)"" />
<substitution expression="android:versionName="${app.version}"" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
</target>
<!-- Modify the Key in AndroidManifest.xml -->
<target name="modify_key" >
<!-- Modify Umeng Key -->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="<!-- UM_KEY_S -->([^..]*)<!-- UM_KEY_E -->"/>
<substitution expression="<!-- UM_KEY_S --> <meta-data android:name="UMENG_APPKEY" android:value="${app.umeng.appkey.release}"/> <!-- UM_KEY_E -->" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
<!-- Modify carrier pigeon KeyId -->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="<!-- XG_ID_S -->([^..]*)<!-- XG_ID_E -->"/>
<substitution expression="<!-- XG_ID_S --> <meta-data android:name="XG_V2_ACCESS_ID" android:value="${app.xg.access.id.release}"/> <!-- XG_ID_E -->" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
<!-- Modify carrier pigeon Key -->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="<!-- XG_KEY_S -->([^..]*)<!-- XG_KEY_E -->"/>
<substitution expression="<!-- XG_KEY_S --> <meta-data android:name="XG_V2_ACCESS_KEY" android:value="${app.xg.access.key.release}"/> <!-- XG_KEY_E -->" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
</target>
<!-- Modify the Key in AndroidManifest.xml -->
<target name="modify_key_test" >
<!-- Modify Umeng Key -->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="<!-- UM_KEY_S -->([^..]*)<!-- UM_KEY_E -->"/>
<substitution expression="<!-- UM_KEY_S --> <meta-data android:name="UMENG_APPKEY" android:value="${app.umeng.appkey.test}"/> <!-- UM_KEY_E -->" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
<!-- Modify carrier pigeon KeyId -->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="<!-- XG_ID_S -->([^..]*)<!-- XG_ID_E -->"/>
<substitution expression="<!-- XG_ID_S --> <meta-data android:name="XG_V2_ACCESS_ID" android:value="${app.xg.access.id.test}"/> <!-- XG_ID_E -->" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
<!-- Modify carrier pigeon Key -->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="<!-- XG_KEY_S -->([^..]*)<!-- XG_KEY_E -->"/>
<substitution expression="<!-- XG_KEY_S --> <meta-data android:name="XG_V2_ACCESS_KEY" android:value="${app.xg.access.key.test}"/> <!-- XG_KEY_E -->" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
</target>
<!-- Modify the channel in AndroidManifest.xml -->
<target name="modify_manifest" depends="get_channel">
<!-- Modify channel-->
<replaceregexp
byline="false"
encoding="utf-8"
flags="g" >
<regexp pattern="<!-- UM_CHL_S -->([^..]*)<!-- UM_CHL_E -->"/>
<substitution expression="<!-- UM_CHL_S --> <meta-data android:name="UMENG_CHANNEL" android:value="${channel}"/> <!-- UM_CHL_E -->" />
<fileset
you=""
includes="AndroidManifest.xml" />
</replaceregexp>
<!-- 5. Package release -->
<antcall target="release" />
<!-- Output channel package to bin/out directory ${out.absolute.dir}/-->
<copy
file="bin/${app.name}-release.apk"
tofile="apk/${app.apk.name}_${app.version}_${current_date}${channelId}.apk" />
</target>
<!-- Get channel -->
<target name="get_channel" >
<!-- ChannelId -->
<propertyregex
input="${channel_info}"
property="channelId"
regexp="(.*):"
select="\1" />
<!-- channel name-->
<propertyregex
input="${channel_info}"
property="channel"
regexp=":(.*)"
select="\1" />
</target>
</project>
===========================================================================
ant.properties
#########################################
#Apk name
app.apk.name=ard_app
#Version
app.version=1.1.4
#service.url.release
app.service.url.release=https://app.tziba.com
#service.url.prepare
app.service.url.prepare=http://192.168.1.1:8803
#service.url.test
app.service.url.test=http://192.168.1.2:8803
#service.url.debug
app.service.url.debug=http://192.168.1.3:8080
#########################################
#app.umeng.appkey.test
app.umeng.appkey.test=11111111111111111111
#app.umeng.appkey.release
app.umeng.appkey.release=22222222222222222222
#app.market.channels.test
app.market.channels.test=C000:testMarket
#app.market.channels.release
app.market.channels.release=C100:officialWebsite,C101:tencentMarket,C102:360Market,C103:baiduMarket,C104:hiapkMarket,C105:91Market,C106:appsMarket,C107:wandoujiaMarket,C108:appchinaMarket,C109:mumayiMarket,C110:nduoaMarket,C111:anzhiMarket,C112:sogouMarket,C113:gfanMarket,C114:xiaomiMarket,C115:flymMarket,C116:jinliMarket,C117:huaweiMarket,C118:oppomobileMarket,C119:vivoMarket,C120:lenovoMarket,C121:suningMarket
#app.xg.access.id.test
app.xg.access.id.test=2100123456
#app.xg.access.key.test
app.xg.access.key.test=AAAAAAAAAAAA
#app.xg.access.id.release
app.xg.access.id.release=2100123456
#app.xg.access.key.release
app.xg.access.key.release=AAAAAAAAAAAA
#########################################
#Apk keystore
key.store=./ard_application.keystore
#Apk keystore password
key.store.password=12345
#Apk keystore alias
key.alias=ard_app
#Apk keystore alias password
key.alias.password=12345