-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix declaring product of straight-to-jar compilation (#20592)
Currently the straight-to-JAR compilation does not declare any class file to Zinc, which prevents Zinc from compiling downstream modules incrementally. For the context, we would like to enable straight-to-JAR compilation in sbt 2.x, and put remote caching on top of it.
- Loading branch information
Showing
6 changed files
with
114 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package xsbt | ||
|
||
import org.junit.Assert.* | ||
import org.junit.Ignore | ||
import org.junit.Test | ||
|
||
import java.io.File | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
class ProductsSpecification { | ||
|
||
@Test | ||
def extractProductsFromJar = { | ||
val src = | ||
"""package example | ||
| | ||
|class A { | ||
| class B | ||
| def foo = | ||
| class C | ||
|}""".stripMargin | ||
val output = compiler.compileSrcsToJar(src) | ||
val srcFile = output.srcFiles.head | ||
val products = output.analysis.productClassesToSources.filter(_._2 == srcFile).keys.toSet | ||
|
||
def toPathInJar(className: String): Path = | ||
Paths.get(s"${output.classesOutput}!${className.replace('.', File.separatorChar)}.class") | ||
val expected = Set("example.A", "example.A$B", "example.A$C$1").map(toPathInJar) | ||
assertEquals(products, expected) | ||
} | ||
|
||
private def compiler = new ScalaCompilerForUnitTesting | ||
} |
Oops, something went wrong.