From bc97eb443f7d3fc937d22d72656c9af73e0a5343 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Burstr=C3=B6m?= Date: Thu, 14 May 2020 16:42:25 +0200 Subject: [PATCH] feat: Bump AGP to 3.6.3 and add functional test for it --- build.gradle | 2 +- .../snom/AndroidFunctionalTest.groovy | 75 ++++++++++++++++++- 2 files changed, 75 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 59df00020..752d72f80 100644 --- a/build.gradle +++ b/build.gradle @@ -26,7 +26,7 @@ ext { errorproneVersion = '2.3.4' spotBugsVersion = '4.0.2' slf4jVersion = '1.8.0-beta4' - androidGradlePluginVersion = '3.5.3' + androidGradlePluginVersion = '3.6.3' } dependencies { diff --git a/src/functionalTest/groovy/com/github/spotbugs/snom/AndroidFunctionalTest.groovy b/src/functionalTest/groovy/com/github/spotbugs/snom/AndroidFunctionalTest.groovy index bfea1ca29..43d66f256 100644 --- a/src/functionalTest/groovy/com/github/spotbugs/snom/AndroidFunctionalTest.groovy +++ b/src/functionalTest/groovy/com/github/spotbugs/snom/AndroidFunctionalTest.groovy @@ -37,7 +37,7 @@ class AndroidFunctionalTest extends Specification { } @Requires({env['ANDROID_SDK_ROOT']}) - def "can generate spotbugsRelease depending on variant compilation task"() { + def "can generate spotbugsRelease depending on variant compilation task with AGP 3.5.3"() { given: "a Gradle project to build an Android app" GradleRunner runner = GradleRunner.create() @@ -73,6 +73,79 @@ repositories { jcenter() } +android { + compileSdkVersion 29 + buildToolsVersion '29.0.2' + buildTypes { + release { + minifyEnabled false + } + } +} +""" + + File sourceDir = new File(rootDir, "src/main/java") + sourceDir.mkdirs() + File sourceFile = new File(sourceDir, "Foo.java") + sourceFile << """ +public class Foo { + public static void main(String... args) { + System.out.println("Hello, SpotBugs!"); + } +} +""" + File manifestFile = new File(rootDir, "src/main/AndroidManifest.xml") + manifestFile << """ + +""" + + when: "the spotbugsRelease task is executed" + BuildResult result = runner + .withArguments(":spotbugsRelease", '-s') + .withGradleVersion(version) + .build() + + then: "gradle runs spotbugsMain successfully" + assertEquals(SUCCESS, result.task(":spotbugsRelease").outcome) + } + + @Requires({env['ANDROID_SDK_ROOT']}) + def "can generate spotbugsRelease depending on variant compilation task with AGP 3.6.3"() { + given: "a Gradle project to build an Android app" + GradleRunner runner = + GradleRunner.create() + .withProjectDir(rootDir) + .withPluginClasspath() + .forwardOutput() + .withGradleVersion(version) + + buildFile << """ +buildscript { + repositories { + google() + jcenter() + } + + dependencies { + classpath 'com.android.tools.build:gradle:3.6.3' +""" + runner.pluginClasspath.forEach({ file -> + buildFile << """ + classpath files('${file.absolutePath}') +""" + }) + buildFile << """ + } +} + +apply plugin: 'com.android.application' +apply plugin: 'com.github.spotbugs' + +repositories { + google() + jcenter() +} + android { compileSdkVersion 29 buildToolsVersion '29.0.2'