@@ -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+ failMissingRequiredImplementation(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-
7164static 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
@@ -100,9 +93,7 @@ static void failInvalidRemoteBuildCacheType(String remoteBuildCacheType, String
10093 throw new IllegalStateException (message)
10194}
10295
103- // Included builds may not have the necessary plugin applied.
104- // Only fail if the top-level build is missing the required extension.
105- static void failMissingRequiredPlugin (String remoteBuildCacheType , String expDir , String docsRoot ) {
96+ static void failMissingRequiredImplementation (String remoteBuildCacheType , String expDir , String docsRoot ) {
10697 def errorFile = new File (expDir, ' errors.txt' )
10798 errorFile. text = " Remote build cache connector type '${ remoteBuildCacheType} ' requested, but the required plugin is not applied."
10899 if (remoteBuildCacheType == ' develocity' ) {
0 commit comments