This is an automated email from the ASF dual-hosted git repository. matrei pushed a commit to branch improve-gradle-conf-time in repository https://gitbox.apache.org/repos/asf/grails-core.git
commit 18728430203fe27cc441789ce6b88a501be00f2d Author: Mattias Reichel <[email protected]> AuthorDate: Thu Jul 30 10:00:51 2026 +0200 build: improve project dependency substitution logic in functional test configuration This speeds up the configuration phase. --- gradle/functional-test-config.gradle | 69 +++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 32 deletions(-) diff --git a/gradle/functional-test-config.gradle b/gradle/functional-test-config.gradle index 1c8f38ed4b..178d70a409 100644 --- a/gradle/functional-test-config.gradle +++ b/gradle/functional-test-config.gradle @@ -17,49 +17,54 @@ * under the License. */ -rootProject.subprojects +def substitutableProjects = rootProject.subprojects .findAll { !(it.name in testProjects) && !(it.name in docProjects) && !(it.name in cliProjects) } - .each { project.evaluationDependsOn(it.path) } + .collect { + project.evaluationDependsOn(it.path) + return [ + project: it, + artifactId: it.findProperty('pomArtifactId') ?: it.name, + cliArtifactId: it.findProperty('cliArtifactId') + ] + } configurations.configureEach { resolutionStrategy.dependencySubstitution { // Test projects will often include dependencies from local projects. This will ensure any dependencies // included will be substituted with the local projects in this repository instead of pulling upstream. - for (def possibleProject : rootProject.subprojects) { - if (!(possibleProject.name in testProjects) && !(possibleProject.name in docProjects) && !(possibleProject.name in cliProjects)) { - def artifactId = possibleProject.findProperty('pomArtifactId') ?: possibleProject.name - def substitutedArtifact = "$possibleProject.group:$artifactId" - //TODO: This does not handle libraries that are both test fixtures & a libraries like grails-data-mongodb, - // see grails-test-examples-mongodb-base, & grails-test-examples-mongodb-hibernate5 for project() workaround - if (possibleProject.name == 'grails-bom') { - substitute module(substitutedArtifact) using platform(project(':grails-bom')) - } - else if(possibleProject.name == 'grails-geb') { - def selector = it.variant(module(substitutedArtifact)) { VariantSelectionDetails details -> - details.capabilities { ModuleDependencyCapabilitiesHandler handler -> - handler.requireCapability("${substitutedArtifact}-test-fixtures" as String) - } - } - - def replacement = it.variant(project(":$possibleProject.name")) { v -> - v.capabilities { it.requireCapability("${substitutedArtifact}-test-fixtures") } + for (def substitution : substitutableProjects) { + def possibleProject = substitution.project + def substitutedArtifact = "$possibleProject.group:${substitution.artifactId}" + //TODO: This does not handle libraries that are both test fixtures & a libraries like grails-data-mongodb, + // see grails-test-examples-mongodb-base, & grails-test-examples-mongodb-hibernate5 for project() workaround + if (possibleProject.name == 'grails-bom') { + substitute module(substitutedArtifact) using platform(project(':grails-bom')) + } + else if(possibleProject.name == 'grails-geb') { + def selector = it.variant(module(substitutedArtifact)) { VariantSelectionDetails details -> + details.capabilities { ModuleDependencyCapabilitiesHandler handler -> + handler.requireCapability("${substitutedArtifact}-test-fixtures" as String) } - substitute selector using replacement } - else { - substitute module(substitutedArtifact) using project(":$possibleProject.name") + + def replacement = it.variant(project(":$possibleProject.name")) { v -> + v.capabilities { it.requireCapability("${substitutedArtifact}-test-fixtures") } } + substitute selector using replacement + } + else { + substitute module(substitutedArtifact) using project(":$possibleProject.name") + } - // companion cli artifacts are additional publications of the same project, - // reachable locally through the project's cli capability - def cliArtifactId = possibleProject.findProperty('cliArtifactId') - if (cliArtifactId) { - def cliCoordinate = "$possibleProject.group:$cliArtifactId" as String - def cliReplacement = it.variant(project(":$possibleProject.name")) { v -> - v.capabilities { it.requireCapability(cliCoordinate) } - } - substitute module(cliCoordinate) using cliReplacement + // companion cli artifacts are additional publications of the same project, + // reachable locally through the project's cli capability + def cliArtifactId = possibleProject.findProperty('cliArtifactId') + if (cliArtifactId) { + def cliCoordinate = "$possibleProject.group:$cliArtifactId" as String + def cliReplacement = it.variant(project(":$possibleProject.name")) { v -> + v.capabilities { it.requireCapability(cliCoordinate) } } + substitute module(cliCoordinate) using cliReplacement } } }
