diff --git a/.github/renovate.json5 b/.github/renovate.json5 new file mode 100644 index 00000000..d2b109d9 --- /dev/null +++ b/.github/renovate.json5 @@ -0,0 +1,47 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:recommended", + "github>gradle/renovate-agent//presets/dv.json5", + ], + // See https://docs.renovatebot.com/modules/manager/regex/ + // Dependabot is used for all other updates. + "enabledManagers": ["regex"], + "customManagers": [ + { + // Matches AGP versions annotated with a "renovate: AGP version" comment + customType: "regex", + fileMatch: [ + "src/main/resources/versions\\.json5", + "gradle\\.properties", + ], + matchStrings: [ + // For JSON: the first double-quoted string below the comment line, e.g. "1.0.0" + "\/\/ renovate: AGP version\\s+?\"(?\\S+?)\"", + // For properties: the value of the first property below the comment line, e.g. anyProperty=1.0.0 + "# renovate: AGP version\\s+?\\S+?=(?\\S+?)(?:\\s|$)", + ], + "datasourceTemplate": "maven", + "versioningTemplate": "maven", + "depNameTemplate": "com.android.tools.build:gradle", + "registryUrlTemplate": "https://dl.google.com/dl/android/maven2/", + }, + ], + // Ensure patches to older minors are opened, even if a newer minor is available + // In versions.json5, means older minors will still be checked for a newer patch + "separateMinorPatch": true, + "packageRules": [ + { + // In versions.json5, disable bumps of major/minor, which should be added as new properties + "matchDepNames": ["com.android.tools.build:gradle"], + "matchUpdateTypes": ["major", "minor"], + "matchFileNames": ["src/main/resources/versions\\.json5"], + "enabled": false, + }, + { + // Group changes to versions.json5 + "matchFileNames": ["src/main/resources/versions\\.json5"], + "groupName": "supportedVersions", + }, + ], +} diff --git a/build.gradle.kts b/build.gradle.kts index cd71d019..6de09420 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ import com.gradle.develocity.agent.gradle.test.PredictiveTestSelectionProfile.FAST import com.gradle.develocity.agent.gradle.test.PredictiveTestSelectionProfile.STANDARD import groovy.json.JsonSlurper +import groovy.json.JsonParserType // Upgrade transitive dependencies in plugin classpath buildscript { @@ -162,7 +163,14 @@ tasks.test { } } -getSupportedVersions().keys.forEach { androidVersion -> +val latestVersion = providers.gradleProperty("org.gradle.android.latestKnownAgpVersion") +val supportedVersions = readSupportedVersions() + +check(latestVersion.get() in supportedVersions) { + "The project must be updated to support AGP $latestVersion. Please add it to supported versions." +} + +supportedVersions.keys.forEach { androidVersion -> val versionSpecificTest = tasks.register(androidTestTaskName(androidVersion)) { description = "Runs the multi-version tests for AGP $androidVersion" group = "verification" @@ -257,8 +265,9 @@ fun releaseNotes(): Provider { } @Suppress("UNCHECKED_CAST") -fun getSupportedVersions(): Map> { - val versionFile = providers.fileContents(layout.projectDirectory.file("src/main/resources/versions.json")) - return (JsonSlurper() - .parse(versionFile.asBytes.get()) as Map>>).getValue("supportedVersions") +fun readSupportedVersions(): Map> { + val versionFile = providers.fileContents(layout.projectDirectory.file("src/main/resources/versions.json5")) + val slurper = JsonSlurper().setType(JsonParserType.LAX) + val json = slurper.parse(versionFile.asBytes.get()) as Map>> + return json.getValue("supportedVersions") } diff --git a/gradle.properties b/gradle.properties index c32a211a..b2a6c14b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,3 +5,6 @@ org.gradle.jvmargs=-Duser.language=en -Duser.country=US -Dfile.encoding=UTF-8 org.gradle.kotlin.dsl.allWarningsAsErrors=true systemProp.pts.enabled=true + +# renovate: AGP version +org.gradle.android.latestKnownAgpVersion=8.9.0-alpha04 diff --git a/src/main/groovy/org/gradle/android/Versions.groovy b/src/main/groovy/org/gradle/android/Versions.groovy index c60e26f5..bd23c8c5 100644 --- a/src/main/groovy/org/gradle/android/Versions.groovy +++ b/src/main/groovy/org/gradle/android/Versions.groovy @@ -5,6 +5,7 @@ import com.google.common.collect.ImmutableMultimap import com.google.common.collect.ImmutableSortedSet import com.google.common.collect.Multimap import groovy.json.JsonSlurper +import groovy.json.JsonParserType import groovy.transform.CompileStatic import groovy.transform.TypeCheckingMode import org.gradle.util.GradleVersion @@ -17,7 +18,8 @@ class Versions { static final VersionNumber CURRENT_ANDROID_VERSION static { - def versions = new JsonSlurper().parse(AndroidCacheFixPlugin.classLoader.getResource("versions.json")) + def slurper = new JsonSlurper().setType(JsonParserType.LAX) + def versions = slurper.parse(AndroidCacheFixPlugin.classLoader.getResource("versions.json5")) def builder = ImmutableMultimap.builder() versions.supportedVersions.each { String androidVersion, List gradleVersions -> diff --git a/src/main/resources/versions.json b/src/main/resources/versions.json5 similarity index 63% rename from src/main/resources/versions.json rename to src/main/resources/versions.json5 index 63897cbe..2a91682f 100644 --- a/src/main/resources/versions.json +++ b/src/main/resources/versions.json5 @@ -1,50 +1,65 @@ { "supportedVersions": { + // renovate: AGP version "8.9.0-alpha04": [ "8.12" ], + // renovate: AGP version "8.8.0-beta01": [ "8.12" ], + // renovate: AGP version "8.7.2": [ "8.12" ], + // renovate: AGP version "8.6.1": [ "8.12" ], + // renovate: AGP version "8.5.2": [ "8.12" ], + // renovate: AGP version "8.4.2": [ "8.12" ], + // renovate: AGP version "8.3.2": [ "8.12" ], + // renovate: AGP version "8.2.2": [ "8.12" ], + // renovate: AGP version "8.1.4": [ "8.12" ], + // renovate: AGP version "8.0.2": [ "8.0.2" ], + // renovate: AGP version "7.4.2": [ "7.6.2" ], + // renovate: AGP version "7.3.1": [ "7.4.2", "7.6.2" ], + // renovate: AGP version "7.2.2": [ "7.3.3", "7.6.2" ], + // renovate: AGP version "7.1.3": [ "7.2", "7.6.2" ], + // renovate: AGP version "7.0.4": [ "7.0.2", "7.6.2" diff --git a/src/test/groovy/org/gradle/android/CrossVersionOutcomeAndRelocationTest.groovy b/src/test/groovy/org/gradle/android/CrossVersionOutcomeAndRelocationTest.groovy index 8f8fbc23..47e6c00f 100644 --- a/src/test/groovy/org/gradle/android/CrossVersionOutcomeAndRelocationTest.groovy +++ b/src/test/groovy/org/gradle/android/CrossVersionOutcomeAndRelocationTest.groovy @@ -135,7 +135,8 @@ class CrossVersionOutcomeAndRelocationTest extends AbstractTest { private static ExpectedResults expectedResults(VersionNumber androidVersion, VersionNumber kotlinVersion) { def builder = new ExpectedOutcomeBuilder() - def outcomesResource = CrossVersionOutcomeAndRelocationTest.classLoader.getResource("expectedOutcomes/${androidVersion}_outcomes.json") + def path = "expectedOutcomes/${androidVersion.major}.${androidVersion.minor}_outcomes.json" + def outcomesResource = CrossVersionOutcomeAndRelocationTest.classLoader.getResource(path) if (outcomesResource == null) { throw new IllegalStateException("Could not find expectedOutcomes/${androidVersion}_outcomes.json - make sure an outcomes file exists for this version!") diff --git a/src/test/groovy/org/gradle/android/WorkaroundTest.groovy b/src/test/groovy/org/gradle/android/WorkaroundTest.groovy index e6766081..fe3de77a 100644 --- a/src/test/groovy/org/gradle/android/WorkaroundTest.groovy +++ b/src/test/groovy/org/gradle/android/WorkaroundTest.groovy @@ -11,21 +11,21 @@ class WorkaroundTest extends Specification { expect: workarounds.collect { it.class.simpleName.replaceAll(/Workaround/, "") }.sort() == expectedWorkarounds.sort() where: - androidVersion | expectedWorkarounds - "8.9.0-alpha04" | ['JdkImage'] - "8.8.0-beta01" | ['JdkImage'] - "8.7.2" | ['JdkImage'] - "8.6.1" | ['JdkImage'] - "8.5.2" | ['JdkImage'] - "8.4.2" | ['JdkImage'] - "8.3.2" | ['MergeSourceSetFolders', 'JdkImage'] - "8.2.2" | ['MergeSourceSetFolders', 'JdkImage', 'PackageForUnitTest'] - "8.1.4" | ['MergeSourceSetFolders', 'JdkImage', 'PackageForUnitTest'] - "8.0.2" | ['MergeSourceSetFolders', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] - "7.4.2" | ['MergeSourceSetFolders', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] - "7.3.1" | ['MergeSourceSetFolders', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] - "7.2.2" | ['MergeSourceSetFolders', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] - "7.1.3" | ['BundleLibraryClasses', 'CompileLibraryResources', 'DataBindingMergeDependencyArtifacts', 'LibraryJniLibs', 'MergeNativeLibs', 'MergeSourceSetFolders', 'StripDebugSymbols', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] - "7.0.4" | ['BundleLibraryClasses', 'CompileLibraryResources', 'DataBindingMergeDependencyArtifacts', 'LibraryJniLibs', 'MergeNativeLibs', 'MergeSourceSetFolders', 'StripDebugSymbols', 'ZipMergingTask', 'PackageForUnitTest'] + androidVersion | expectedWorkarounds + "8.9" | ['JdkImage'] + "8.8" | ['JdkImage'] + "8.7" | ['JdkImage'] + "8.6" | ['JdkImage'] + "8.5" | ['JdkImage'] + "8.4" | ['JdkImage'] + "8.3" | ['MergeSourceSetFolders', 'JdkImage'] + "8.2" | ['MergeSourceSetFolders', 'JdkImage', 'PackageForUnitTest'] + "8.1" | ['MergeSourceSetFolders', 'JdkImage', 'PackageForUnitTest'] + "8.0" | ['MergeSourceSetFolders', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] + "7.4" | ['MergeSourceSetFolders', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] + "7.3" | ['MergeSourceSetFolders', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] + "7.2" | ['MergeSourceSetFolders', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] + "7.1" | ['BundleLibraryClasses', 'CompileLibraryResources', 'DataBindingMergeDependencyArtifacts', 'LibraryJniLibs', 'MergeNativeLibs', 'MergeSourceSetFolders', 'StripDebugSymbols', 'ZipMergingTask', 'JdkImage', 'PackageForUnitTest'] + "7.0" | ['BundleLibraryClasses', 'CompileLibraryResources', 'DataBindingMergeDependencyArtifacts', 'LibraryJniLibs', 'MergeNativeLibs', 'MergeSourceSetFolders', 'StripDebugSymbols', 'ZipMergingTask', 'PackageForUnitTest'] } } diff --git a/src/test/resources/expectedOutcomes/7.0.4_outcomes.json b/src/test/resources/expectedOutcomes/7.0_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/7.0.4_outcomes.json rename to src/test/resources/expectedOutcomes/7.0_outcomes.json diff --git a/src/test/resources/expectedOutcomes/7.1.3_outcomes.json b/src/test/resources/expectedOutcomes/7.1_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/7.1.3_outcomes.json rename to src/test/resources/expectedOutcomes/7.1_outcomes.json diff --git a/src/test/resources/expectedOutcomes/7.2.2_outcomes.json b/src/test/resources/expectedOutcomes/7.2_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/7.2.2_outcomes.json rename to src/test/resources/expectedOutcomes/7.2_outcomes.json diff --git a/src/test/resources/expectedOutcomes/7.3.1_outcomes.json b/src/test/resources/expectedOutcomes/7.3_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/7.3.1_outcomes.json rename to src/test/resources/expectedOutcomes/7.3_outcomes.json diff --git a/src/test/resources/expectedOutcomes/7.4.2_outcomes.json b/src/test/resources/expectedOutcomes/7.4_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/7.4.2_outcomes.json rename to src/test/resources/expectedOutcomes/7.4_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.0.2_outcomes.json b/src/test/resources/expectedOutcomes/8.0_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.0.2_outcomes.json rename to src/test/resources/expectedOutcomes/8.0_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.1.4_outcomes.json b/src/test/resources/expectedOutcomes/8.1_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.1.4_outcomes.json rename to src/test/resources/expectedOutcomes/8.1_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.2.2_outcomes.json b/src/test/resources/expectedOutcomes/8.2_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.2.2_outcomes.json rename to src/test/resources/expectedOutcomes/8.2_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.3.2_outcomes.json b/src/test/resources/expectedOutcomes/8.3_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.3.2_outcomes.json rename to src/test/resources/expectedOutcomes/8.3_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.4.2_outcomes.json b/src/test/resources/expectedOutcomes/8.4_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.4.2_outcomes.json rename to src/test/resources/expectedOutcomes/8.4_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.5.2_outcomes.json b/src/test/resources/expectedOutcomes/8.5_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.5.2_outcomes.json rename to src/test/resources/expectedOutcomes/8.5_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.6.1_outcomes.json b/src/test/resources/expectedOutcomes/8.6_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.6.1_outcomes.json rename to src/test/resources/expectedOutcomes/8.6_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.7.2_outcomes.json b/src/test/resources/expectedOutcomes/8.7_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.7.2_outcomes.json rename to src/test/resources/expectedOutcomes/8.7_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.8.0-beta01_outcomes.json b/src/test/resources/expectedOutcomes/8.8_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.8.0-beta01_outcomes.json rename to src/test/resources/expectedOutcomes/8.8_outcomes.json diff --git a/src/test/resources/expectedOutcomes/8.9.0-alpha04_outcomes.json b/src/test/resources/expectedOutcomes/8.9_outcomes.json similarity index 100% rename from src/test/resources/expectedOutcomes/8.9.0-alpha04_outcomes.json rename to src/test/resources/expectedOutcomes/8.9_outcomes.json