Skip to content

Commit f8f2804

Browse files
committed
Throw an exception when building with an AGP version lower than the minimum supported
1 parent 729f383 commit f8f2804

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

embrace-gradle-plugin-integration-tests/src/test/java/io/embrace/android/gradle/integration/testcases/AgpSupportTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,14 @@ class AgpSupportTest {
3434
fun `maximum supported version`() = runTest(MaxVersion)
3535

3636
@Test
37-
fun `unsupported old version`() {
37+
fun `unsupported old gradle version`() {
3838
rule.runTest(
3939
fixture = "android-version-support",
4040
task = "assembleRelease",
4141
testMatrix = TestMatrix.UnsupportedOldGradleVersion,
4242
projectType = ProjectType.ANDROID,
43-
expectedExceptionMessage = "Embrace Gradle Plugin requires Gradle version ${GradleVersion.MIN_VERSION} or newer",
43+
expectedExceptionMessage =
44+
"Embrace requires Gradle version ${GradleVersion.MIN_VERSION} or higher. Please update your Gradle version.",
4445
assertions = {
4546
verifyNoUploads()
4647
}

embrace-gradle-plugin/src/main/java/io/embrace/android/gradle/plugin/EmbraceGradlePlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class EmbraceGradlePlugin : Plugin<Project> {
4646

4747
private fun validateMinGradleVersion() {
4848
if (!isAtLeast(GradleVersion.MIN_VERSION)) {
49-
error("Embrace Gradle Plugin requires Gradle version ${GradleVersion.MIN_VERSION} or newer")
49+
error("Embrace requires Gradle version ${GradleVersion.MIN_VERSION} or higher. Please update your Gradle version.")
5050
}
5151
}
5252
}

embrace-gradle-plugin/src/main/java/io/embrace/android/gradle/plugin/EmbraceGradlePluginDelegate.kt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@ class EmbraceGradlePluginDelegate {
2828
variantConfigurationsListProperty: ListProperty<VariantConfig>,
2929
extension: SwazzlerExtension,
3030
) {
31+
val agpWrapper = AgpWrapperImpl(project)
32+
validateMinAgpVersion(agpWrapper)
33+
3134
val behavior = PluginBehaviorImpl(project, extension)
3235
Logger.setPluginLogLevel(behavior.logLevel)
33-
val agpWrapper = AgpWrapperImpl(project)
3436
val networkService = OkHttpNetworkService(behavior.baseUrl)
3537

3638
BuildTelemetryService.register(
@@ -127,4 +129,10 @@ class EmbraceGradlePluginDelegate {
127129
}
128130
}
129131
}
132+
133+
private fun validateMinAgpVersion(agpWrapper: AgpWrapper) {
134+
if (agpWrapper.version < AgpVersion.MIN_VERSION) {
135+
error("Embrace requires AGP version ${AgpVersion.MIN_VERSION} or higher. Please update your AGP version.")
136+
}
137+
}
130138
}

embrace-gradle-plugin/src/main/java/io/embrace/android/gradle/plugin/agp/AgpVersion.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.android.build.api.AndroidPluginVersion
55
sealed class AgpVersion(private val version: AndroidPluginVersion) : Comparable<AgpVersion> {
66

77
class CURRENT(version: AndroidPluginVersion) : AgpVersion(version)
8+
object MIN_VERSION : AgpVersion(AndroidPluginVersion(7, 4, 2))
89
object AGP_8_3_0 : AgpVersion(AndroidPluginVersion(8, 3, 0))
910
object AGP_8_0_0 : AgpVersion(AndroidPluginVersion(8, 0, 0))
1011

0 commit comments

Comments
 (0)