当我添加带有另一个 git 分支的文件夹作为项目的子文件夹时,为什么会有 sbt 异常?

Why is there a sbt exception there, when I have added the folder with another git branch as a subfolder of the project?

为了像另一个项目开发人员已经完成的那样设置项目,我这样做

  1. 克隆根项目 repo 和 switch/checkout 开发文件夹。它在相应的文件夹中包含一些名为 core 和 deps 的项目。
此根的

build.sbt 包含对某些 sbt 项目的提及:

lazy val industry = (project in file("industry"))

它没有指向根文件夹中的实际文件夹

  1. 创建 industry 文件夹,cd 到它,再次检出项目并 switch/checkout 到特定分支(例如,industry-dev

所以现在提到的项目文件夹有项目本身,它承载了自己的 build.sbt 和存在于相应文件夹中的其他人员。我们必须这样设置,因为 industry-dev 基于 dev 的 类,作为核心 类,我们需要同时观察它们, 不将单个项目从一个分支切换到另一个分支

  1. 在根目录下尝试执行

    sbt core/clean

我收到以下消息的错误:

[info] Loading settings for project spark-runner-build from plugins.sbt ...
[info] Loading project definition from D:\Java\sekai\spark-runner3\spark-runner\                                                                                                                                                                           project
[warn] There may be incompatibilities among your library dependencies; run 'evic                                                                                                                                                                           ted' to see detailed eviction warnings.
[info] Compiling 5 Scala sources to D:\Java\sekai\spark-runner3\spark-runner\pro                                                                                                                                                                           ject\target\scala-2.12\sbt-1.0\classes ...
[info] Done compiling.
D:\Java\sekai\spark-runner3\spark-runner\industry\build.sbt:53: error: missing ar                                                                                                                                                                           gument list for method environmentArtifactSettings in object Settings
Unapplied methods are only converted to functions when a function type is expect                                                                                                                                                                           ed.
You can make this conversion explicit by writing `environmentArtifactSettings _`                                                                                                                                                                            or `environmentArtifactSettings(_,_)` instead of `environmentArtifactSettings`.
    environmentArtifactSettings,
    ^
[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? l
[debug] > Exec(early(addDefaultCommands), None, None)
[debug] > Exec(addDefaultCommands, None, None)
[debug] > Exec(early(initialize), None, None)
[debug] > Exec(initialize, None, None)
[debug] > Exec(boot, None, None)
[debug] > Exec(writeSbtVersion, None, None)
[debug] > Exec(reload, None, None)
[debug] > Exec(sbtStashOnFailure, None, None)
[debug] > Exec(onFailure loadFailed, None, None)
[debug] > Exec(loadp, None, None)
[debug] Load.defaultLoad until apply took 240.9052ms
[debug]           Load.loadUnit: plugins took 62.3721ms
[debug]           Load.loadUnit: defsScala took 0.2643ms
[debug] [Loading] Scanning directory D:\Java\sekai\spark-runner3\spark-runner\pr                                                                                                                                                                           oject
[debug]             Load.loadUnit: mkEval took 6.0745ms
[debug] [Loading] Found non-root projects
[debug] [Loading] Done in D:\Java\sekai\spark-runner3\spark-runner\project, retu                                                                                                                                                                           rning: ()
[debug] deducing auto plugins based on known facts Set(Atom(sbt.plugins.CorePlug                                                                                                                                                                           in)) and clauses Clauses(List(Clause(Atom(sbt.plugins.JvmPlugin),Set(Atom(sbt.pl                                                                                                                                                                           ugins.IvyPlugin))), Clause(Atom(sbt.ScriptedPlugin),Set(Atom(sbt.plugins.JvmPlug                                                                                                                                                                           in))), Clause(Atom(sbt.plugins.SbtPlugin),Set(Atom(sbt.ScriptedPlugin))), Clause                                                                                                                                                                           (Atom(sbt.plugins.SemanticdbPlugin),Set(Atom(sbt.plugins.JvmPlugin))), Clause(At                                                                                                                                                                           om(sbt.plugins.JUnitXmlReportPlugin),Set(Atom(sbt.plugins.JvmPlugin))), Clause(A                                                                                                                                                                           tom(sbt.plugins.CorePlugin),Set(Atom(sbt.plugins.IvyPlugin))), Clause(Atom(sbt.p                                                                                                                                                                           lugins.IvyPlugin),Set(Atom(sbt.plugins.JvmPlugin))), Clause(Atom(sbt.plugins.Jvm                                                                                                                                                                           Plugin),Set(Atom(sbt.plugins.SemanticdbPlugin))), Clause(Atom(sbt.plugins.JvmPlu                                                                                                                                                                           gin),Set(Atom(sbt.plugins.JUnitXmlReportPlugin))), Clause(Atom(sbt.plugins.CoreP                                                                                                                                                                           lugin),Set(Atom(sbt.plugins.Giter8TemplatePlugin)))))
[debug]   :: deduced result: Matched(sbt.plugins.CorePlugin,sbt.plugins.Giter8Te                                                                                                                                                                           mplatePlugin,sbt.plugins.IvyPlugin,sbt.plugins.JvmPlugin,sbt.plugins.JUnitXmlRep                                                                                                                                                                           ortPlugin,sbt.plugins.SemanticdbPlugin)
[debug] Plugins.deducer#function took 12.2367 ms
[info] Loading settings for project spark-runner-build from plugins.sbt ...
[debug]               Load.resolveProject(spark-runner-build) took 186.0941ms
[debug]             Load.loadTransitive: finalizeProject2(Project(id spark-runne                                                                                                                                                                           r-build, base: D:\Java\sekai\spark-runner3\spark-runner\project, plugins: List(<                                                                                                                                                                           none>))) took 208.1284ms
[debug] [Loading] Done in D:\Java\sekai\spark-runner3\spark-runner\project, retu                                                                                                                                                                           rning: (spark-runner-build)
[debug]           Load.loadUnit: loadedProjectsRaw took 2876.5073ms
[debug]           Load.loadUnit: cleanEvalClasses took 6.6777ms
[debug]         Load.loadUnit(file:/D:/Java/sekai/spark-runner3/spark-runner/pro                                                                                                                                                                           ject/, ...) took 2950.8249ms
[debug]       Load.apply: load took 3424.9926ms
[debug]       Load.apply: resolveProjects took 4.7629ms
[debug]       Load.apply: finalTransforms took 35.1922ms
[debug]       Load.apply: config.delegates took 5.7578ms
[debug]       Load.apply: Def.make(settings)... took 321.9701ms
[debug]       Load.apply: structureIndex took 77.1997ms
[debug]       Load.apply: mkStreams took 2.3537ms
[info] Loading project definition from D:\Java\sekai\spark-runner3\spark-runner\                                                                                                                                                                           project
[debug] Running task... Cancel: Signal, check cycles: false, forcegc: true
[warn] There may be incompatibilities among your library dependencies; run 'evic                                                                                                                                                                           ted' to see detailed eviction warnings.
[info] Compiling 5 Scala sources to D:\Java\sekai\spark-runner3\spark-runner\pro                                                                                                                                                                           ject\target\scala-2.12\sbt-1.0\classes ...
[info] Done compiling.
[debug]     Load.loadUnit: plugins took 9147.8894ms
[debug]     Load.loadUnit: defsScala took 0.0045ms
[debug] [Loading] Scanning directory D:\Java\sekai\spark-runner3\spark-runner
[debug]       Load.loadUnit: mkEval took 0.2912ms
[debug] [Loading] Found non-root projects industry,industry_l,co                                                                                                                                                                           re,deps,standaloneBase,base
[debug] [Loading] Loading project industry @ D:\Java\sekai\spark-runner3\spark-ru                                                                                                                                                                           nner\industry
[debug] Type error in expression
[debug]         at sbt.compiler.Eval.checkError(Eval.scala:485)
[debug]         at sbt.compiler.Eval.compileAndLoad(Eval.scala:261)
[debug]         at sbt.compiler.Eval.evalCommon(Eval.scala:222)
[debug]         at sbt.compiler.Eval.evalDefinitions(Eval.scala:164)
[debug]         at sbt.internal.EvaluateConfigurations$.evaluateDefinitions(Eval                                                                                                                                                                           uateConfigurations.scala:325)
[debug]         at sbt.internal.EvaluateConfigurations$.evaluateSbtFile(Evaluate                                                                                                                                                                           Configurations.scala:151)
[debug]         at sbt.internal.Load$.loadSettingsFile(Load.scala:1128)
[debug]         at sbt.internal.Load$.$anonfun$discoverProjects(Load.scala:113                                                                                                                                                                           8)
[debug]         at scala.collection.MapLike.getOrElse(MapLike.scala:131)
[debug]         at scala.collection.MapLike.getOrElse$(MapLike.scala:129)
[debug]         at scala.collection.AbstractMap.getOrElse(Map.scala:63)
[debug]         at sbt.internal.Load$.memoLoadSettingsFile(Load.scala:1137)
[debug]         at sbt.internal.Load$.$anonfun$discoverProjects(Load.scala:114                                                                                                                                                                           5)
[debug]         at scala.collection.TraversableLike.$anonfun$map(TraversableLi                                                                                                                                                                           ke.scala:238)
[debug]         at scala.collection.immutable.List.foreach(List.scala:392)
[debug]         at scala.collection.TraversableLike.map(TraversableLike.scala:23                                                                                                                                                                           8)
[debug]         at scala.collection.TraversableLike.map$(TraversableLike.scala:2                                                                                                                                                                           31)
[debug]         at scala.collection.immutable.List.map(List.scala:298)
[debug]         at sbt.internal.Load$.loadFiles(Load.scala:1145)
[debug]         at sbt.internal.Load$.discoverProjects(Load.scala:1159)
[debug]         at sbt.internal.Load$.discover(Load.scala:855)
[debug]         at sbt.internal.Load$.discoverAndLoad(Load.scala:890)
[debug]         at sbt.internal.Load$.loadTransitive(Load.scala:908)
[debug]         at sbt.internal.Load$.loadTransitive(Load.scala:971)
[debug]         at sbt.internal.Load$.loadProjects(Load.scala:720)
[debug]         at sbt.internal.Load$.$anonfun$loadUnit(Load.scala:723)
[debug]         at sbt.internal.Load$.timed(Load.scala:1390)
[debug]         at sbt.internal.Load$.$anonfun$loadUnit(Load.scala:723)
[debug]         at sbt.internal.Load$.timed(Load.scala:1390)
[debug]         at sbt.internal.Load$.loadUnit(Load.scala:682)
[debug]         at sbt.internal.Load$.$anonfun$builtinLoader(Load.scala:480)
[debug]         at sbt.internal.BuildLoader$.$anonfun$componentLoader(BuildLoa                                                                                                                                                                           der.scala:180)
[debug]         at sbt.internal.BuildLoader.apply(BuildLoader.scala:245)
[debug]         at sbt.internal.Load$.loadURI(Load.scala:542)
[debug]         at sbt.internal.Load$.loadAll(Load.scala:558)
[debug]         at sbt.internal.Load$.loadURI(Load.scala:488)
[debug]         at sbt.internal.Load$.load(Load.scala:467)
[debug]         at sbt.internal.Load$.$anonfun$apply(Load.scala:243)
[debug]         at sbt.internal.Load$.timed(Load.scala:1390)
[debug]         at sbt.internal.Load$.apply(Load.scala:243)
[debug]         at sbt.internal.Load$.defaultLoad(Load.scala:55)
[debug]         at sbt.BuiltinCommands$.liftedTree1(Main.scala:839)
[debug]         at sbt.BuiltinCommands$.doLoadProject(Main.scala:839)
[debug]         at sbt.BuiltinCommands$.$anonfun$loadProjectImpl(Main.scala:80                                                                                                                                                                           1)
[debug]         at sbt.Command$.$anonfun$applyEffect(Command.scala:149)
[debug]         at sbt.Command$.$anonfun$applyEffect(Command.scala:144)
[debug]         at sbt.Command$.process(Command.scala:187)
[debug]         at sbt.MainLoop$.process(MainLoop.scala:185)
[debug]         at sbt.MainLoop$.processCommand(MainLoop.scala:220)
[debug]         at sbt.MainLoop$.$anonfun$next(MainLoop.scala:142)
[debug]         at sbt.State$StateOpsImpl$.runCmd(State.scala:273)
[debug]         at sbt.State$StateOpsImpl$.process$extension(State.scala:277)
[debug]         at sbt.MainLoop$.$anonfun$next(MainLoop.scala:142)
[debug]         at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.sc                                                                                                                                                                           ala:19)
[debug]         at sbt.MainLoop$.next(MainLoop.scala:142)
[debug]         at sbt.MainLoop$.run(MainLoop.scala:133)
[debug]         at sbt.MainLoop$.$anonfun$runWithNewLog(MainLoop.scala:111)
[debug]         at sbt.io.Using.apply(Using.scala:27)
[debug]         at sbt.MainLoop$.runWithNewLog(MainLoop.scala:105)
[debug]         at sbt.MainLoop$.runAndClearLast(MainLoop.scala:60)
[debug]         at sbt.MainLoop$.runLoggedLoop(MainLoop.scala:45)
[debug]         at sbt.MainLoop$.runLogged(MainLoop.scala:36)
[debug]         at sbt.StandardMain$.runManaged(Main.scala:132)
[debug]         at sbt.xMain$.run(Main.scala:67)
[debug]         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[debug]         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAcces                                                                                                                                                                           sorImpl.java:62)
[debug]         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMet                                                                                                                                                                           hodAccessorImpl.java:43)
[debug]         at java.lang.reflect.Method.invoke(Method.java:497)
[debug]         at sbt.internal.XMainConfiguration.run(XMainConfiguration.scala:                                                                                                                                                                           46)
[debug]         at sbt.xMain.run(Main.scala:39)
[debug]         at xsbt.boot.Launch$.$anonfun$run(Launch.scala:149)
[debug]         at xsbt.boot.Launch$.withContextLoader(Launch.scala:176)
[debug]         at xsbt.boot.Launch$.run(Launch.scala:149)
[debug]         at xsbt.boot.Launch$.$anonfun$apply(Launch.scala:44)
[debug]         at xsbt.boot.Launch$.launch(Launch.scala:159)
[debug]         at xsbt.boot.Launch$.apply(Launch.scala:44)
[debug]         at xsbt.boot.Launch$.apply(Launch.scala:21)
[debug]         at xsbt.boot.Boot$.runImpl(Boot.scala:78)
[debug]         at xsbt.boot.Boot$.run(Boot.scala:73)
[debug]         at xsbt.boot.Boot$.main(Boot.scala:21)
[debug]         at xsbt.boot.Boot.main(Boot.scala)
[error] sbt.compiler.EvalException: Type error in expression
[error] sbt.compiler.EvalException: Type error in expression
[error] Use 'last' for the full log.
[debug] > Exec(loadFailed, None, None)
[debug] > Exec(last, None, None)
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore? 

那里的核心问题是什么?


出现此异常的原因是分支的误用,每个分支都包含预期的 build.sbt。事实上,子文件夹分支与 roo 相同,因此子项目 build.sbt 实际上与根项目相同 build.sbt

因此,如果您遇到这种情况,请检查子项目的代码是否符合您的预期。