Skip to content

Commit 6f5e7bb

Browse files
RBusarowkodiakhq[bot]
authored andcommitted
remove the google() repository requirement from docs
The `google()` repository should no longer be mandatory, since AGP is no longer in the plugin's runtime classpath.
1 parent 917328a commit 6f5e7bb

4 files changed

Lines changed: 100 additions & 53 deletions

File tree

build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ plugins {
3636
id("mcbuild.artifacts-check")
3737
id("mcbuild.ben-manes")
3838
id("mcbuild.clean")
39-
id("mcbuild.dependency-guard")
4039
id("mcbuild.dokka")
4140
id("mcbuild.knit")
4241
id("mcbuild.kotlin")

modulecheck-gradle/plugin/src/test/kotlin/modulecheck/gradle/BaseGradleTest.kt

Lines changed: 56 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import org.junit.jupiter.api.DynamicTest
3636
import java.io.File
3737
import kotlin.text.RegexOption.IGNORE_CASE
3838

39+
@Suppress("PropertyName")
3940
abstract class BaseGradleTest :
4041
BaseTest(),
4142
ProjectCollector,
@@ -52,62 +53,69 @@ abstract class BaseGradleTest :
5253
override val root: File
5354
get() = testProjectDir
5455

56+
val DEFAULT_BUILD_FILE by resets {
57+
"""
58+
buildscript {
59+
dependencies {
60+
classpath("com.android.tools.build:gradle:$agpVersion")
61+
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
62+
}
63+
}
64+
65+
plugins {
66+
id("com.rickbusarow.module-check")
67+
}
68+
""".trimIndent()
69+
}
70+
5571
val rootBuild by resets {
5672
root.child("build.gradle.kts")
57-
.createSafely(
58-
"""
59-
buildscript {
60-
dependencies {
61-
classpath("com.android.tools.build:gradle:$agpVersion")
62-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
63-
}
64-
}
73+
.createSafely(DEFAULT_BUILD_FILE)
74+
}
75+
76+
val DEFAULT_SETTINGS_FILE by resets {
77+
"""
78+
rootProject.name = "root"
6579
66-
plugins {
67-
id("com.rickbusarow.module-check")
80+
pluginManagement {
81+
repositories {
82+
gradlePluginPortal()
83+
mavenCentral()
84+
mavenLocal()
85+
google()
86+
}
87+
resolutionStrategy {
88+
eachPlugin {
89+
if (requested.id.id.startsWith("com.android")) {
90+
useVersion("$agpVersion")
91+
}
92+
if (requested.id.id == "com.rickbusarow.module-check") {
93+
useVersion("${BuildProperties.VERSION}")
94+
}
95+
if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
96+
useVersion("$kotlinVersion")
97+
}
98+
if (requested.id.id == "com.squareup.anvil") {
99+
useVersion("$anvilVersion")
100+
}
68101
}
69-
""".trimIndent()
70-
)
102+
}
103+
}
104+
dependencyResolutionManagement {
105+
@Suppress("UnstableApiUsage")
106+
repositories {
107+
mavenCentral()
108+
mavenLocal()
109+
google()
110+
}
111+
}
112+
""".trimIndent()
71113
}
114+
72115
val rootSettings by resets {
73116
root.child("settings.gradle.kts")
74117
.createSafely(
75-
"""
76-
rootProject.name = "root"
77-
78-
pluginManagement {
79-
repositories {
80-
gradlePluginPortal()
81-
mavenCentral()
82-
mavenLocal()
83-
google()
84-
}
85-
resolutionStrategy {
86-
eachPlugin {
87-
if (requested.id.id.startsWith("com.android")) {
88-
useVersion("$agpVersion")
89-
}
90-
if (requested.id.id == "com.rickbusarow.module-check") {
91-
useVersion("${BuildProperties.VERSION}")
92-
}
93-
if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
94-
useVersion("$kotlinVersion")
95-
}
96-
if (requested.id.id == "com.squareup.anvil") {
97-
useVersion("$anvilVersion")
98-
}
99-
}
100-
}
101-
}
102-
dependencyResolutionManagement {
103-
@Suppress("UnstableApiUsage")
104-
repositories {
105-
mavenCentral()
106-
mavenLocal()
107-
google()
108-
}
109-
}
110-
""".trimIndent()
118+
DEFAULT_SETTINGS_FILE
111119
)
112120
}
113121

modulecheck-gradle/plugin/src/test/kotlin/modulecheck/gradle/RuntimeClasspathValidationTest.kt

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
package modulecheck.gradle
1717

1818
import io.kotest.matchers.string.shouldContain
19+
import modulecheck.gradle.internal.BuildProperties
20+
import modulecheck.utils.remove
1921
import org.junit.jupiter.api.TestFactory
2022

2123
class RuntimeClasspathValidationTest : BaseGradleTest() {
@@ -52,6 +54,48 @@ class RuntimeClasspathValidationTest : BaseGradleTest() {
5254
}
5355
"""
5456
)
57+
// This is the same settings as the default used in other tests,
58+
// except no `google()` repository. `google()` shouldn't be necessary since there should be
59+
// no dependency upon AGP.
60+
rootSettings.writeText(
61+
"""
62+
rootProject.name = "root"
63+
64+
pluginManagement {
65+
repositories {
66+
gradlePluginPortal()
67+
mavenCentral()
68+
mavenLocal()
69+
}
70+
resolutionStrategy {
71+
eachPlugin {
72+
if (requested.id.id.startsWith("com.android")) {
73+
useVersion("$agpVersion")
74+
}
75+
if (requested.id.id == "com.rickbusarow.module-check") {
76+
useVersion("${BuildProperties.VERSION}")
77+
}
78+
if (requested.id.id.startsWith("org.jetbrains.kotlin")) {
79+
useVersion("$kotlinVersion")
80+
}
81+
if (requested.id.id == "com.squareup.anvil") {
82+
useVersion("$anvilVersion")
83+
}
84+
}
85+
}
86+
}
87+
dependencyResolutionManagement {
88+
@Suppress("UnstableApiUsage")
89+
repositories {
90+
mavenCentral()
91+
mavenLocal()
92+
}
93+
}
94+
""".trimIndent()
95+
)
96+
97+
// just double-check that this settings file is in sync with the default
98+
rootSettings shouldHaveText DEFAULT_SETTINGS_FILE.remove("\\s*google\\(\\)".toRegex())
5599

56100
shouldSucceed(taskName)
57101
}

website/docs/quickstart.mdx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@ values={[
2525
pluginManagement {
2626
repositories {
2727
gradlePluginPortal()
28-
// used for Android Gradle Plugin internally
29-
google()
3028
// Add for SNAPSHOT builds
3129
maven("https://oss.sonatype.org/content/repositories/snapshots/")
3230
}
@@ -51,8 +49,6 @@ plugins {
5149
pluginManagement {
5250
repositories {
5351
gradlePluginPortal()
54-
// used for Android Gradle Plugin internally
55-
google()
5652
// Add for SNAPSHOT builds
5753
maven {
5854
url "https://oss.sonatype.org/content/repositories/snapshots"

0 commit comments

Comments
 (0)