Spotless: Conflicts on JGit transitive dependency version

Created on 13 Jul 2020  路  3Comments  路  Source: diffplug/spotless

I was trying to add spotless 5.0.0 to a project but it gave me an error, and I tried other versions and I saw that it failed for versions 4.5.0 and newer.

Software version:

  • spotless 4.5.0+
  • pl.allegro.tech.build.axion-release 1.12.0
  • gradle 6.5.1
  • macOs Mojave (10.14.6)

It fails when I add the plugin to the plugins block.

ERROR: Unable to load class 'org.eclipse.jgit.transport.JschConfigSessionFactory'.

In version 4.5.0 the JGit dependency was updated from 5.7 to 5.8 (commit link) while axion is still using version 5.7.

I also saw that there is an Issue #587 that seems to touch on this subject.

This issue has also been reported on the axion repo (issue link).

Result of gradlew spotlessCheck --stacktrace:

* Exception is:
java.lang.NoClassDefFoundError: org.eclipse.jgit.transport.JschConfigSessionFactory
        at pl.allegro.tech.build.axion.release.infrastructure.git.GitRepository.<init>(GitRepository.java:28)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
        at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
        at pl.allegro.tech.build.axion.release.infrastructure.di.ScmRepositoryFactory.create(ScmRepositoryFactory.groovy:23)
        at pl.allegro.tech.build.axion.release.infrastructure.di.ScmRepositoryFactory$create.call(Unknown Source)
        at pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext.create(GradleAwareContext.groovy:15)
        at pl.allegro.tech.build.axion.release.infrastructure.di.GradleAwareContext$create.call(Unknown Source)
        at pl.allegro.tech.build.axion.release.domain.VersionConfig.ensureContextExists(VersionConfig.groovy:167)
        at pl.allegro.tech.build.axion.release.domain.VersionConfig.getUncachedVersion(VersionConfig.groovy:155)
        at pl.allegro.tech.build.axion.release.domain.VersionConfig_Decorated.getUncachedVersion(Unknown Source)
        at pl.allegro.tech.build.axion.release.domain.VersionConfig.ensureVersionExists(VersionConfig.groovy:150)
        at pl.allegro.tech.build.axion.release.domain.VersionConfig.getVersion(VersionConfig.groovy:130)
        at pl.allegro.tech.build.axion.release.domain.VersionConfig_Decorated.getVersion(Unknown Source)
        at Build_gradle.<init>(build.gradle.kts:51)
        at Program.execute(Unknown Source)
        at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.eval(Interpreter.kt:502)
        at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.evaluateSecondStageOf(Interpreter.kt:418)
        at Program.execute(Unknown Source)
        at org.gradle.kotlin.dsl.execution.Interpreter$ProgramHost.eval(Interpreter.kt:502)
        at org.gradle.kotlin.dsl.execution.Interpreter.eval(Interpreter.kt:200)
        at org.gradle.kotlin.dsl.provider.StandardKotlinScriptEvaluator.evaluate(KotlinScriptEvaluator.kt:119)
        at org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory$create$1.invoke(KotlinScriptPluginFactory.kt:51)
        at org.gradle.kotlin.dsl.provider.KotlinScriptPluginFactory$create$1.invoke(KotlinScriptPluginFactory.kt:36)
        at org.gradle.kotlin.dsl.provider.KotlinScriptPlugin.apply(KotlinScriptPlugin.kt:34)
        at org.gradle.configuration.BuildOperationScriptPlugin$1$1.run(BuildOperationScriptPlugin.java:69)
      (... a bunch supress here)
        at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
Caused by: java.lang.ClassNotFoundException: org.eclipse.jgit.transport.JschConfigSessionFactory
        ... 148 more
question

All 3 comments

Thanks for sharing. I'm surprised that Gradle can't handle 5.7 and 5.8. You are correct that #587 would be a resolution. Another option would be to futz with something like this:

buildscript {
  configurations.classpath {
    resolutionStrategy {
      force 'org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r'
    }
  }
}

Thanks for sharing. I'm surprised that Gradle can't handle 5.7 and 5.8. You are correct that #587 would be a resolution. Another option would be to futz with something like this:

buildscript {
  configurations.classpath {
    resolutionStrategy {
      force 'org.eclipse.jgit:org.eclipse.jgit:5.7.0.202003110725-r'
    }
  }
}

It does indeed work as a workaround.

I'm gonna close as dupe of #587, since that is likely the only long-term fix for this recurrent issue. Happy to revisit if new info emerges.

Was this page helpful?
0 / 5 - 0 ratings