summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTor Norbye <tnorbye@google.com>2013-09-11 09:47:20 -0700
committerTor Norbye <tnorbye@google.com>2013-10-09 15:22:21 -0700
commit2ebf420cea8799d49f895b9f9a09f9f5da19d36b (patch)
tree39aa0dcae4c66ad271b6e9e5579922a34c365d82
parentc73a75e1a5911457971493051bd7e1b42fe5f0ec (diff)
downloadbase-2ebf420cea8799d49f895b9f9a09f9f5da19d36b.tar.gz
Don't require versionName and versionCode in Gradle projects. DO NOT MERGE
Change-Id: I0e97e83d330cc2ef8176465000a07b88e7492222
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ManifestDetectorTest.java8
-rw-r--r--lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ManifestDetector.java10
2 files changed, 16 insertions, 2 deletions
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestDetectorTest.java
index 617ea80748..36efedd03f 100644
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestDetectorTest.java
+++ b/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestDetectorTest.java
@@ -301,6 +301,14 @@ public class ManifestDetectorTest extends AbstractCheckTest {
lintProject("no_version.xml=>AndroidManifest.xml"));
}
+ public void testVersionNotMissingInGradleProjects() throws Exception {
+ mEnabled = Collections.singleton(ManifestDetector.SET_VERSION);
+ assertEquals(""
+ + "No warnings.",
+ lintProject("no_version.xml=>AndroidManifest.xml",
+ "multiproject/library.properties=>build.gradle")); // dummy; only name counts
+ }
+
public void testIllegalReference() throws Exception {
mEnabled = Collections.singleton(ManifestDetector.ILLEGAL_REFERENCE);
assertEquals(""
diff --git a/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ManifestDetector.java b/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ManifestDetector.java
index e7a5ec29e1..33ac1b578a 100644
--- a/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ManifestDetector.java
+++ b/lint/libs/lint-checks/src/main/java/com/android/tools/lint/checks/ManifestDetector.java
@@ -385,7 +385,10 @@ public class ManifestDetector extends Detector implements Detector.XmlScanner {
context.report(ILLEGAL_REFERENCE, element, context.getLocation(element),
"The android:versionCode cannot be a resource url, it must be "
+ "a literal integer", null);
- } else if (codeNode == null && context.isEnabled(SET_VERSION)) {
+ } else if (codeNode == null && context.isEnabled(SET_VERSION)
+ // Not required in Gradle projects; typically defined in build.gradle instead
+ // and inserted at build time
+ && !context.getMainProject().isGradleProject()) {
context.report(SET_VERSION, element, context.getLocation(element),
"Should set android:versionCode to specify the application version", null);
}
@@ -395,7 +398,10 @@ public class ManifestDetector extends Detector implements Detector.XmlScanner {
context.report(ILLEGAL_REFERENCE, element, context.getLocation(element),
"The android:versionName cannot be a resource url, it must be "
+ "a literal string", null);
- } else if (nameNode == null && context.isEnabled(SET_VERSION)) {
+ } else if (nameNode == null && context.isEnabled(SET_VERSION)
+ // Not required in Gradle projects; typically defined in build.gradle instead
+ // and inserted at build time
+ && !context.getMainProject().isGradleProject()) {
context.report(SET_VERSION, element, context.getLocation(element),
"Should set android:versionName to specify the application version", null);
}