Make lint a reserved name.
Xavier Ducrohet [Mon, 18 Feb 2013 20:41:51 +0000 (12:41 -0800)]
Change-Id: I67a37e4164333ba8dc9991ef5ce79693efff3bca

builder/src/main/java/com/android/builder/BuilderConstants.java
gradle/src/main/groovy/com/android/build/gradle/AppPlugin.groovy

index 5c1500b..9e90aed 100644 (file)
@@ -35,4 +35,5 @@ public class BuilderConstants {
     public final static String RELEASE = "release";
 
     public final static String TEST = "test";
+    public final static String LINT = "lint";
 }
index 97b74bf..b8eb23d 100644 (file)
@@ -126,9 +126,8 @@ class AppPlugin extends com.android.build.gradle.BasePlugin implements org.gradl
      */
     private void addBuildType(BuildType buildType) {
         String name = buildType.name
-        if (name.startsWith(BuilderConstants.TEST)) {
-            throw new RuntimeException("BuildType names cannot start with 'test'")
-        }
+        checkName(name, "BuildType")
+
         if (productFlavors.containsKey(name)) {
             throw new RuntimeException("BuildType names cannot collide with ProductFlavor names")
         }
@@ -148,10 +147,10 @@ class AppPlugin extends com.android.build.gradle.BasePlugin implements org.gradl
      * @param productFlavor the product flavor
      */
     private void addProductFlavor(GroupableProductFlavor productFlavor) {
-        if (productFlavor.name.startsWith(BuilderConstants.TEST)) {
-            throw new RuntimeException("ProductFlavor names cannot start with 'test'")
-        }
-        if (buildTypes.containsKey(productFlavor.name)) {
+        String name = productFlavor.name
+        checkName(name, "ProductFlavor")
+
+        if (buildTypes.containsKey(name)) {
             throw new RuntimeException("ProductFlavor names cannot collide with BuildType names")
         }
 
@@ -166,6 +165,17 @@ class AppPlugin extends com.android.build.gradle.BasePlugin implements org.gradl
         productFlavors[productFlavor.name] = productFlavorData
     }
 
+    private static void checkName(String name, String displayName) {
+        if (name.startsWith(BuilderConstants.TEST)) {
+            throw new RuntimeException(
+                    "${displayName} names cannot start with '${BuilderConstants.TEST}'")
+        }
+
+        if (BuilderConstants.LINT.equals(name)) {
+            throw new RuntimeException("${displayName} names cannot be ${BuilderConstants.LINT}")
+        }
+    }
+
     /**
      * Task creation entry point.
      */