Плагин SBT вызывает IncompatibleClassChangeError - PullRequest
0 голосов
/ 03 октября 2019

У меня есть два плагина sbt, которые я написал, используя их по отдельности, но использование обоих в проекте приводит к сбою сборки sbt со следующим исключением

[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[error] java.lang.IncompatibleClassChangeError: Implementing class
[error]         at java.lang.ClassLoader.defineClass1(Native Method)
[error]         at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
[error]         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
[error]         at java.net.URLClassLoader.defineClass(URLClassLoader.java:468)
[error]         at java.net.URLClassLoader.access$100(URLClassLoader.java:74)
[error]         at java.net.URLClassLoader$1.run(URLClassLoader.java:369)
[error]         at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
[error]         at java.security.AccessController.doPrivileged(Native Method)
[error]         at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
[error]         at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
[error]         at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
[error]         at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
[error]         at java.lang.Class.forName0(Native Method)
[error]         at java.lang.Class.forName(Class.java:348)
[error]         at sbt.internal.inc.ModuleUtilities$.getObject(ModuleUtilities.scala:20)
[error]         at sbt.internal.inc.ModuleUtilities$.getCheckedObject(ModuleUtilities.scala:27)
[error]         at sbt.internal.inc.ModuleUtilities$.$anonfun$getCheckedObjects$1(ModuleUtilities.scala:31)
[error]         at scala.collection.immutable.Stream.$anonfun$map$1(Stream.scala:414)
[error]         at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1167)
[error]         at scala.collection.immutable.Stream$Cons.tail(Stream.scala:1157)
[error]         at scala.collection.generic.Growable.loop$1(Growable.scala:53)
[error]         at scala.collection.generic.Growable.$plus$plus$eq(Growable.scala:57)
[error]         at scala.collection.generic.Growable.$plus$plus$eq$(Growable.scala:49)
[error]         at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:185)
[error]         at scala.collection.mutable.ListBuffer.$plus$plus$eq(ListBuffer.scala:43)
[error]         at scala.collection.TraversableLike.$plus$plus(TraversableLike.scala:146)
[error]         at scala.collection.TraversableLike.$plus$plus$(TraversableLike.scala:142)
[error]         at scala.collection.immutable.List.$plus$plus(List.scala:206)
[error]         at sbt.internal.PluginDiscovery$.discoverAll(PluginDiscovery.scala:56)
[error]         at sbt.internal.Load$.loadPlugins(Load.scala:1318)
[error]         at sbt.internal.Load$.loadPluginDefinition(Load.scala:1263)
[error]         at sbt.internal.Load$.buildPlugins(Load.scala:1242)
[error]         at sbt.internal.Load$.plugins(Load.scala:1225)
[error]         at sbt.internal.Load$.$anonfun$loadUnit$2(Load.scala:694)
[error]         at sbt.internal.Load$.timed(Load.scala:1395)
[error]         at sbt.internal.Load$.$anonfun$loadUnit$1(Load.scala:694)
[error]         at sbt.internal.Load$.timed(Load.scala:1395)
[error]         at sbt.internal.Load$.loadUnit(Load.scala:688)
[error]         at sbt.internal.Load$.$anonfun$builtinLoader$4(Load.scala:484)
[error]         at sbt.internal.BuildLoader$.$anonfun$componentLoader$5(BuildLoader.scala:176)
[error]         at sbt.internal.BuildLoader.apply(BuildLoader.scala:241)
[error]         at sbt.internal.Load$.loadURI$1(Load.scala:546)
[error]         at sbt.internal.Load$.loadAll(Load.scala:562)
[error]         at sbt.internal.Load$.loadURI(Load.scala:492)
[error]         at sbt.internal.Load$.load(Load.scala:471)
[error]         at sbt.internal.Load$.$anonfun$apply$1(Load.scala:251)
[error]         at sbt.internal.Load$.timed(Load.scala:1395)
[error]         at sbt.internal.Load$.apply(Load.scala:251)
[error]         at sbt.internal.Load$.defaultLoad(Load.scala:69)
[error]         at sbt.BuiltinCommands$.liftedTree1$1(Main.scala:829)
[error]         at sbt.BuiltinCommands$.doLoadProject(Main.scala:829)
[error]         at sbt.BuiltinCommands$.$anonfun$loadProjectImpl$2(Main.scala:800)
[error]         at sbt.Command$.$anonfun$applyEffect$4(Command.scala:142)
[error]         at sbt.Command$.$anonfun$applyEffect$2(Command.scala:137)
[error]         at sbt.Command$.process(Command.scala:181)
[error]         at sbt.MainLoop$.processCommand(MainLoop.scala:151)
[error]         at sbt.MainLoop$.$anonfun$next$2(MainLoop.scala:139)
[error]         at sbt.State$$anon$1.runCmd$1(State.scala:246)
[error]         at sbt.State$$anon$1.process(State.scala:250)
[error]         at sbt.MainLoop$.$anonfun$next$1(MainLoop.scala:139)
[error]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:16)
[error]         at sbt.MainLoop$.next(MainLoop.scala:139)
[error]         at sbt.MainLoop$.run(MainLoop.scala:132)
[error]         at sbt.MainLoop$.$anonfun$runWithNewLog$1(MainLoop.scala:110)
[error]         at sbt.io.Using.apply(Using.scala:22)
[error]         at sbt.MainLoop$.runWithNewLog(MainLoop.scala:104)
[error]         at sbt.MainLoop$.runAndClearLast(MainLoop.scala:59)
[error]         at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:44)
[error]         at sbt.MainLoop$.runLogged(MainLoop.scala:35)
[error]         at sbt.StandardMain$.runManaged(Main.scala:138)
[error]         at sbt.xMain.run(Main.scala:89)
[error]         at xsbt.boot.Launch$$anonfun$run$1.apply(Launch.scala:111)
[error]         at xsbt.boot.Launch$.withContextLoader(Launch.scala:130)
[error]         at xsbt.boot.Launch$.run(Launch.scala:111)
[error]         at xsbt.boot.Launch$$anonfun$apply$1.apply(Launch.scala:37)
[error]         at xsbt.boot.Launch$.launch(Launch.scala:119)
[error]         at xsbt.boot.Launch$.apply(Launch.scala:20)
[error]         at xsbt.boot.Boot$.runImpl(Boot.scala:56)
[error]         at xsbt.boot.Boot$.main(Boot.scala:18)
[error]         at xsbt.boot.Boot.main(Boot.scala)
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? [error] java.lang.IncompatibleClassChangeError: Implementing class
[error] Use 'last' for the full log.

Я создал простой пример проекта, который воспроизводит ошибкуhttps://github.com/austek/sbt-debug-plugin

есть идеи, что может быть причиной или как решить проблему?

1 Ответ

1 голос
/ 03 октября 2019

К сожалению, ваш пример проекта не работает для меня:

[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: nl.jworks.markdown_to_asciidoc#markdown_to_asciidoc;1.0: not found
[warn]  :: ch.netzwerg#paleo-core;0.11.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

Однако , если вы внимательно прочитали оригинальную ошибку, вы найдете

[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings. 

Обычно это означает, что оба ваших плагина имеют хотя бы одну общую зависимость, но в разных (несовместимых) версиях.

Я бы порекомендовал запустить sbt в ваших проектах project папку и запустить evicted. Это должно показать вам, если зависимость в одном из ваших плагинов была удалена из-за более новой версии в зависимостях вашего другого плагина.

ОБНОВЛЕНИЕ

ПРИМЕЧАНИЕ Ваша проблема возникает, когда sbt пытается использовать ваши загруженные плагины. Фаза SBT, на которой загружаются плагины, является просто еще одним SBT-проектом внутри вашего фактического проекта, расположенного в каталоге с зловещим названием project.

Когда вы cd попадете в этот каталог project внутри корневого каталога вашего проекта и выполните sbt evicted вы получите следующий вывод:

[info] Loading global plugins from /home/sascha/.sbt/1.0/plugins
[info] Loading project definition from /home/sascha/dev/sbt-debug-plugin/project/project
[info] Updating ProjectRef(uri("file:/home/sascha/dev/sbt-debug-plugin/project/project/"), "project-build")...
[info] Done updating.
[info] Loading settings for project project from plugins.sbt ...
[info] Set current project to project (in build file:/home/sascha/dev/sbt-debug-plugin/project/)
[info] Updating ...
[warn] Resolving a snapshot version. It's going to be slow unless you use `updateOptions := updateOptions.value.withLatestSnapshots(false)` options.
[info] Out of 1 candidates we found for com.mdsol#sbt-swagger2markup;0.1-SNAPSHOT in sonatype-snapshots, we are choosing sonatype-snapshots.
[info] downloading https://jcenter.bintray.com/nl/jworks/markdown_to_asciidoc/markdown_to_asciidoc/1.0/markdown_to_asciidoc-1.0.jar ...
[info] downloading https://jcenter.bintray.com/ch/netzwerg/paleo-core/0.11.0/paleo-core-0.11.0.jar ...
[info] downloading https://repo1.maven.org/maven2/org/pegdown/pegdown/1.4.2/pegdown-1.4.2.jar ...
[info] downloading https://repo1.maven.org/maven2/org/jsoup/jsoup/1.8.1/jsoup-1.8.1.jar ...
[info] downloading https://repo1.maven.org/maven2/org/parboiled/parboiled-java/1.1.6/parboiled-java-1.1.6.jar ...
[info] downloading https://repo1.maven.org/maven2/org/parboiled/parboiled-core/1.1.6/parboiled-core-1.1.6.jar ...
[info]  [SUCCESSFUL ] nl.jworks.markdown_to_asciidoc#markdown_to_asciidoc;1.0!markdown_to_asciidoc.jar (240ms)
[info]  [SUCCESSFUL ] org.pegdown#pegdown;1.4.2!pegdown.jar (269ms)
[info]  [SUCCESSFUL ] org.parboiled#parboiled-java;1.1.6!parboiled-java.jar(bundle) (606ms)
[info]  [SUCCESSFUL ] org.parboiled#parboiled-core;1.1.6!parboiled-core.jar(bundle) (713ms)
[info]  [SUCCESSFUL ] ch.netzwerg#paleo-core;0.11.0!paleo-core.jar (723ms)
[info]  [SUCCESSFUL ] org.jsoup#jsoup;1.8.1!jsoup.jar (792ms)
[info] Done updating.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[warn] Found version conflict(s) in library dependencies; some are suspected to be binary incompatible:
[warn]  * com.github.jnr:jnr-constants:0.9.12 is selected over {0.9.9, 0.9.11}
[warn]      +- com.github.jnr:jnr-enxio:0.19                      (depends on 0.9.11)
[warn]      +- com.github.jnr:jnr-unixsocket:0.20                 (depends on 0.9.11)
[warn]      +- org.jruby:jruby-core:9.2.7.0                       (depends on 0.9.11)
[warn]      +- com.github.jnr:jnr-posix:3.0.49                    (depends on 0.9.9)
[warn]  * com.github.jnr:jnr-enxio:0.19 is selected over 0.18
[warn]      +- org.jruby:jruby-core:9.2.7.0                       (depends on 0.19)
[warn]      +- com.github.jnr:jnr-unixsocket:0.20                 (depends on 0.18)
[warn]  * io.vavr:vavr:0.9.1 is selected over 0.9.0
[warn]      +- io.github.swagger2markup:swagger2markup:1.3.3      (depends on 0.9.1)
[warn]      +- ch.netzwerg:paleo-core:0.11.0                      (depends on 0.9.0)
[warn]  * com.google.code.findbugs:jsr305:3.0.1 is selected over 2.0.1
[warn]      +- com.github.fge:btf:1.2                             (depends on 2.0.1)
[warn]      +- com.github.fge:uri-template:0.9                    (depends on 2.0.1)
[warn]      +- com.github.java-json-tools:json-schema-core:1.2.8  (depends on 2.0.1)
[warn]      +- com.github.fge:json-patch:1.6                      (depends on 2.0.1)
[warn]      +- com.github.fge:msg-simple:1.1                      (depends on 2.0.1)
[warn]      +- com.github.java-json-tools:json-schema-validator:2.2.8 (depends on 2.0.1)
[warn]      +- com.github.fge:jackson-coreutils:1.8               (depends on 2.0.1)
[warn]  * com.google.guava:guava:20.0 is selected over 16.0.1
[warn]      +- io.swagger:swagger-core:1.5.19                     (depends on 20.0)
[warn]      +- com.github.fge:uri-template:0.9                    (depends on 16.0.1)
[warn]      +- com.github.fge:jackson-coreutils:1.8               (depends on 16.0.1)
[info] Here are other dependency conflicts that were resolved:
[info]  * joda-time:joda-time:2.9.9 is selected over 2.9.7
[info]      +- org.jruby:jruby-core:9.2.7.0                       (depends on 2.9.9)
[info]      +- com.github.java-json-tools:json-schema-validator:2.2.8 (depends on 2.9.7)
[info]  * com.github.jnr:jnr-posix:3.0.49 is selected over 3.0.46
[info]      +- com.github.jnr:jnr-unixsocket:0.20                 (depends on 3.0.46)
[info]      +- org.jruby:jruby-core:9.2.7.0                       (depends on 3.0.46)
[info]  * commons-logging:commons-logging:1.2 is selected over 1.1.1
[info]      +- org.apache.commons:commons-configuration2:2.1      (depends on 1.2)
[info]      +- org.apache.httpcomponents:httpclient:4.5.2         (depends on 1.2)
[info]      +- commons-beanutils:commons-beanutils:1.9.2          (depends on 1.1.1)
[info]  * com.github.fge:jackson-coreutils:1.8 is selected over 1.6
[info]      +- com.github.java-json-tools:json-schema-core:1.2.8  (depends on 1.8)
[info]      +- com.github.fge:json-patch:1.6                      (depends on 1.6)
[info]  * com.fasterxml.jackson.core:jackson-databind:2.9.5 is selected over 2.2.3
[info]      +- io.swagger:swagger-core:1.5.19                     (depends on 2.9.5)
[info]      +- com.github.fge:jackson-coreutils:1.8               (depends on 2.2.3)
[info]  * com.fasterxml.jackson.core:jackson-annotations:2.9.5 is selected over 2.9.0
[info]      +- io.swagger:swagger-models:1.5.19                   (depends on 2.9.5)
[info]      +- io.swagger:swagger-core:1.5.19                     (depends on 2.9.5)
[info]      +- com.fasterxml.jackson.core:jackson-databind:2.9.5  (depends on 2.9.0)
[info]  * org.slf4j:slf4j-api:1.7.22 is selected over {1.7.18, 1.6.3}
[info]      +- io.swagger:swagger-models:1.5.19                   (depends on 1.7.18)
[info]      +- io.swagger:swagger-core:1.5.19                     (depends on 1.7.18)
[info]      +- io.github.swagger2markup:markup-document-builder:1.1.2 (depends on 1.7.18)
[info]      +- org.slf4j:slf4j-ext:1.6.3                          (depends on 1.7.18)
[info]      +- io.swagger:swagger-parser:1.0.35                   (depends on 1.7.18)
[info]  * commons-codec:commons-codec:1.10 is selected over 1.9
[info]      +- io.github.swagger2markup:markup-document-builder:1.1.2 (depends on 1.10)
[info]      +- org.apache.httpcomponents:httpclient:4.5.2         (depends on 1.9)
[info]  * org.apache.commons:commons-lang3:3.4 is selected over {3.3.2, 3.2.1}
[info]      +- io.github.swagger2markup:markup-document-builder:1.1.2 (depends on 3.4)
[info]      +- io.swagger:swagger-core:1.5.19                     (depends on 3.2.1)
[info]      +- org.apache.commons:commons-configuration2:2.1      (depends on 3.3.2)

Обычно строки с префиксом [WARN] являются наиболее проницательными. Наиболее вероятные кандидаты для создания ваших исключений -

com.google.code.findbugs:jsr305:3.0.1 is selected over 2.0.1
com.google.guava:guava:20.0 is selected over 16.0.1

из-за увеличения основной версии.

Решением было бы либо обновить зависимости в одном плагине, либо понизить их в другом.

...