Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sbt always does full rebuild because of modified binary dependency rt.jar

Tags:

scala

sbt

Sbt always does full rebuild because of modified binary dependency: 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()

Obviously, rt.jar wasn't changed, its created/accesses/modified dates are the same and quite old.

It's in c:\Program Files\Java\jdk1.6.0_37\jre\lib\

JAVA_HOME is set as C:\Progra~1\Java\jdk1.6.0_37

JAVA_HOME/bin is in PATH.

Any ideas why sbt thinks rt.jar was changed?

like image 940
nau Avatar asked Oct 19 '12 10:10

nau


1 Answers

I had JAVA_HOME set to C:\Progra~1\Java\jdk1.6.0_37 and sbt resolved the dependency as C:\Program Files\Java\jdk1.6.0_37\jre\lib\rt.jar. Sbt uses java.io.File.equals() which is not correct in this case:

In 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))
            }
        )

gives the following output:

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

Thus, sbt always thinks rt.jar was changed.

Workaround would be setting JAVA_HOME to "c:\Program Files\Java\jdk1.6.0_37" Solution would be to do:

resolved.getCanonicalPath != dependsOn.getCanonicalPath
like image 129
nau Avatar answered Nov 08 '22 20:11

nau