多项目构建 - 全局插件在构建中途重新编译并在 "Symbol 'type sbt.io.IOSyntax' is missing from the classpath" 上失败

Multi-project-build - global plugin is recompiled midway through build and failed on "Symbol 'type sbt.io.IOSyntax' is missing from the classpath"

sbt 版本:从 1.4.0 开始仍然在 1.4.2

之前正在处理 1.3.13

多项目构建,可在 https://github.com/raphaelNguyen/sample/new/master.

获得最低版本示例项目

在 sbt-sample 中启动 sbt 时,sbt 加载失败并出现错误

构建的简短描述:

我们的项目有一个包含所有组织设置的全局插件和一个包含我们某些项目特定设置的单独插件项目。具体设置项目依赖全局插件项目将全局autoplugin添加到具体autoplugin的要求中。

需要使用特定插件的项目随后会将特定插件项目作为项目依赖项拉入其构建项目(在 project/plugin.sbt 中),如下面的结构所示​​。

-+-- global-plugin - used as sample project when running sbt
 |
 +-- specific-plugin - dependsOn global-plugin
 |
 +-- sbt-sample - dependsOn sbt-sample-child and sbt-sample-other-child
 |     +-- sbt-sample-build - dependsOn specific-plugin
 |
 +-- sbt-sample-child
 |     +-- sbt-sample-child-build - dependsOn specific-plugin
 |
 +-- sbt-sample-other-child (not included in linked project above as unecessary to reproduce this error)
       +-- sbt-sample-other-child-build

有了上面的设置,当运行sbt在sbt-sample目录下用下面的命令:

SBT_OPTS="${SBT_OPTS} -Dsbt.global.plugins=Path\to\repo\sample\plugin-sample" sbt
  

结果如下输出

[info] welcome to sbt 1.4.2 (AdoptOpenJDK Java 11.0.8)
[info] loading global plugins from O:\Prj\github\sample\global-plugin\project
[info] loading settings for project global-plugins from build.sbt ...
[info] loading global plugins from O:\Prj\github\sample\global-plugin
[info] compiling 3 Scala sources to O:\Prj\github\sample\global-plugin\target\scala-2.12\sbt-1.0\classes ...
[info] loading settings for project sample-build from plugins.sbt ...
[info] loading project definition from O:\Prj\github\sample\specific-plugin\project
[info] loading settings for project play-plugins from build.sbt ...
[info] loading project definition from O:\Prj\github\sample\global-plugin\project
[info] loading settings for project global-plugin from build.sbt ...
[info] loading project definition from O:\Prj\github\sample\sbt-sample\project
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[warn] There may be incompatibilities among your library dependencies; run 'evicted' to see detailed eviction warnings.
[info] compiling 3 Scala sources to O:\Prj\github\sample\global-plugin\target\scala-2.12\sbt-1.0\classes ...
[info] loading settings for project sbt-sample from build.sbt ...
[info] loading settings for project sbt-sample-child-build from plugins.sbt ...
[info] loading project definition from O:\Prj\github\sample\specific-plugin\project
[info] loading settings for project play-plugins from build.sbt ...
[info] loading project definition from O:\Prj\github\sample\global-plugin\project
[info] loading settings for project global-plugin from build.sbt ...
[info] loading project definition from O:\Prj\github\sample\sbt-sample-child\project
[info] compiling 3 Scala sources to O:\Prj\github\sample\global-plugin\target\scala-2.12\sbt-1.0\classes ...
[error] O:\Prj\github\sample\global-plugin\src\main\scala\iad\sbt\Projects.scala:4:8: Symbol 'type sbt.io.IOSyntax' is missing from the classpath.
[error] This symbol is required by 'trait sbt.IOSyntax1'.
[error] Make sure that type IOSyntax is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
[error] A full rebuild may help if 'IOSyntax1.class' was compiled against an incompatible version of sbt.io.
[error] import sbt._
[error]        ^
[error] one error found
[error] (ProjectRef(uri("file:///O:/Prj/github/sample/global-plugin/"), "global-plugin") / Compile / compileIncremental) Compilation failed
[warn] Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? (default: r)

有谁知道什么可能导致全局插件重新编译并在重新编译过程中失败,即使它第一次完成得很好?

sbt 1.4.3(最新)可能已经解决了您的问题。