This is an automated email from the ASF dual-hosted git repository. jamesfredley pushed a commit to branch fix/dependency-repository-dos in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 3389c6f6a989293f227784b1b3cf439e80590ca3 Author: James Fredley <[email protected]> AuthorDate: Fri Oct 9 12:08:13 2026 -0400 Stop re-checking released dependencies on every CI build Dependency resolution asked repo.grails.org for every release because Maven Central was not declared. Fixed versions are immutable, so they now resolve from Maven Central with releasesOnly(). gradle-tooling-api 8.14.5 is not on Central and is requested only from Gradle's release repository. Plugin libraries that are not on Central come from the Plugin Portal. Snapshots are still polled immediately on ordinary CI. Dynamic release listings stay at Gradle's 24 hour default. The CI modules-2 cache key moves to gradle-deps-v2 so metadata that was sticky to repo.grails.org is not restored. Assisted-by: opencode:grok-4.7 --- .github/workflows/gradle.yml | 48 ++++++++--------- build-logic/plugins/build.gradle | 8 +++ .../grails/buildsrc/DependencyCachePolicy.groovy | 41 ++++++++++++++ .../buildsrc/GrailsRepoSettingsPlugin.groovy | 30 ++++++++++- .../buildsrc/DependencyCachePolicySpec.groovy | 42 +++++++++++++++ .../buildsrc/GrailsRepoSettingsPluginSpec.groovy | 63 ++++++++++++++++++++++ build-logic/settings.gradle | 23 +++++++- build.gradle | 7 +-- gradle/plugin-repositories.gradle | 6 ++- grails-forge/build.gradle | 8 ++- 10 files changed, 237 insertions(+), 39 deletions(-) diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 96e77e62a7..91cfc4a3be 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -44,9 +44,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -88,9 +88,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -152,9 +152,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -198,9 +198,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -241,9 +241,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -311,9 +311,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -474,9 +474,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -519,9 +519,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -559,9 +559,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -624,9 +624,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -690,9 +690,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: @@ -801,9 +801,9 @@ jobs: path: | ~/.gradle/caches/modules-2 ~/.gradle/wrapper - key: gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties') }} + key: gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}-${{ hashFiles('**/dependencies.gradle', '**/gradle-wrapper.properties', 'build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy') }} restore-keys: | - gradle-deps-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- + gradle-deps-v2-${{ runner.os }}-${{ github.base_ref || github.ref_name }}- - name: "🐘 Setup Gradle" uses: gradle/actions/setup-gradle@9c971963bec38e04b3d30dcc455b5382be2fdbfb # v6.3.0 with: diff --git a/build-logic/plugins/build.gradle b/build-logic/plugins/build.gradle index b53a3ca9dd..560367f772 100644 --- a/build-logic/plugins/build.gradle +++ b/build-logic/plugins/build.gradle @@ -38,6 +38,14 @@ dependencies { implementation "${gradleBomDependencies['grails-publish-plugin']}" implementation "org.gradle.crypto.checksum:org.gradle.crypto.checksum.gradle.plugin:${gradleProperties.gradleChecksumPluginVersion}" implementation "org.cyclonedx.bom:org.cyclonedx.bom.gradle.plugin:${gradleProperties.gradleCycloneDxPluginVersion}" + + testImplementation "org.spockframework:spock-core:${gradleBomDependencyVersions['gradle-spock.version']}" + testImplementation gradleTestKit() + testRuntimeOnly 'org.junit.platform:junit-platform-launcher' +} + +tasks.named('test', Test) { + useJUnitPlatform() } gradlePlugin { diff --git a/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/DependencyCachePolicy.groovy b/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/DependencyCachePolicy.groovy new file mode 100644 index 0000000000..4c65f8324b --- /dev/null +++ b/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/DependencyCachePolicy.groovy @@ -0,0 +1,41 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.grails.buildsrc + +import groovy.transform.CompileStatic +import org.gradle.api.artifacts.ResolutionStrategy + +/** + * Fixed releases are not governed by these knobs. Dynamic listings are release metadata, + * so they stay at Gradle's 24 hour default. Changing modules (snapshots) are polled + * immediately on ordinary CI and within 10 minutes locally. A reproducible build must + * not re-resolve them, even when CI is also set. + */ +@CompileStatic +class DependencyCachePolicy { + + static void apply(ResolutionStrategy strategy, boolean ci, boolean reproducible) { + strategy.cacheDynamicVersionsFor(24, 'hours') + if (reproducible) { + strategy.cacheChangingModulesFor(24, 'hours') + } else if (ci) { + strategy.cacheChangingModulesFor(0, 'hours') + } else { + strategy.cacheChangingModulesFor(10, 'minutes') + } + } +} diff --git a/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy b/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy index e14287f644..e8dbae35ba 100644 --- a/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy +++ b/build-logic/plugins/src/main/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPlugin.groovy @@ -32,7 +32,11 @@ class GrailsRepoSettingsPlugin implements Plugin<Settings> { if (System.getenv('GRAILS_INCLUDE_MAVEN_LOCAL')) { repo.mavenLocal() } - repo.mavenCentral() + repo.mavenCentral { + mavenContent { + it.releasesOnly() + } + } repo.gradlePluginPortal() repo.maven { url = 'https://repository.apache.org/content/groups/snapshots' @@ -71,8 +75,30 @@ class GrailsRepoSettingsPlugin implements Plugin<Settings> { if (System.getenv('GRAILS_INCLUDE_MAVEN_LOCAL')) { repo.mavenLocal() } + // Maven Central first. Gradle disables a repository for the rest of the build on a transport + // failure and fails resolution instead of trying the next repository, so the primary + // repository has to be the one expected to stay up. + repo.mavenCentral { + mavenContent { + it.releasesOnly() + } + } + // 8.14.5 of gradle-tooling-api is not on Maven Central. Ask only Gradle's release + // repository for that module. A non-exclusive include leaves Central and mavenLocal + // eligible if they have it; exclusiveContent would hide it from both. repo.maven { - url = 'https://repo.grails.org/grails/restricted' + url = 'https://repo.gradle.org/gradle/libs-releases' + content { + it.includeModule('org.gradle', 'gradle-tooling-api') + } + mavenContent { + it.releasesOnly() + } + } + // Plugin jars and plugin markers are published to the Plugin Portal, not Maven Central. + // buildSrc consumes several of them as libraries. Central remains first, so a + // release Central has is not also requested here. + repo.gradlePluginPortal { mavenContent { it.releasesOnly() } diff --git a/build-logic/plugins/src/test/groovy/org/apache/grails/buildsrc/DependencyCachePolicySpec.groovy b/build-logic/plugins/src/test/groovy/org/apache/grails/buildsrc/DependencyCachePolicySpec.groovy new file mode 100644 index 0000000000..064e3c9d61 --- /dev/null +++ b/build-logic/plugins/src/test/groovy/org/apache/grails/buildsrc/DependencyCachePolicySpec.groovy @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.grails.buildsrc + +import org.gradle.api.artifacts.ResolutionStrategy +import spock.lang.Specification + +class DependencyCachePolicySpec extends Specification { + + def "dynamic release listings stay cached for 24 hours and snapshots follow the build kind"() { + given: + ResolutionStrategy strategy = Mock(ResolutionStrategy) + + when: + DependencyCachePolicy.apply(strategy, ci, reproducible) + + then: + 1 * strategy.cacheDynamicVersionsFor(24, 'hours') + 1 * strategy.cacheChangingModulesFor(changingValue, changingUnits) + + where: + ci | reproducible || changingValue | changingUnits + false | false || 10 | 'minutes' + true | false || 0 | 'hours' + false | true || 24 | 'hours' + true | true || 24 | 'hours' + } +} diff --git a/build-logic/plugins/src/test/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPluginSpec.groovy b/build-logic/plugins/src/test/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPluginSpec.groovy new file mode 100644 index 0000000000..d2f9b7232c --- /dev/null +++ b/build-logic/plugins/src/test/groovy/org/apache/grails/buildsrc/GrailsRepoSettingsPluginSpec.groovy @@ -0,0 +1,63 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.grails.buildsrc + +import org.gradle.testkit.runner.GradleRunner +import spock.lang.Specification +import spock.lang.TempDir + +class GrailsRepoSettingsPluginSpec extends Specification { + + @TempDir + File projectDir + + def "dependency repositories prefer Central and do not fall back to repo.grails.org"() { + given: + new File(projectDir, 'settings.gradle').text = ''' + plugins { + id 'org.apache.grails.buildsrc.repo' + } + + def lines = [] + dependencyResolutionManagement.repositories.each { repo -> + lines << repo.url.toString() + } + new File(settingsDir, 'repos.txt').text = lines.join(System.lineSeparator()) + ''' + new File(projectDir, 'build.gradle').text = '' + + when: + GradleRunner.create() + .withProjectDir(projectDir) + .withPluginClasspath() + .withArguments('--offline', 'help') + .withEnvironment(System.getenv().findAll { key, value -> key != 'GRAILS_INCLUDE_MAVEN_LOCAL' }) + .build() + + then: + List<String> urls = new File(projectDir, 'repos.txt').text.readLines() + urls == [ + 'https://repo.maven.apache.org/maven2/', + 'https://repo.gradle.org/gradle/libs-releases', + 'https://plugins.gradle.org/m2', + 'https://repository.apache.org/content/groups/snapshots', + 'https://central.sonatype.com/repository/maven-snapshots', + 'https://repository.apache.org/content/groups/staging', + ] + !urls.any { it.contains('repo.grails.org') } + } +} diff --git a/build-logic/settings.gradle b/build-logic/settings.gradle index e8e735d27d..ac5e1cafbd 100644 --- a/build-logic/settings.gradle +++ b/build-logic/settings.gradle @@ -63,8 +63,27 @@ dependencyResolutionManagement { if (System.getenv('GRAILS_INCLUDE_MAVEN_LOCAL')) { mavenLocal() } - mavenCentral() - gradlePluginPortal() + mavenCentral { + mavenContent { + releasesOnly() + } + } + // 8.14.5 of gradle-tooling-api is not on Maven Central. This build cannot apply the + // settings plugin it produces, so the same module filter is declared here. + maven { + url = 'https://repo.gradle.org/gradle/libs-releases' + content { + includeModule('org.gradle', 'gradle-tooling-api') + } + mavenContent { + releasesOnly() + } + } + gradlePluginPortal { + mavenContent { + releasesOnly() + } + } // publish plugin maven { url = 'https://repository.apache.org/content/groups/snapshots' diff --git a/build.gradle b/build.gradle index 761c5b7ccd..7f80dac0f8 100644 --- a/build.gradle +++ b/build.gradle @@ -27,6 +27,7 @@ import java.time.format.DateTimeFormatter import javax.inject.Inject +import org.apache.grails.buildsrc.DependencyCachePolicy import org.apache.tools.ant.taskdefs.condition.Os ext { @@ -75,11 +76,7 @@ subprojects { } configurations.configureEach { - resolutionStrategy { - def cacheHours = isCiBuild || isReproducibleBuild ? 0 : 24 - cacheDynamicVersionsFor(cacheHours, 'hours') - cacheChangingModulesFor(cacheHours, 'hours') - } + DependencyCachePolicy.apply(resolutionStrategy, isCiBuild as boolean, isReproducibleBuild as boolean) } } diff --git a/gradle/plugin-repositories.gradle b/gradle/plugin-repositories.gradle index 260a9c7a66..e688489da8 100644 --- a/gradle/plugin-repositories.gradle +++ b/gradle/plugin-repositories.gradle @@ -21,7 +21,11 @@ ext.configurePluginRepositories = { RepositoryHandler repositories -> if (System.getenv('GRAILS_INCLUDE_MAVEN_LOCAL')) { repositories.mavenLocal() } - repositories.mavenCentral() + repositories.mavenCentral { + mavenContent { + releasesOnly() + } + } repositories.gradlePluginPortal() repositories.maven { url = uri('https://repository.apache.org/content/groups/snapshots') diff --git a/grails-forge/build.gradle b/grails-forge/build.gradle index e427bce710..5e33fbac15 100644 --- a/grails-forge/build.gradle +++ b/grails-forge/build.gradle @@ -17,6 +17,8 @@ * under the License. */ +import org.apache.grails.buildsrc.DependencyCachePolicy + import java.time.Instant import java.time.LocalDate import java.time.ZoneOffset @@ -51,11 +53,7 @@ allprojects { subprojects { configurations.configureEach { - resolutionStrategy { - def cacheHours = isCiBuild || isReproducibleBuild ? 0 : 24 - cacheDynamicVersionsFor(cacheHours, 'hours') - cacheChangingModulesFor(cacheHours, 'hours') - } + DependencyCachePolicy.apply(resolutionStrategy, isCiBuild as boolean, isReproducibleBuild as boolean) } }
