OSDN Git Service

Expose version.name property for aapt task.
authorTero Saarni <tero.saarni@gmail.com>
Thu, 2 Jun 2011 17:22:12 +0000 (20:22 +0300)
committerTero Saarni <tero.saarni@gmail.com>
Mon, 15 Aug 2011 19:16:57 +0000 (22:16 +0300)
The new property makes it possible to create ant build scripts
that programmatically determine and set the versionName attribute
during build.  Similar property already exists for versionCode.

Signed-off-by: Tero Saarni <tero.saarni@gmail.com>
Change-Id: Ia36632ae029785563fc7c1bc8937034963016852

anttasks/src/com/android/ant/AaptExecLoopTask.java
files/ant/main_rules.xml

index 6c98cbd..ebefde5 100644 (file)
@@ -78,6 +78,7 @@ public final class AaptExecLoopTask extends BaseTask {
     private boolean mVerbose = false;
     private boolean mUseCrunchCache = false;
     private int mVersionCode = 0;
+    private String mVersionName;
     private String mManifest;
     private ArrayList<Path> mResources;
     private String mAssets;
@@ -139,6 +140,14 @@ public final class AaptExecLoopTask extends BaseTask {
         }
     }
 
+    /**
+     * Sets the value of the "versionName" attribute
+     * @param versionName the value
+     */
+    public void setVersionname(String versionName) {
+        mVersionName = versionName;
+    }
+
     public void setDebug(boolean value) {
         mDebug = value;
     }
@@ -418,6 +427,11 @@ public final class AaptExecLoopTask extends BaseTask {
             task.createArg().setValue(Integer.toString(mVersionCode));
         }
 
+        if ((mVersionName != null) && (mVersionName.length() > 0)) {
+            task.createArg().setValue("--version-name");
+            task.createArg().setValue(mVersionName);
+        }
+
         // manifest location
         if (mManifest != null) {
             task.createArg().setValue("-M");
index ff19add..8404eb8 100644 (file)
          before, then this will create them with empty values, which are then ignored
          by the custom tasks receiving them. -->
     <property name="version.code" value="" />
+    <property name="version.name" value="" />
     <property name="aapt.resource.filter" value="" />
     <property name="filter.abi" value="" />
 
         <aapt executable="${aapt}"
                 command="package"
                 versioncode="${version.code}"
+                versionname="${version.name}"
                 debug="${build.packaging.debug}"
                 manifest="AndroidManifest.xml"
                 assets="${asset.absolute.dir}"