标签:android des style blog class code
<taskdef resource="net/sf/antcontrib/antcontrib.properties">
<classpath>
<pathelement location="${env.ANT_HOME}/lib/ant-contrib.jar" />
</classpath>
</taskdef>
<property name="channelname"
value="" />
<property name="release.out.out.dir" value="20131219194545" />
<property name="key" value="
:xxx_adwx1,
:xxx_adwx2,"/>
<target name="deploy">
<foreach target="modify_manifest" list="${key}" param="nameandchannel" delimiter=",">
</foreach>
</target>
<target name="modify_manifest">
<!-- 获取渠道名字 -->
<propertyregex override="true" property="channelname" input="${nameandchannel}" regexp=":(.*)" select="\1" />
<replaceregexp flags="g" byline="false" encoding="UTF-8">
<regexp pattern=‘meta-data android:name="UMENG_CHANNEL" android:value="(.*)"‘ />
<substitution expression=‘meta-data android:name="UMENG_CHANNEL" android:value="${channelname}"‘ />
<fileset dir="" includes="AndroidManifest.xml" />
</replaceregexp>
<antcall target="release-name" />
</target>
<!-- version-tag: 1 -->
<target name="release-name"
depends="-set-release-mode-name, -release-obfuscation-check, -package, -post-package, -release-prompt-for-password, -release-nosign, -release-sign, -post-build"
description="Builds the application in release mode.">
</target>
<target name="-set-release-mode-name" depends="-set-mode-check">
<property name="out.packaged.file" location="${out.absolute.dir}/${ant.project.name}-release-unsigned.apk" />
<property name="out.final.file" location="${out.absolute.dir}/qupai_v2.1.0_${channelname}.apk" />
<property name="build.is.mode.set" value="true" />
<!-- record the current build target -->
<property name="build.target" value="release" />
<property name="build.is.instrumented" value="false" />
<!-- release mode is only valid if the manifest does not explicitly
set debuggable to true. default is false. -->
<xpath input="${manifest.abs.file}" expression="/manifest/application/@android:debuggable"
output="build.is.packaging.debug" default="false"/>
<!-- signing mode: release -->
<property name="build.is.signing.debug" value="false" />
<!-- Renderscript optimization level: aggressive -->
<property name="renderscript.opt.level" value="${renderscript.release.opt.level}" />
<if condition="${build.is.packaging.debug}">
<then>
<echo>*************************************************</echo>
<echo>**** Android Manifest has debuggable=true ****</echo>
<echo>**** Doing DEBUG packaging with RELEASE keys ****</echo>
<echo>*************************************************</echo>
</then>
<else>
<!-- property only set in release mode.
Useful for if/unless attributes in target node
when using Ant before 1.8 -->
<property name="build.is.mode.release" value="true"/>
</else>
</if>
</target>
</project>
sdk.dir=E:\\android\\sdk
最后需要说明一点,ant打包跟Eclipse的工程是不能同时存在的。就是说如果你的工程现在在Eclipse里面运行就会出现问题.好的方法就是用svn吧代码down下来放到一个特定的位置。然后对代码进行打包操作。还有一点就是我们这个打包脚本只是对友盟的渠道进行修改.里面有个容易出现的问题.就是友盟的AndroidManifest.xml里面的渠道需要写成一行。如下--是必须写成一行,原因应该是脚本的问题..我这个不熟..
<meta-data android:name="UMENG_CHANNEL"android:value="qupai_adwx1" />
ok就这么愉快的完成了!!!-----有任何问题可以加我QQ:11635423 或者直接留言.我邮件会收到的.
标签:android des style blog class code
原文地址:http://www.cnblogs.com/shansheng/p/3714564.html