Skip to content

Defer output JAR creation until the first entry is written - #27662

Open
anatoliykmetyuk wants to merge 3 commits into
scala:mainfrom
anatoliykmetyuk:br/i27587-defer-output-jar
Open

anatoliykmetyuk wants to merge 3 commits into
scala:mainfrom
anatoliykmetyuk:br/i27587-defer-output-jar

Conversation

@anatoliykmetyuk

Copy link
Copy Markdown
Contributor

Fixes #27587

Related to sbt/sbt#10063

Problem: options such as -d or -Ypickle-write create the destination jars immediately after being processed by the compiler at the beginning of the compilation pipeline. In the scenario of e.g. presentation compiler, the writes to the destination may never happen, yet, the destination will be recreated as an empty jar. Systems that rely on this jar may therefore end up with an empty jar and error.

Solution: defer creation of mentioned jars to the time when the first write actually happens. Introduce the respective internal API, JarDestination and Output types to model such lazy jar destinations.

Have you relied on LLM-based tools in this contribution?

Yes, and I checked the output by manual review and testing against mentioned issue reproductions.

How was the solution tested?

New automated regression test: SettingsTests.outputJarsAreWrittenOnFirstEntry covers both flags, including parser-only runs, interactive compiler startup, and replacement of stale entries on a subsequent compile.

@anatoliykmetyuk
anatoliykmetyuk marked this pull request as ready for review November 27, 2026 06:56
@SolalPirelli

Copy link
Copy Markdown
Contributor

How urgent is this? I wanted to address it as part of #26512, but happy to merge this in the meantime if it's blocking someone -- that PR has been delayed for a while because removing our scala2 dependency from the stdlib is taking me longer than I wanted.

@anatoliykmetyuk

Copy link
Copy Markdown
Contributor Author

It's not blocking anyone as far as I know, I've also submitted a fix on the sbt side that will resolve it as well for the original reporter. So feel free to defer it to that integrated PR if you think it's better!

@SolalPirelli

Copy link
Copy Markdown
Contributor

OK, I'll leave this open so I can use the tests and try to get to it next week. Sorry for not planning this better.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option parsing empties the jar given to -Ypickle-write or -d, even in runs that write nothing (e.g. -Ystop-after:parser, InteractiveDriver)

2 participants