使用具有代码覆盖率的 Scala SBT 时出现兼容性错误
Compatibility Error When Using Scala SBT with Code Coverage
我在 Scala 中有一个项目,我正在尝试将版本从 Scala 2.12.3 升级到 2.12.13,但是在我的 CI 管道中该过程失败,堆栈跟踪如下:
[error] java.lang.NoSuchMethodError: scala.tools.nsc.Global.reporter()Lscala/tools/nsc/reporters/Reporter;
[error] at scoverage.ScoverageInstrumentationComponent$$anon.run(plugin.scala:119)
[error] at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1511)
[error] at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1495)
[error] at scala.tools.nsc.Global$Run.compileSources(Global.scala:1488)
[error] at scala.tools.nsc.Global$Run.compileFiles(Global.scala:1599)
[error] at xsbt.CachedCompiler0.run(CompilerBridge.scala:163)
[error] at xsbt.CachedCompiler0.run(CompilerBridge.scala:134)
[error] at xsbt.CompilerBridge.run(CompilerBridge.scala:39)
[error] at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:92)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile(MixedAnalyzingCompiler.scala:186)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile(MixedAnalyzingCompiler.scala:176)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$adapted(MixedAnalyzingCompiler.scala:157)
[error] at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.compileScala(MixedAnalyzingCompiler.scala:157)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$adapted(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.Incremental$.$anonfun$apply(Incremental.scala:174)
[error] at sbt.internal.inc.Incremental$.$anonfun$apply$adapted(Incremental.scala:172)
[error] at sbt.internal.inc.Incremental$$anon.run(Incremental.scala:459)
[error] at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] at sbt.internal.inc.IncrementalCommon$$anon.next(IncrementalCommon.scala:56)
[error] at sbt.internal.inc.IncrementalCommon$$anon.next(IncrementalCommon.scala:52)
[error] at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:261)
[error] at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile(Incremental.scala:414)
[error] at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:499)
[error] at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:401)
[error] at sbt.internal.inc.Incremental$.apply(Incremental.scala:166)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally(IncrementalCompilerImpl.scala:491)
[error] at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2177)
[error] at sbt.Defaults$.$anonfun$compileIncrementalTask(Defaults.scala:2134)
[error] at sbt.internal.io.Retry$.apply(Retry.scala:40)
[error] at sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] at sbt.Defaults$.$anonfun$compileIncrementalTask(Defaults.scala:2130)
[error] at scala.Function1.$anonfun$compose(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon.work(Transform.scala:68)
[error] at sbt.Execute.$anonfun$submit(Execute.scala:282)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] at sbt.Execute.work(Execute.scala:291)
[error] at sbt.Execute.$anonfun$submit(Execute.scala:282)
[error] at sbt.ConcurrentRestrictions$$anon.$anonfun$submitValid(ConcurrentRestrictions.scala:265)
[error] at sbt.CompletionService$$anon.call(CompletionService.scala:64)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (Compile / compileIncremental) java.lang.NoSuchMethodError: scala.tools.nsc.Global.reporter()Lscala/tools/nsc/reporters/Reporter;
[error] Total time: 15 s, completed Feb 27, 2021 6:48:04 AM
restoring stty: 500:5:bf:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
The command "sbt clean coverage test coverageReport" exited with 1.
这纯粹是一个兼容性错误,sbt 覆盖率是罪魁祸首。知道如何解决这个问题吗?
issue is that Scala compiler plugins should be fully cross-versioned
we do normally recommend that compiler plugins be published against
the full Scala version.
there's no binary compatibility guarantees between two patch releases
of scala-compiler.
这意味着甚至补丁版本对于发布工件也很重要
a.b.c
^
例如,比较wartremover
编译器插件如何包含补丁版本
wartremover_2.13.3/
wartremover_2.13.4/
wartremover_2.13.5/
scalac-scoverage-plugin_2.13/
Build CrossVersion.full #306 已为 scalac-scoverage-plugin
解决此问题,但尚未发布。
我在 Scala 中有一个项目,我正在尝试将版本从 Scala 2.12.3 升级到 2.12.13,但是在我的 CI 管道中该过程失败,堆栈跟踪如下:
[error] java.lang.NoSuchMethodError: scala.tools.nsc.Global.reporter()Lscala/tools/nsc/reporters/Reporter;
[error] at scoverage.ScoverageInstrumentationComponent$$anon.run(plugin.scala:119)
[error] at scala.tools.nsc.Global$Run.compileUnitsInternal(Global.scala:1511)
[error] at scala.tools.nsc.Global$Run.compileUnits(Global.scala:1495)
[error] at scala.tools.nsc.Global$Run.compileSources(Global.scala:1488)
[error] at scala.tools.nsc.Global$Run.compileFiles(Global.scala:1599)
[error] at xsbt.CachedCompiler0.run(CompilerBridge.scala:163)
[error] at xsbt.CachedCompiler0.run(CompilerBridge.scala:134)
[error] at xsbt.CompilerBridge.run(CompilerBridge.scala:39)
[error] at sbt.internal.inc.AnalyzingCompiler.compile(AnalyzingCompiler.scala:92)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile(MixedAnalyzingCompiler.scala:186)
[error] at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.timed(MixedAnalyzingCompiler.scala:241)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile(MixedAnalyzingCompiler.scala:176)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.$anonfun$compile$adapted(MixedAnalyzingCompiler.scala:157)
[error] at sbt.internal.inc.JarUtils$.withPreviousJar(JarUtils.scala:239)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.compileScala(MixedAnalyzingCompiler.scala:157)
[error] at sbt.internal.inc.MixedAnalyzingCompiler.compile(MixedAnalyzingCompiler.scala:204)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileInternal$adapted(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.Incremental$.$anonfun$apply(Incremental.scala:174)
[error] at sbt.internal.inc.Incremental$.$anonfun$apply$adapted(Incremental.scala:172)
[error] at sbt.internal.inc.Incremental$$anon.run(Incremental.scala:459)
[error] at sbt.internal.inc.IncrementalCommon$CycleState.next(IncrementalCommon.scala:116)
[error] at sbt.internal.inc.IncrementalCommon$$anon.next(IncrementalCommon.scala:56)
[error] at sbt.internal.inc.IncrementalCommon$$anon.next(IncrementalCommon.scala:52)
[error] at sbt.internal.inc.IncrementalCommon.cycle(IncrementalCommon.scala:261)
[error] at sbt.internal.inc.Incremental$.$anonfun$incrementalCompile(Incremental.scala:414)
[error] at sbt.internal.inc.Incremental$.withClassfileManager(Incremental.scala:499)
[error] at sbt.internal.inc.Incremental$.incrementalCompile(Incremental.scala:401)
[error] at sbt.internal.inc.Incremental$.apply(Incremental.scala:166)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compileInternal(IncrementalCompilerImpl.scala:573)
[error] at sbt.internal.inc.IncrementalCompilerImpl.$anonfun$compileIncrementally(IncrementalCompilerImpl.scala:491)
[error] at sbt.internal.inc.IncrementalCompilerImpl.handleCompilationError(IncrementalCompilerImpl.scala:332)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compileIncrementally(IncrementalCompilerImpl.scala:420)
[error] at sbt.internal.inc.IncrementalCompilerImpl.compile(IncrementalCompilerImpl.scala:137)
[error] at sbt.Defaults$.compileIncrementalTaskImpl(Defaults.scala:2177)
[error] at sbt.Defaults$.$anonfun$compileIncrementalTask(Defaults.scala:2134)
[error] at sbt.internal.io.Retry$.apply(Retry.scala:40)
[error] at sbt.internal.io.Retry$.apply(Retry.scala:23)
[error] at sbt.internal.server.BspCompileTask$.compute(BspCompileTask.scala:31)
[error] at sbt.Defaults$.$anonfun$compileIncrementalTask(Defaults.scala:2130)
[error] at scala.Function1.$anonfun$compose(Function1.scala:49)
[error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219(TypeFunctions.scala:62)
[error] at sbt.std.Transform$$anon.work(Transform.scala:68)
[error] at sbt.Execute.$anonfun$submit(Execute.scala:282)
[error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:23)
[error] at sbt.Execute.work(Execute.scala:291)
[error] at sbt.Execute.$anonfun$submit(Execute.scala:282)
[error] at sbt.ConcurrentRestrictions$$anon.$anonfun$submitValid(ConcurrentRestrictions.scala:265)
[error] at sbt.CompletionService$$anon.call(CompletionService.scala:64)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[error] at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
[error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
[error] at java.lang.Thread.run(Thread.java:748)
[error] (Compile / compileIncremental) java.lang.NoSuchMethodError: scala.tools.nsc.Global.reporter()Lscala/tools/nsc/reporters/Reporter;
[error] Total time: 15 s, completed Feb 27, 2021 6:48:04 AM
restoring stty: 500:5:bf:8a3b:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
The command "sbt clean coverage test coverageReport" exited with 1.
这纯粹是一个兼容性错误,sbt 覆盖率是罪魁祸首。知道如何解决这个问题吗?
issue is that Scala compiler plugins should be fully cross-versioned
we do normally recommend that compiler plugins be published against the full Scala version.
there's no binary compatibility guarantees between two patch releases of scala-compiler.
这意味着甚至补丁版本对于发布工件也很重要
a.b.c
^
例如,比较wartremover
编译器插件如何包含补丁版本
wartremover_2.13.3/
wartremover_2.13.4/
wartremover_2.13.5/
scalac-scoverage-plugin_2.13/
Build CrossVersion.full #306 已为 scalac-scoverage-plugin
解决此问题,但尚未发布。