https://github.com/usefulness/maven-sympathy
Gradle plugin that ensures first-order dependencies select the same version as they request.
https://github.com/usefulness/maven-sympathy
Last synced: over 1 year ago
JSON representation
Gradle plugin that ensures first-order dependencies select the same version as they request.
- Host: GitHub
- URL: https://github.com/usefulness/maven-sympathy
- Owner: usefulness
- License: mit
- Created: 2024-03-30T11:30:51.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-03-29T17:50:49.000Z (over 1 year ago)
- Last Synced: 2025-04-09T22:09:40.516Z (over 1 year ago)
- Language: Kotlin
- Homepage: https://jakewharton.com/nonsensical-maven-is-still-a-gradle-problem/
- Size: 306 KB
- Stars: 16
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# maven-sympathy
[](https://github.com/usefulness/maven-sympathy/actions/workflows/default.yml)
[](https://plugins.gradle.org/plugin/io.github.usefulness.maven-sympathy)

https://jakewharton.com/nonsensical-maven-is-still-a-gradle-problem/
### Usage:
```groovy
plugins {
id("io.github.usefulness.maven-sympathy") version "{{version}}"
}
```
Version Catalog
```toml
usefulness-maven-sympathy = { id = "io.github.usefulness.maven-sympathy", version = "{{version}}" }
```
From now on, the `sympathyForMrMaven` will run on every `check` task invocation.
```
[compileClasspath] dependency org.jetbrains.kotlin:kotlin-stdlib:1.9.22 version changed: 1.9.22 → 1.9.23
[runtimeClasspath] dependency org.jetbrains.kotlin:kotlin-stdlib:1.9.22 version changed: 1.9.22 → 1.9.23
> Task :sympathyForMrMaven FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':sympathyForMrMaven'.
> Declared dependencies were upgraded transitively. See task output above. Please update their versions.
```
#### Advanced configuration
###### Customize plugin behavior
Configurable via `io.github.usefulness.mavensympathy.MavenSympathyExtension` extension.
Groovy
```groovy
mavenSympathy {
attachStrategy = io.github.usefulness.mavensympathy.AttachStrategy.Default
}
```
Kotlin
```kotlin
mavenSympathy {
attachStrategy = io.github.usefulness.mavensympathy.AttachStrategy.Default
}
```
- `attachStrategy` - Defines how the plugin will hook up with the project to listen for version mismatches. Has to be one of:
- `WatchAllResolvableConfigurations` - the plugin will check all resolvable configurations for versions mismatch
- `ExtractFromMavenPublishComponents` - the plugin will only watch configurations attached to SoftwareComponents
The implementation relies on internal gradle APIs and may break in the future Gradle versions.
- `Default` - if `maven-publish` is present, the plugin will behave as `ExtractFromMavenPublishComponents`, if not it will fall back to `WatchAllResolvableConfigurations` behavior.
The behavior is subject to change, but the assumption is it should cover most common setups.
###### Customize task behavior
Groovy
```groovy
tasks.named("sympathyForMrMaven") {
behaviorOnMismatch = BehaviorOnMismatch.Fail
}
```
Kotlin
```kotlin
tasks.named("sympathyForMrMaven") {
behaviorOnMismatch = BehaviorOnMismatch.Fail
}
```
`behaviorOnMismatch` - one of `Fail` (prints error logs + fails the build) or `Warn` (only prints error logs)