我正在开发一个现有的项目,它很大程度上依赖于custom_rules.xml ant build中的大量配置。我在网上看了一下,但还没有明确详细地处理过这样的任务。我和Gradle一起玩过并尝试过一些建议的方法,但还没有任何工作。如果有人能指出我正确的方向,我将非常感激。
编辑:这是我需要使用Gradle重建的内容。我希望通过命令行摆脱这种做法,更不用说处理依赖性等等。
<?xml version="1.0" encoding="UTF-8"?>
设置预编译
<!-- ========================================================================================= -->
<!-- Once update android SDK, please copy this target from build.xml under android SDK -->
<!-- ========================================================================================= -->
<!-- Updates the pre-processed PNG cache -->
<target name="-crunch">
<echo>SET CRUNCH</echo>
<exec executable="${aapt}" taskName="crunch">
<arg value="crunch" />
<arg value="-v" />
<arg value="-S" />
<arg path="${resource.absolute.dir}" />
<arg value="-C" />
<arg path="${out.res.absolute.dir}" />
</exec>
</target>
<!-- ========================================================================================= -->
<!-- Once update android SDK, please copy this target from build.xml under android SDK -->
<!-- ========================================================================================= -->
<!-- Puts the project's resources into the output package file
This actually can create multiple resource package in case
Some custom apk with specific configuration have been
declared in default.properties.
-->
<target name="-package-resources" depends="-crunch">
<!-- only package resources if *not* a library project -->
<echo>MADE IT TO CRUNCH</echo>
<do-only-if-not-library elseText="Library project: do not package resources..." >
<aapt executable="${aapt}"
command="package"
versioncode="${version.code}"
versionname="${version.name}"
debug="${build.is.packaging.debug}"
manifest="${out.manifest.abs.file}"
assets="${asset.absolute.dir}"
androidjar="${project.target.android.jar}"
apkfolder="${out.absolute.dir}"
nocrunch="${build.packaging.nocrunch}"
resourcefilename="${resource.package.file.name}"
resourcefilter="${aapt.resource.filter}"
libraryResFolderPathRefid="project.library.res.folder.path"
libraryPackagesRefid="project.library.packages"
libraryRFileRefid="project.library.bin.r.file.path"
previousBuildType="${build.last.target}"
buildType="${build.target}"
ignoreAssets="${aapt.ignore.assets}"
manifestpackage="com.myproj">
<res path="${out.res.absolute.dir}" />
<res path="${resource.absolute.dir}" />
<!-- <nocompress /> forces no compression on any files in assets or res/raw -->
<!-- <nocompress extension="xml" /> forces no compression on specific file extensions in assets and res/raw -->
</aapt>
</do-only-if-not-library>
</target>
<target name="-post-package" >
<property name="config_path" location="${cert.dir}" />
<property name="out.pre.signlib.signed.file" location="${out.absolute.dir}/${ant.project.name}-release-pre-signlib-sign.apk" />
<property name="out.signlib.signed.file" location="${out.absolute.dir}/${ant.project.name}-release-signlib-signed.apk" />
<echo>sign with signlib certificate</echo>
<touch file="res/raw/my.properties"/>
<copy file="${out.packaged.file}" tofile="${out.pre.signlib.signed.file}"/>
<java jar="apksigtool.jar" failonerror="true" fork="true">
<arg value="${out.packaged.file}"/>
<arg value="private_key.der" />
<arg value="my.crt" />
</java>
<copy file="${out.packaged.file}" tofile="${out.signlib.signed.file}"/>
</target>