- Notifications
You must be signed in to change notification settings - Fork950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
[2.x] compile straight-to-jar#7592
base:develop
Are you sure you want to change the base?
Conversation
45add08
to9d55dc2
Compare
EDIT: I updated to the latest compiler nightly to continue working |
d89091c
tocddba85
CompareIt seems we can't run scaladoc on the JAR directly,instead we need to unzip it and use the plain TASTy files
1e24a38
to2584e0b
Compare36a365c
toeefa7e3
Compare// TODO remove: create output jar if missing | ||
if !Files.exists(outputJar) then | ||
val zip = new ZipOutputStream(new FileOutputStream(outputJar.toFile)) | ||
zip.close() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This should be removed once we releasesbt/zinc#1368
// TODO remove and use IO.unzip as soon as Zinc can create regular Jar files | ||
object IO2 { | ||
def unzip(from: File, toDirectory: File): Set[File] = | ||
val dirPath = toDirectory.toPath | ||
val set = mutable.Set.empty[File] | ||
jarFileSystem(from) { root => | ||
Files | ||
.walk(root) | ||
.iterator | ||
.asScala | ||
.foreach { entry => | ||
val target = dirPath.resolve(root.relativize(entry).toString) | ||
if !Files.isDirectory(target) then Files.copy(entry, target) | ||
if Files.isRegularFile(target) then set += target.toFile | ||
} | ||
} | ||
set.toSet |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
We cannot use theIO.unzip
method because the JAR file produced by Zinc contains all old and new entries since the creation of the JAR.
Work is being done in Zinc to fix this.
@@ -6,7 +6,7 @@ object Dependencies { | |||
// WARNING: Please Scala update versions in PluginCross.scala too | |||
val scala212 = "2.12.19" | |||
val scala213 = "2.13.12" | |||
val scala3 = "3.3.1" | |||
val scala3 = "3.5.1-RC1-bin-20240628-1efbb92-NIGHTLY" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Using a nightly version because ofscala/scala3#20592, and we need the Zinc products to find the auto plugins.
Eventually we should use3.3.5
or3.5.1
.
# Marked pending until sbt/zinc#1376 is released | ||
$ copy-file changes/S1.scala S.scala | ||
> compile | ||
$ copy-file changes/S2.scala S.scala |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This scripted test is failing because ofsbt/zinc#1376
@eed3si9n this is definitelty not ready for merging but it is ready for a review if you have time. |
This PR enables compilation to JAR by default in sbt 2.x, so that we can directly cache the compiled JAR without the annoying zip/unzip loop.
Several versions of the Scala 3 compiler do not support straight-to-JAR compilation:
analysis.products
is empty which causes unnecessary invalidationI think it is a manageable situation because, by the time we release sbt 2.x, everyone should be using 3.3.5+ or 3.5+.