<!-- build the filter to remove R, Manifest, BuildConfig --> <getemmafilter appPackage="${project.app.package}" libraryPackagesRefId="project.library.packages" filterOut="emma.default.filter"/> <!-- define where the .em file is going. This may have been setup already if this is a library --> <property name="emma.coverage.absolute.file" location="${out.absolute.dir}/coverage.em" />
<!-- It only instruments class files, not any external libs --> <emma enabled="true"> <instr verbosity="${verbosity}" mode="overwrite" instrpath="${out.absolute.dir}/classes" outdir="${out.absolute.dir}/classes" metadatafile="${emma.coverage.absolute.file}"> <filter excludes="${emma.default.filter}" /> <filter value="${emma.filter}" /> </instr> </emma> </then> </if> <!-- if the project is a library then we generate a jar file --> <if condition="${project.is.library}"> <then> <echo level="info">Creating library output jar file...</echo> <property name="out.library.jar.file" location="${out.absolute.dir}/classes.jar" /> <if> <condition> <length string="${android.package.excludes}" trim="true" when="greater" length="0" /> </condition> <then> <echo level="info">Custom jar packaging exclusion: ${android.package.excludes}</echo> </then> </if> <propertybyreplace name="project.app.package.path" input="${project.app.package}" replace="." with="/" /> <jar destfile="${out.library.jar.file}"> <fileset dir="${out.classes.absolute.dir}" includes="**/*.class" excludes="${project.app.package.path}/R.class ${project.app.package.path}/R$*.class ${project.app.package.path}/BuildConfig.class"/> <fileset dir="${source.absolute.dir}" excludes="**/*.java ${android.package.excludes}" /> </jar> </then> </if> </do-only-if-manifest-hasCode> </target> </project> ant.properties的例子, 和上面的xml是对应的 key.store=D:/workAndroid/files/android_key.store key.alias=alia key.store.password=111111 key.alias.password=111111 java.encoding=UTF-8 java.target=7 java.source=7 在生成的apk中使用版本号文件名, 而不是用默认的 xxx-release.apkhttp://jeffreysambells.com/2013/02/14/build-your-android-apk-with-the-manifest-version-number <target name="-set-release-mode" depends="rename-release-with-version-number,android_rules.-set-release-mode"> <echo message="target: ${build.target}"></echo> </target> <target name="rename-release-with-version-number"> <xmlproperty file="AndroidManifest.xml" prefix="themanifest" collapseAttributes="true"/> <!-- see ${sdk.dir}/tools/ant/build.xml -set-release-mode --> <property name="out.packaged.file" location="${out.absolute.dir}/${ant.project.name}-${themanifest.manifest.android:versionName}-release-unsigned.apk" /> <property name="out.final.file" location="${out.absolute.dir}/${ant.project.name}-${themanifest.manifest.android:versionName}-release.apk" /> </target> The -set-release-mode target overrides the same target in ${sdk.dir}/tools/ant/build.xml where the out.final.file file name is originally defined. To add the version number, I override -set-release-mode by calling my rename-release-with-version-number target in the dependencies and then calling the original android_rules.-set-release-mode to finish any other setup there.The rename-release-with-version-number target simply reads in the manifest and adds the version number to both out.final.file and out.packaged.file.Now the build APK is ProjectName-version-release.apk and it’s automatically used by the rest of the ant build process without clumsy file renaming.ANT发布SVN WEB项目到Tomcat以及利用post-commit自动提交编译更新 http://www.linuxidc.com/Linux/2014-11/109331.htm更多Android相关信息见Android 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=11本文永久更新链接地址:http://www.linuxidc.com/Linux/2015-04/116722.htm