diff --git a/firebase-appdistribution-gradle/CHANGELOG.md b/firebase-appdistribution-gradle/CHANGELOG.md index 47ab28bcf2e..c1d846be790 100644 --- a/firebase-appdistribution-gradle/CHANGELOG.md +++ b/firebase-appdistribution-gradle/CHANGELOG.md @@ -1,10 +1,4 @@ -### App Distribution Gradle plugin version 5.2.0 +### App Distribution Gradle plugin version 5.2.1 -* {{fixed}} Fixed compatibility with AGP 9.0.0. - -* {{fixed}} Fixed issue causing distribution properties (configured with `firebaseAppDistribution { }`) to work incorrectly within Android buildType configurations on Kotlin Gradle builds. - -* {{deprecated}} Support for AGP < 8.1.0 (and Gradle < 8.0) has been deprecated and will be removed in a future release. - -* {{deprecated}} Previously, we allowed `firebaseAppDistribution { }` at the root of an app's gradle build (in addition to inside its buildTypes and productFlavors). This undocumented feature has been renamed to `firebaseAppDistributionDefault { }`. In a future release, the original DSL, `firebaseAppDistribution { }`, will only work in productFlavors and buildTypes. +* {{fixed}} Declare dependency on GoogleServices plugin diff --git a/firebase-appdistribution-gradle/firebase-appdistribution-gradle.gradle b/firebase-appdistribution-gradle/firebase-appdistribution-gradle.gradle index 31829ae9466..e9ca6bb1e1d 100644 --- a/firebase-appdistribution-gradle/firebase-appdistribution-gradle.gradle +++ b/firebase-appdistribution-gradle/firebase-appdistribution-gradle.gradle @@ -209,7 +209,6 @@ dependencies { testImplementation(gradleApi()) testImplementation(libs.junit) testImplementation("com.android.tools.build:gradle:7.2.0") - testImplementation("org.mockito:mockito-core:3.3.3") testImplementation("com.github.stefanbirkner:system-rules:1.19.0") testImplementation("org.mockito:mockito-core:4.11.0") testImplementation("org.mockito.kotlin:mockito-kotlin:4.1.0") diff --git a/firebase-appdistribution-gradle/gradle.properties b/firebase-appdistribution-gradle/gradle.properties index a746f6b740a..353979eb19c 100644 --- a/firebase-appdistribution-gradle/gradle.properties +++ b/firebase-appdistribution-gradle/gradle.properties @@ -1,3 +1,3 @@ groupId=com.google.firebase artifactId=firebase-appdistribution-gradle -version=5.2.0 +version=5.2.1 diff --git a/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/AddTestersTaskTest.kt b/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/AddTestersTaskTest.kt index dfd6894dd15..018fa065e3d 100644 --- a/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/AddTestersTaskTest.kt +++ b/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/AddTestersTaskTest.kt @@ -70,9 +70,9 @@ class AddTestersTaskTest { fun testAddTesters_failsIfTooManyTesters() { testGroovyBuild.writeBuildFiles() testGradleProject.writeServiceCredentialsFile() - val tooManyEmailsBuffer = StringBuffer() + val tooManyEmailsBuffer = StringBuilder() for (i in 0..1000) { - tooManyEmailsBuffer.append("tester" + i + "e.mail\n") + tooManyEmailsBuffer.append("tester${i}e.mail\n") } val tooManyEmailsFile = testGradleProject.createFile("too-many-emails.txt") writeFile(tooManyEmailsFile, tooManyEmailsBuffer.toString()) diff --git a/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/RemoveTestersTaskTest.kt b/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/RemoveTestersTaskTest.kt index c4c90001807..cb55d3a1a10 100644 --- a/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/RemoveTestersTaskTest.kt +++ b/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/RemoveTestersTaskTest.kt @@ -115,9 +115,9 @@ class RemoveTestersTaskTest { fun testRemoveTesters_failsIfTooManyTesters() { testGroovyBuild.writeBuildFiles() testGradleProject.writeServiceCredentialsFile() - val tooManyEmailsBuffer = StringBuffer() + val tooManyEmailsBuffer = StringBuilder() for (i in 0..1000) { - tooManyEmailsBuffer.append("tester" + i + "e.mail\n") + tooManyEmailsBuffer.append("tester${i}e.mail\n") } val tooManyEmailsFile = testGradleProject.createFile("too-many-emails.txt") writeFile(tooManyEmailsFile, tooManyEmailsBuffer.toString()) diff --git a/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/TestGradleProject.kt b/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/TestGradleProject.kt index c4613142c60..c1dc395213b 100644 --- a/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/TestGradleProject.kt +++ b/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/TestGradleProject.kt @@ -182,7 +182,7 @@ class TestGradleProject : ExternalResource() { */ @Throws(IOException::class) private fun writeLocalProperties() = - writeFile(localProperties, "sdk.dir=${System.getenv("ANDROID_SDK_ROOT")}") + writeFile(localProperties, "sdk.dir=${System.getenv("ANDROID_HOME")}") /** Utility for creating a file in the project dir */ @Throws(IOException::class) fun createFile(fileName: String?) = projectDir.newFile(fileName) diff --git a/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/UploadDistributionTaskTest.kt b/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/UploadDistributionTaskTest.kt index 5bd90d56f5e..71ebc2116f5 100644 --- a/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/UploadDistributionTaskTest.kt +++ b/firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/UploadDistributionTaskTest.kt @@ -721,8 +721,10 @@ class UploadDistributionTaskTest { companion object { // Latest gradle, AGP and google-services plugin versions. Update this when new releases come // out. - private const val LATEST_GRADLE_VERSION = "9.2.1" - private const val LATEST_AGP_VERSION = "9.0.0-beta01" + // Also remember to update the latest AGP/gradle versions in BeePlusGradleProject.java. + // firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/BeePlusGradleProject.java#L59-L60 + private const val LATEST_GRADLE_VERSION = "9.3.0" + private const val LATEST_AGP_VERSION = "9.1.0-alpha05" private const val LATEST_GOOGLE_SERVICES_VERSION = "4.4.4" // For tests against Gradle 9, we get the error: // "In order to compile Java 9+ source, please set compileSdkVersion to 30 or above" diff --git a/firebase-appdistribution-gradle/src/main/java/com/google/firebase/appdistribution/gradle/AppDistributionException.kt b/firebase-appdistribution-gradle/src/main/java/com/google/firebase/appdistribution/gradle/AppDistributionException.kt index 7ed8f1bfcc3..4da52c674ec 100644 --- a/firebase-appdistribution-gradle/src/main/java/com/google/firebase/appdistribution/gradle/AppDistributionException.kt +++ b/firebase-appdistribution-gradle/src/main/java/com/google/firebase/appdistribution/gradle/AppDistributionException.kt @@ -92,7 +92,7 @@ constructor( GET_TEST_RETRIEVAL_FAILURE("App Distribution could not retrieve the test."), GET_TEST_TIMEOUT("It took longer than expected to process your test, please try again."), GET_TEST_FAILED("Automated test failed or was inconclusive."), - TEST_CASE_NOT_FOUND("Could not find find test case with ID"), + TEST_CASE_NOT_FOUND("Could not find test case with ID"), TEST_CASE_WITH_LOGIN_RESOURCES( "Username or password resources for automatic login cannot be specified when test cases IDs are set" ), diff --git a/firebase-appdistribution-gradle/src/main/java/com/google/firebase/appdistribution/gradle/tasks/UploadDistributionTaskConfigurator.kt b/firebase-appdistribution-gradle/src/main/java/com/google/firebase/appdistribution/gradle/tasks/UploadDistributionTaskConfigurator.kt index 6f99aac2736..8d9d22f489a 100644 --- a/firebase-appdistribution-gradle/src/main/java/com/google/firebase/appdistribution/gradle/tasks/UploadDistributionTaskConfigurator.kt +++ b/firebase-appdistribution-gradle/src/main/java/com/google/firebase/appdistribution/gradle/tasks/UploadDistributionTaskConfigurator.kt @@ -124,6 +124,7 @@ object UploadDistributionTaskConfigurator { val googleServicesOutputDirectory = try { task.project.tasks.named(googleServicesTaskName).flatMap { googleServicesTask -> + task.mustRunAfter(googleServicesTask) val resourceDirProp = googleServicesTask.property("intermediateDir") as File task.project.objects.directoryProperty().fileValue(resourceDirProp) } diff --git a/firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/BeePlusGradleProject.java b/firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/BeePlusGradleProject.java index 9611c586c19..aaf54417806 100644 --- a/firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/BeePlusGradleProject.java +++ b/firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/BeePlusGradleProject.java @@ -56,8 +56,10 @@ private static String getRequiredSystemProperty(String propertyName) { } static final String PACKAGE_NAME = "com.firebase.appdistribution.prober"; - static final String LATEST_AGP_VERSION = "9.0.0-beta01"; - static final String LATEST_GRADLE_VERSION = "9.2.1"; + // Also remember to update the latest AGP/gradle versions in UploadDistributionTaskTest.kt + // firebase-appdistribution-gradle/src/integrationTest/java/com/google/firebase/appdistribution/gradle/UploadDistributionTaskTest.kt#L724-L726 + static final String LATEST_AGP_VERSION = "9.1.0-alpha05"; + static final String LATEST_GRADLE_VERSION = "9.3.0"; // The project number for App Distro Probes. We need to use this project // because this is the one that's actually linked to play for BeePlus, // which is required for AAB uploads. @@ -106,7 +108,7 @@ public BuildResult runAddTesters(Collection emails) { String.join(",", emails)) .withPluginClasspath(pluginClasspathFiles) .withGradleVersion(LATEST_GRADLE_VERSION) - .withEnvironment(ImmutableMap.of("FIREBASE_TOKEN", getToken())) + .withEnvironment(getEnvironment()) .build(); } @@ -122,7 +124,7 @@ public BuildResult runAddTesters(File emailsFile) { emailsFile.getAbsolutePath()) .withPluginClasspath(pluginClasspathFiles) .withGradleVersion(LATEST_GRADLE_VERSION) - .withEnvironment(ImmutableMap.of("FIREBASE_TOKEN", getToken())) + .withEnvironment(getEnvironment()) .build(); } @@ -139,7 +141,7 @@ public BuildResult runRemoveTesters(Collection emails) { "--debug") .withPluginClasspath(pluginClasspathFiles) .withGradleVersion(LATEST_GRADLE_VERSION) - .withEnvironment(ImmutableMap.of("FIREBASE_TOKEN", getToken())) + .withEnvironment(getEnvironment()) .build(); } @@ -156,7 +158,7 @@ public BuildResult runRemoveTesters(File emailsFile) { "--debug") .withPluginClasspath(pluginClasspathFiles) .withGradleVersion(LATEST_GRADLE_VERSION) - .withEnvironment(ImmutableMap.of("FIREBASE_TOKEN", getToken())) + .withEnvironment(getEnvironment()) .build(); } @@ -166,7 +168,7 @@ public BuildResult runUploadApk() { .withArguments("assembleDebug", "appDistributionUploadDebug", "--info") .withPluginClasspath(pluginClasspathFiles) .withGradleVersion(LATEST_GRADLE_VERSION) - .withEnvironment(ImmutableMap.of("FIREBASE_TOKEN", getToken())) + .withEnvironment(getEnvironment()) .build(); } @@ -176,7 +178,7 @@ public BuildResult runUploadAab() { .withArguments("bundleDebug", "appDistributionUploadDebug", "--info") .withPluginClasspath(pluginClasspathFiles) .withGradleVersion(LATEST_GRADLE_VERSION) - .withEnvironment(ImmutableMap.of("FIREBASE_TOKEN", getToken())) + .withEnvironment(getEnvironment()) .build(); } @@ -189,6 +191,18 @@ private String getToken() { return token; } + private ImmutableMap getEnvironment() { + ImmutableMap.Builder env = ImmutableMap.builder(); + env.put("FIREBASE_TOKEN", getToken()); + String androidHome = System.getenv("ANDROID_HOME"); + if (isNullOrEmpty(androidHome)) { + throw new IllegalStateException( + "ANDROID_HOME environment variable not set. This is required for production tests."); + } + env.put("ANDROID_HOME", androidHome); + return env.build(); + } + /** Writes the {@code build.gradle} file for the test project with default build file options */ public void writeBuildFile() throws IOException { writeBuildFile(BuildFileUploadOptions.builder().build()); @@ -222,7 +236,7 @@ public void writeBuildFile(BuildFileUploadOptions options) throws IOException { + "\n" + "android {\n" + " namespace '%s'\n" - + " compileSdkVersion 27\n" + + " compileSdkVersion 30\n" + "\n" + " defaultConfig {\n" + " applicationId '%s'\n" diff --git a/firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/README b/firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/README index 008c26589eb..b95e14e814b 100644 --- a/firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/README +++ b/firebase-appdistribution-gradle/src/prodTest/java/com/google/firebase/appdistribution/gradle/README @@ -13,6 +13,7 @@ big changes, similar to how one would do manual testing via a test matrix. Before running the tests, you need to create a `local.properties` file in the root directory of the `firebase-android-buildtools` project with the following properties: ```properties +sdk.dir= firebase.appId= firebase.projectNumber= ``` diff --git a/firebase-perf-gradle/src/test/java/com/google/firebase/perf/plugin/transform/InstrumentationApiCompatTest.java b/firebase-perf-gradle/src/test/java/com/google/firebase/perf/plugin/transform/InstrumentationApiCompatTest.java index 79890936070..4d690665fdd 100644 --- a/firebase-perf-gradle/src/test/java/com/google/firebase/perf/plugin/transform/InstrumentationApiCompatTest.java +++ b/firebase-perf-gradle/src/test/java/com/google/firebase/perf/plugin/transform/InstrumentationApiCompatTest.java @@ -51,8 +51,8 @@ public class InstrumentationApiCompatTest { private static final String GRADLE_RELEASES_URL = "https://api.github.com/repos/gradle/gradle/releases/latest"; // Latest verified versions. Update these as new versions are released and verified. - private static final String VERIFIED_AGP_VERSION = "9.0.0-alpha14"; - private static final String VERIFIED_GRADLE_VERSION = "9.2.0"; + private static final String VERIFIED_AGP_VERSION = "9.1.0-alpha03"; + private static final String VERIFIED_GRADLE_VERSION = "9.2.1"; private final OkHttpClient client = new OkHttpClient(); @RegisterExtension public GradleBuildProject gradleBuildProject = new GradleBuildProject(); @@ -88,6 +88,14 @@ public void gradleBuildRunsInstrumentationForAllVariants_latestGradleAndAgp() th LOGGER.log(Level.INFO, "Latest AGP Version: {0}", latestAgpVersion); LOGGER.log(Level.WARNING, "If this test fails, please file an issue or a bug"); + if (latestAgpVersion.equals(VERIFIED_AGP_VERSION) + && latestGradleVersion.equals(VERIFIED_GRADLE_VERSION)) { + LOGGER.log( + Level.INFO, + "Latest gradle and AGP versions are identical to verified versions. Skipping test."); + return; + } + GradleBuildResult result = gradleBuildProject .getJavaRunnerBuilder()