gpt4 book ai didi

scala - sbt 总是对虚假的源代码更改进行完全重建

转载 作者:行者123 更新时间:2023-12-01 06:31:33 27 4
gpt4 key购买 nike

我唯一的猜测是我的构建配置有问题,但每次编译时都会重新编译所有内容。深入挖掘“最后一次编译”总是告诉我

> compile
[info] Compiling 28 Scala sources and 78 Java sources to /home/me/foo/target/scala-2.10/classes...
[warn] Note: Some input files use unchecked or unsafe operations.
[warn] Note: Recompile with -Xlint:unchecked for details.
[success] Total time: 34 s, completed Nov 8, 2013 12:35:18 PM
> last compile
[debug]
[debug] Initial source changes:
[debug] removed:Set(/home/me/foo/scala/Bar.scala, ...)
[debug] added: Set(scala/Bar.scala, ...)
[debug] modified: Set()
...
[debug] Recompiling all 106 sources: invalidated sources (56) exceeded 50.0% of all sources
...

对于我的每个 Scala 源文件,它们在包含完全限定路径的删除集中,在添加集中,它们具有我在配置中使用的相对路径。我有一个混合的 Scala 和 Java 项目,所以这可能是一个问题吗?尽管“最后一次编译”从未提及 Java 文件。

我的配置看起来像:
import sbt._
import Keys._

object MyBuild extends Build {
val buildSettings = Defaults.defaultSettings ++ Seq(
scalaVersion := "2.10.2"
)
val jettyVersion = "7.6.7.v20120910"

val webHome = System.getenv("WEB_HOME")

val webJars =
Seq("servlet-api-2.5.jar",
"annotations.jar",
"jetty-server-" + jettyVersion + ".jar",
"jetty-client-" + jettyVersion + ".jar",
"jetty-http-" + jettyVersion + ".jar",
"jetty-http-" + jettyVersion + ".jar")
.map(webHome + "/lib/java/" + _)
val classes = Seq("build/jars/Foo.classes")

val jarPath = (webJars ++ classes).map(file).classpath

val sourcePaths =
inConfig(Compile)(Defaults.configSettings) ++
Seq(
unmanagedSourceDirectories in Compile += file("scala"),
unmanagedSourceDirectories in Compile += file("build/java"),
unmanagedSourceDirectories in Compile += file("java"),
unmanagedJars in Compile ++= jarPath)

val root = Project("root", file("."), settings = (buildSettings ++ sourcePaths))
}

有什么明显的我在这里搞砸了吗?

最佳答案

我将以下行放在 build.sbt 的末尾:

scalaSource in Compile := baseDirectory.value / "src"

解决了我的问题,由于 IDE 兼容性,我的源代码直接位于 src 下没有 main也不是 scala文件夹。

关于scala - sbt 总是对虚假的源代码更改进行完全重建,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19865412/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com