concept Ant in category android

This is an excerpt from Manning's book Android in Practice.
A build system can do even more for us, such as installing the application on a device and running the test suite. Figure 14.3 shows the typical steps a build system like Ant would perform when used in an Android environment.
Figure 14.3. A build system such as Apache Ant can greatly simplify the build lifecycle by executing each step using a build script. A build system can usually be triggered using a simple shell command.
![]()
We’re not limited to one kind of build system Fortunately, there are plenty: GNU Make, Ant, Maven, Gradle, SBT, Rake, Buildr.... the list is long. Which one is the best for you depends on your mileage, but we’ll review two of the most popular ones, Ant and Maven, against the backdrop of Android.
We’ll start with what’s probably the simplest and also best-known build system in the Java universe: Apache Ant. A word of warning before we continue: none of the techniques about build systems that follow are meant to be in-depth introductions into the build systems themselves. Such intense cover would blow this book’s scope way out of proportion. Entire books have been written on using Ant or Maven, but this isn’t one of them. Instead, we’ll give a quick introduction to the build system itself and its major building blocks. Then, we’ll quickly advance to the Android specifics and how the build system being discussed compares to others with respect to building Android applications. We’ll always point you to more detailed information about the tool being discussed.
Even if you’ve only used a bit of Java before you decided to tread the path of the Android developer, chances are you’ve at least heard of Apache Ant. Perhaps you’ve even used it. Ant (Another neat tool) is a build system written in Java, for Java. You can use it for more than building Java applications, but building Java applications is its primary purpose and motivation behind its development. If you’ve done any programming for native Linux/UNIX applications before, think of Ant as the equivalent to UNIX’s make tool. Unlike make’s crude syntax found in the Makefile describing a build, Ant banks on XML, and the build descriptor is aptly called build.xml.
If you’ve worked with relatively simple build systems such as Ant or GNU Make before, then you already know what I’m going to say now: things can get messy if you reach a certain level of project complexity (lots of dependencies, submodules, that sort of thing). We’ll explain Ant’s strengths and weaknesses in more detail later. For now, let’s summarize Ant by itself as being perfectly fit for simple build tasks in simple applications. Ant is also the standard and Google-official way Android applications are built from the command line. Although Ant has its shortcomings, we’re not wasting your time. But before starting to assess Ant, maybe we should first look at how it works.
Now that we’ve dissected the build descriptor, let’s use it to build an APK from our application using Ant. The first thing you need to know is which targets are provided to you by Android. The next listing does this by running Ant with the -p flag.