micronaut-projects / micronaut-projects/micronaut-data
Defend against data-processor and data-runtime at different versions?
- Dominant language
- Java
- Stars
- 482
- Forks
- 229
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 32
Description
Not strictly a bug, nor really a micronaut-data problem but it felt like something to capture somewhere as an FYI and useful for people googling.
I've been chasing weird micronaut-data-jdbc errors on and off for a few weeks now, the most recent one was trying to use the new changes from #496. After much frustration I realised that the version of the micronaut-data annotationProcessor was at 2.0.1 added via the `micronaut-bom` and the data-runtime (and friends) was being correctly set via the `micronaut-data-bom` at 2.1.1.
Because micronaut-bom and micronaut-data-bom aren't managed in sync, this difference can happen, it depends on what version of each you are running and when they were released relative to each other, micronaut-core 2.1.1 references micronaut-data 2.0.1 (https://github.com/micronaut-projects/micronaut-core/blob/v2.1.1/gradle.properties), but 2.1.2 references 2.1.1 (https://github.com/micronaut-projects/micronaut-core/blob/v2.1.2/gradle.properties).
This isn't visible in simple hello world style gradle projects either, as gradle will forcibly use the newer version of micronaut-data-bom if specified all in one project (as you would expect). But in a multi-module project where you might have your `annotationProcessor` dependencies specified in one `.gradle` file / project and your runtime dependencies in another gradle will quite happily use different versions of BOMs and thus different versions of dependencies.
To workaround this, we've added this to our Gradle file to override this unexpected behaviour:
```
configurations {
all {
resolutionStrategy.dependencySubstitution {
//micronaut bom and micronaut-data bom have diff versions which can cause weird issues if they diverge, so force them to be the same
substitute(platform(module("io.micronaut.data:micronaut-data-bom"))).with(platform(module("io.micronaut.data:micronaut-data-bom:${micronautDataVersion}")))
}
}
}
```
The result of all of that is that the compiled annotation metadata and other things the annotationProcessor does appears to assume that it will be used by the equivalent runtime version? Rather than aim for any backwards compat? If so should a warning be shown when this assumption is broken? Or if the intent is for it to be backwards compat is that captured in automated testing (which sounds really hard)?
Contributor guide
Research direction
Start with issue #496 and the linked micronaut-core 2.1.1 and 2.1.2 gradle.properties references, then reproduce the multi-module Gradle dependency resolution described for micronaut-bom and micronaut-data-bom. Done requires a decided scope for documenting the version constraint, warning about mismatches, or testing compatibility.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system, databases
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100