apache / apache/grails-core

Gradle plugin injects the Grails BOM into every configuration, defeating defaultDependencies (breaks core Gradle jacoco plugin)

Open
#16,335 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Groovy
Stars
2.9k
Forks
975
Avg merge
1d 22h
Merged PRs (30d)
92

Description

### Expected Behavior

Applying core Gradle's `jacoco` plugin to a Grails app works as it does on Grails 7.x (verified on 7.2.3): the `jacocoAgent` and `jacocoAnt` configurations resolve `org.jacoco:org.jacoco.agent` / `org.jacoco:org.jacoco.ant` via the jacoco plugin's `defaultDependencies { }` hooks, and `./gradlew test` runs with coverage.

### Actual Behaviour

On Grails 8.0.0-M3 through M6 (re-verified at each milestone), `./gradlew test` fails:
```
Execution failed for task ':test'.
> Expected configuration ':jacocoAgent' to contain exactly one file, however, it contains no files.
```
`./gradlew dependencies --configuration jacocoAgent` shows the configuration contains only the injected `org.apache.grails:grails-hibernate5-bom` platform. Gradle's `defaultDependencies { }` only fires on an otherwise-empty configuration (gradle/gradle#11209 documents that a platform-only configuration does not count as empty), so the jacoco plugin's defaults never run and the agent/ant jars are never added. The mechanism breaks any plugin that populates a configuration via `defaultDependencies`, not just jacoco.

Likely origin: `GrailsGradlePlugin.applyGrailsBom()` (introduced with the platform migration in #15467, applied in `afterEvaluate`) adds the BOM platform to every configuration; #16009 already adjusted its ordering. Suggested fix: scope the injection away from configurations owned by other plugins (or add the platform via `withDependencies` only where version management is actually needed).

Workaround we use:
```groovy
dependencies {
jacocoAgent "org.jacoco:org.jacoco.agent:${jacoco.toolVersion}"
jacocoAnt "org.jacoco:org.jacoco.ant:${jacoco.toolVersion}"
}
```

### Steps To Reproduce

1. Grails 8.0.0-M6 app (M3, M4, M5 also reproduce).
2. Add `id 'jacoco'` to the plugins block.
3. `./gradlew test`
4. Observe the `jacocoAgent` failure; `./gradlew dependencies --configuration jacocoAgent` shows only the BOM platform.

### Environment Information

Linux, JDK 21 (Temurin 21.0.12), Gradle 8.14. Grails 8.0.0-M3..M6, grails-hibernate5 BOM. Works on Grails 7.2.3

### Example Application

https://github.com/davidbairdala/grails8-bom-defaultdeps-repro

### Version

8.0.0-M6 (present since 8.0.0-M3)

Contributor guide

Open the contributing guide

Research direction

Start in GrailsGradlePlugin.applyGrailsBom(), especially its afterEvaluate ordering, and compare the behavior introduced by #15467 and adjusted by #16009. Reproduce with the linked Grails 8 BOM example by applying the jacoco plugin, then inspect ./gradlew dependencies --configuration jacocoAgent and ./gradlew test. Done means jacocoAgent and jacocoAnt resolve their default dependencies and tests run with coverage without the workaround.

Written by the indexing model from the issue text.

Assessment

Tech stack
groovy
Domain
build-system, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.