6

由于修改了二进制依赖关系,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 已更改?

4

1 回答 1

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
于 2012-10-22T10:55:02.990 回答