Android Open Source Project Ant Task Proposal
The purpose of this page is to provide a high-level design for the Android Open Source Project (AOSP). This proposal describes a set of Apache Ant tasks similar to the ones offered by the standard Apache Ant libraries. The tasks described in this proposal are specifically for managing Android projects.
Here are the standard Apache Ant tasks for reference:
This proposal is a starting point for future discussions and designs.
This system is needed to give developers more control over their Android builds. The current system is not flexible enough. Developers need an easy way to customize their Android project directory structure, integrate with continuous integration systems (e.g. Hudson/Jenkins), and leverage other Java build tools. Ant is the de facto standard for building Java projects. Also, all of these needs can be satisfied by creating a standard Android Ant build system. Ant has parameters for configuring filesystem layout, built-in Hudson/Jenkins integration, and many existing tasks for managing Java projects.
Many of the tasks described in this proposal already exist in one form or another. But, they are not documented well enough for developers to use directly. Also, the interfaces are a moving target because no one is supposed to hook directly into them. Most of the Android Ant build.xml file is treated like a black box by developers.
I propose we examine the existing Android Ant task interfaces. Are the inputs and outputs well defined? Are there too many assumptions being made about the project directory structure? Once we have examined and possibly refined these task interfaces, we should create documentation for them. The trick is that we don’t want to expose interfaces to developers that will change frequently. It might take some engineering to get them right.
The goal of this work would be to create documented, stable, and simple interfaces for building Android projects using Ant. The existing system for automagically generating an Ant “build.xml” should still be preserved and function once this work is done. The purpose is to allow advanced developers direct access to the Ant tasks. There is a desperate need for this in my opinion.
The basic architecture for this system is shown in the diagram below. The current process for building, transforming, and deploying has been decomposed into discrete steps. These steps have been grouped by functional area.
The following section takes the architecture from the previous section and describes the Ant tasks that map to the components.
Note: Work still needs to be done to design the interfaces to the tasks identified in this section. It is expected that engineers in the AOSP will help design and implement these new tasks. Other tasks may be added as the system evolves.
Compile Code Tasks
|TransformAidl||Transforms the AIDL files into Java “.class” files.|
|GenerateR||Generates the “R.class” file from the Android XML files.|
|CompileRenderScript||Compiles Android 3D Renderscript files.|
|Javac||Existing Apache Ant compile task. See Javac for more information.|
Transform Bytecode Tasks
|Obfuscate||Uses ProGuard to obfuscate code.|
|Dex||Converts Java bytecode to a Dalvik Executable DEX file.|
Manage Package Tasks
|Apk||Builds an Android APK package.|
|ZipAlign||Optimizes APK packages, making applications run faster.|
|SignApk||Signs an APK file with a digital certificate. This is very similar to the existing SignJar task.|
|ApkInstall||This task installs an Android APK package on any device, including emulators.|
|ApkUninstall||This task uninstalls an Android APK package from any device.|
Control Logs Tasks
|ClearLog||Clears the Android log buffer.|
|PrintLog||Prints the Android logs to the console.|
Control Emulator Tasks
|Emulator||Starts or stops the Android emulator.|
Copy Files Tasks
|AndroidCopy||Copies files to or from an Android device.|
|AndroidShell||Runs a shell command on an Android device.|
|EmmaJava||Existing Ant task for checking code coverage using Emma. See EmmaJava for more information.|
The proposal described on this page is a starting point for implementing an Android Ant build system. It is expected that this documentation will move to the AOSP once there is agreement to build the proposed system. The AOSP has full permission to use this design in any way. Disgruntled Rats LLC is willing to help the AOSP code, design, and document the proposed system.