Skip to content

Commit a3298bf

Browse files
committed
Skip setting build cache implementation on included builds if missing implementation
1 parent dda080b commit a3298bf

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

Diff for: components/scripts/gradle/gradle-init-scripts/configure-remote-build-caching.gradle

+5-12
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,12 @@ settingsEvaluated { Settings settings ->
2323
failInvalidRemoteBuildCacheType(remoteBuildCacheType, expDir)
2424
}
2525

26-
if (isTopLevelBuild && missingRequiredPlugin(settings, remoteBuildCacheType)) {
27-
failMissingRequiredPlugin(remoteBuildCacheType, expDir, docsRoot)
28-
}
29-
3026
def remoteBuildCacheImplementation = getRemoteBuildCacheImplementation(settings, remoteBuildCacheType)
3127
if (remoteBuildCacheImplementation) {
3228
logger.debug("Configuring remote build cache implementation for '${settings.rootProject.name}' as: ${remoteBuildCacheImplementation}")
3329
remote(remoteBuildCacheImplementation)
30+
} else if (isTopLevelBuild) {
31+
failMissingRequiredPlugin(remoteBuildCacheType, expDir, docsRoot)
3432
}
3533
}
3634

@@ -63,17 +61,12 @@ static boolean isInvalidRemoteBuildCacheType(String remoteBuildCacheType) {
6361
return !['develocity', 'gradle-enterprise', 'http'].contains(remoteBuildCacheType)
6462
}
6563

66-
static boolean missingRequiredPlugin(Settings settings, String type) {
67-
return type == "develocity" && !settings.pluginManager.hasPlugin('com.gradle.develocity')
68-
|| type == "gradle-enterprise" && !settings.pluginManager.hasPlugin('com.gradle.enterprise')
69-
}
70-
7164
static Class<? extends BuildCache> getRemoteBuildCacheImplementation(Settings settings, String type) {
72-
if (type == "develocity") {
65+
if (type == 'develocity' && settings.pluginManager.hasPlugin('com.gradle.develocity')) {
7366
return settings.develocity.buildCache
74-
} else if (type == "gradle-enterprise") {
67+
} else if (type == 'gradle-enterprise' && settings.pluginManager.hasPlugin('com.gradle.enterprise')) {
7568
return settings.gradleEnterprise.buildCache
76-
} else if (type == "http") {
69+
} else if (type == 'http') {
7770
return HttpBuildCache
7871
}
7972
return null

0 commit comments

Comments
 (0)