由于修改后的二进制依赖性,Sbt总是进行完全重建:rt.jar:
[debug]
[debug] Initial source changes:
[debug] removed:Set()
[debug] added: Set()
[debug] modified: Set()
[debug] Removed products: Set()
[debug] Modified external sources: Set()
[debug] Modified binary dependencies: Set(C:\Program Files\Java\jdk1.6.0_37\jre\lib\rt.jar)
[debug] Initial directly invalidated sources: Set()
显然,rt.jar没有改变,它的创建/访问/修改日期是相同的,而且很旧。
位于c:\ Program Files \ Java \ jdk1.6.0_37 \ jre \ lib \
JAVA_HOME设置为C:\ Progra~1 \ Java \ jdk1.6.0_37
JAVA_HOME / bin在PATH中。
为什么sbt认为rt.jar被改变了?
答案 0 :(得分:3)
我将JAVA_HOME设置为C:\ Progra~1 \ Java \ jdk1.6.0_37并且sbt将依赖关系解析为C:\ Program Files \ Java \ jdk1.6.0_37 \ jre \ lib \ rt.jar。 Sbt使用的java.io.File.equals()在这种情况下是不正确的:
在sbt / compile / inc / Incremental.scala中:
def externalBinaryModified(entry: String => Option[File], analysis: File => Option[Analysis], previous: Stamps, current: ReadStamps)(implicit equivS: Equiv[Stamp]): File => Boolean =
dependsOn =>
analysis(dependsOn).isEmpty &&
orTrue(
for {
name <- previous.className(dependsOn)
_ = println("Name: " + name)
e <- entry(name)
_ = println("entry: " + e)
} yield {
val resolved = Locate.resolve(e, name)
println("resolved: " + resolved)
println("dependsOn: " + dependsOn)
println("resolved != dependsOn: " + (resolved != dependsOn))
(resolved != dependsOn) || !equivS.equiv(previous.binary(dependsOn), current.binary(resolved))
}
)
给出以下输出:
Name: java.lang.Object
entry: c:\Progra~1\Java\jdk1.6.0_37\jre\lib\rt.jar
resolved: c:\Progra~1\Java\jdk1.6.0_37\jre\lib\rt.jar
dependsOn: c:\Program Files\Java\jdk1.6.0_37\jre\lib\rt.jar
resolved != dependsOn: true
因此,sbt总是认为rt.jar已经改变了。
解决方法是将JAVA_HOME设置为“c:\ Program Files \ Java \ jdk1.6.0_37” 解决方案是:
resolved.getCanonicalPath != dependsOn.getCanonicalPath