Skip to content

Gradle plugin that ensures first-order dependencies select the same version as they request.

License

Notifications You must be signed in to change notification settings

usefulness/maven-sympathy

Repository files navigation

maven-sympathy

Build Project Latest Version Maven Central

https://jakewharton.com/nonsensical-maven-is-still-a-gradle-problem/

Usage:

plugins {
    id("io.github.usefulness.maven-sympathy") version "{{version}}"
}
Version Catalog
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
mavenSympathy {
    attachStrategy = io.github.usefulness.mavensympathy.AttachStrategy.Default
}
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
tasks.named("sympathyForMrMaven") {
    behaviorOnMismatch = BehaviorOnMismatch.Fail
}
Kotlin
tasks.named<io.github.usefulness.mavensympathy.SympathyForMrMavenTask>("sympathyForMrMaven") {
    behaviorOnMismatch = BehaviorOnMismatch.Fail
}

behaviorOnMismatch - one of Fail (prints error logs + fails the build) or Warn (only prints error logs)