From ed88cf93fbef99a878be3c5e6691615b34f09045 Mon Sep 17 00:00:00 2001
From: Xavier Ducrohet <xav@android.com>
Date: Wed, 10 Mar 2010 16:49:38 -0800
Subject: Move ant.prop to sdk.prop and up a folder.

this file is meant to have general sdk properties, not
just Ant ones.

Also separated the library support from the Ant build version.
It's clearer whether or not libraries are supported, and it's
not just tied to Ant anyway (ADT needs to know as well).

Finally use that new property to do checks on library support
in both the custom Ant tasks and ADT.

Depends on a CL in development.git (sdk.atree change).

Change-Id: I77d229ed3fd60f0468b1d3d31f7cf147b03a32fb
---
 anttasks/src/com/android/ant/SetupTask.java | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

(limited to 'anttasks/src')

diff --git a/anttasks/src/com/android/ant/SetupTask.java b/anttasks/src/com/android/ant/SetupTask.java
index 8facf62..2c0ad53 100644
--- a/anttasks/src/com/android/ant/SetupTask.java
+++ b/anttasks/src/com/android/ant/SetupTask.java
@@ -171,7 +171,8 @@ public final class SetupTask extends ImportTask {
         }
 
         // check that this version of the custom Ant task can build this target
-        int antBuildVersion = androidTarget.getAntBuildRevision();
+        int antBuildVersion = androidTarget.getProperty(SdkConstants.PROP_SDK_ANT_BUILD_REVISION,
+                1);
         if (antBuildVersion > ANT_RULES_MAX_VERSION) {
             throw new BuildException(String.format(
                     "The project target (%1$s) requires a more recent version of the tools. Please update.",
@@ -200,6 +201,14 @@ public final class SetupTask extends ImportTask {
         }
         System.out.println("API level: " + androidTarget.getVersion().getApiString());
 
+        // do a quick check to make sure the target supports library.
+        if (isLibrary &&
+                androidTarget.getProperty(SdkConstants.PROP_SDK_SUPPORT_LIBRARY, false) == false) {
+            throw new BuildException(String.format(
+                    "Project target '%1$s' does not support building libraries.",
+                    androidTarget.getFullName()));
+        }
+
         // always check the manifest minSdkVersion.
         checkManifest(antProject, androidTarget.getVersion());
 
@@ -274,7 +283,7 @@ public final class SetupTask extends ImportTask {
 
             if (rules.isFile() == false) {
                 throw new BuildException(String.format("Build rules file '%s' is missing.",
-                        templateFolder));
+                        rules));
             }
 
             // set the file location to import
@@ -390,7 +399,8 @@ public final class SetupTask extends ImportTask {
 
         // get the build version for the current target. It'll be tested if there's at least
         // one library.
-        int antBuildVersion = androidTarget.getAntBuildRevision();
+        boolean supportLibrary = androidTarget.getProperty(SdkConstants.PROP_SDK_SUPPORT_LIBRARY,
+                false);
 
         int index = 1;
         while (true) {
@@ -401,7 +411,7 @@ public final class SetupTask extends ImportTask {
                 break;
             }
 
-            if (antBuildVersion < SdkConstants.ANT_REV_LIBRARY) {
+            if (supportLibrary == false) {
                 throw new BuildException(String.format(
                         "The build system for this project target (%1$s) does not support libraries",
                         androidTarget.getFullName()));
-- 
cgit v1.1