diff --git a/build.gradle b/build.gradle index d9fc51a6..277037f6 100644 --- a/build.gradle +++ b/build.gradle @@ -17,24 +17,26 @@ apply plugin: 'java' repositories { + google() jcenter() - maven { - url "http://dl.bintray.com/android/android-tools" - } +} + +ext { + lintVersion = '26.0.0-beta2' } dependencies { - compile 'com.android.tools.lint:lint-api:25.3.0' - compile 'com.android.tools.lint:lint-checks:25.3.0' - testCompile 'junit:junit:4.11' - testCompile 'com.android.tools.lint:lint:25.3.0' - testCompile 'com.android.tools.lint:lint-tests:25.3.0' - testCompile 'com.android.tools:testutils:25.3.0' + compile "com.android.tools.lint:lint-api:$lintVersion" + compile "com.android.tools.lint:lint-checks:$lintVersion" + testCompile "junit:junit:4.11" + testCompile "com.android.tools.lint:lint:$lintVersion" + testCompile "com.android.tools.lint:lint-tests:$lintVersion" + testCompile "com.android.tools:testutils:$lintVersion" } jar { manifest { - attributes("Lint-Registry": "com.example.google.lint.MyIssueRegistry") + attributes("Lint-Registry-v2": "com.example.google.lint.MyIssueRegistry") } } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index b5166dad..13372aef 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 274cf712..9375478b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Fri Aug 21 14:39:26 PDT 2015 +#Wed Aug 09 14:33:29 PDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip diff --git a/src/test/java/com/example/google/lint/MainActivityDetectorTest.java b/src/test/java/com/example/google/lint/MainActivityDetectorTest.java index f98d30a5..6df66364 100644 --- a/src/test/java/com/example/google/lint/MainActivityDetectorTest.java +++ b/src/test/java/com/example/google/lint/MainActivityDetectorTest.java @@ -16,17 +16,12 @@ package com.example.google.lint; -import com.android.annotations.NonNull; import com.android.tools.lint.checks.infrastructure.LintDetectorTest; -import com.android.tools.lint.client.api.LintClient; import com.android.tools.lint.detector.api.Detector; import com.android.tools.lint.detector.api.Issue; -import com.android.tools.lint.detector.api.Project; import java.util.Collections; -import java.util.HashSet; import java.util.List; -import java.util.Set; import static com.android.SdkConstants.FN_ANDROID_MANIFEST_XML; @@ -35,11 +30,6 @@ * to adjust your code for the next tools release. */ public class MainActivityDetectorTest extends LintDetectorTest { - /** - * The set of enabled issues for a given test. - */ - private Set mEnabled = new HashSet(); - @Override protected Detector getDetector() { return new MainActivityDetector(); @@ -50,103 +40,91 @@ protected List getIssues() { return Collections.singletonList(MainActivityDetector.ISSUE); } - /** - * Gets the configuration for the test. - * Each test can have a set of enabled issues by assigning the member field {@link #mEnabled}. - */ - @Override - protected TestConfiguration getConfiguration(LintClient client, Project project) { - return new TestConfiguration(client, project, null) { - @Override - public boolean isEnabled(@NonNull Issue issue) { - return super.isEnabled(issue) && mEnabled.contains(issue); - } - }; - } - /** * Test that a manifest with an activity with a launcher intent has no warnings. */ - public void testHasMainActivity() throws Exception { - mEnabled = Collections.singleton(MainActivityDetector.ISSUE); - String expected = "No warnings."; - String result = lintProject(xml(FN_ANDROID_MANIFEST_XML, "" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "")); - assertEquals(expected, result); + public void testHasMainActivity() { + lint().files( + xml(FN_ANDROID_MANIFEST_XML, "" + + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "")) + .run() + .expectClean(); } /** * Test that a manifest without an activity with a launcher intent reports an error. */ - public void testMissingMainActivity() throws Exception { - mEnabled = Collections.singleton(MainActivityDetector.ISSUE); + public void testMissingMainActivity() { String expected = "AndroidManifest.xml: Error: Expecting AndroidManifest.xml to have an " + "activity with a launcher intent. [MainActivityDetector]\n" + "1 errors, 0 warnings\n"; - String result = lintProject(xml(FN_ANDROID_MANIFEST_XML, "" + - "\n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - "\n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - " \n" + - "")); - assertEquals(expected, result); + lint().files( + xml(FN_ANDROID_MANIFEST_XML, "" + + "\n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "\n" + + " \n" + + " \n" + + "\n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + " \n" + + "")) + .run() + .expect(expected); } /** * Test that a manifest without an <application> tag reports an error. */ - public void testMissingApplication() throws Exception { - mEnabled = Collections.singleton(MainActivityDetector.ISSUE); + public void testMissingApplication() { String expected = "AndroidManifest.xml: Error: Expecting AndroidManifest.xml to have an " + " tag. [MainActivityDetector]\n" + "1 errors, 0 warnings\n"; - String result = lintProject(xml(FN_ANDROID_MANIFEST_XML, "" + - "\n" + - "\n" + - "")); - assertEquals(expected, result); + lint().files( + xml(FN_ANDROID_MANIFEST_XML, "" + + "\n" + + "\n" + + "")) + .run() + .expect(expected); } }