Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete products of previous analysis when dropping previous analysis #1293

Merged
merged 2 commits into from
Dec 2, 2023

Conversation

Friendseeker
Copy link
Member

@Friendseeker Friendseeker commented Nov 30, 2023

This PR fixes #1234, sbt/sbt#2074, #825

Issue

prevAnalysis in IncrementalCompilerImpl.scala drops previous analysis when setup is changed.

However, it kept all products of previous analysis, hence these stale products never gets removed.

Fix

When the previous analysis is dropped, delete all products of previous analysis.

Validating the fix

Followed https://github.com/jackkoenig/zinc-bug-example with custom zinc build containing the fix.

❯ git status 
On branch main
Your branch is ahead of 'origin/main' by 1 commit.
  (use "git push" to publish your local commits)

Untracked files:
  (use "git add <file>..." to include in what will be committed)
	.java-version

nothing added to commit but untracked files present (use "git add" to track)

~/zinc-bug-example-2/zinc-bug-example main* ⇡
❯ jenv local 19.0

~/zinc-bug-example-2/zinc-bug-example main* ⇡
❯ sbt compile
[info] welcome to sbt 1.9.7 (Oracle Corporation Java 19.0.1)
[info] loading global plugins from /Users/jiahuitan/.sbt/1.0/plugins
[info] loading project definition from /Users/jiahuitan/zinc-bug-example-2/zinc-bug-example/project
[info] loading settings for project root from build.sbt ...
[info] set current project to zinc-bug-example (in build file:/Users/jiahuitan/zinc-bug-example-2/zinc-bug-example/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] compiling 4 Scala sources to /Users/jiahuitan/zinc-bug-example-2/zinc-bug-example/target/scala-2.13/classes ...
[success] Total time: 2 s, completed Nov 30, 2023, 4:24:54 p.m.

~/zinc-bug-example-2/zinc-bug-example main* ⇡
❯ jenv local 21.0

~/zinc-bug-example-2/zinc-bug-example main* ⇡
❯ git apply moveB.diff

~/zinc-bug-example-2/zinc-bug-example main* ⇡
❯ sbt compile
[info] welcome to sbt 1.9.7 (Oracle Corporation Java 21.0.1)
[info] loading global plugins from /Users/jiahuitan/.sbt/1.0/plugins
[info] loading project definition from /Users/jiahuitan/zinc-bug-example-2/zinc-bug-example/project
[info] loading settings for project root from build.sbt ...
[info] set current project to zinc-bug-example (in build file:/Users/jiahuitan/zinc-bug-example-2/zinc-bug-example/)
[info] Executing in batch mode. For better performance use sbt's shell
[info] compiling 4 Scala sources to /Users/jiahuitan/zinc-bug-example-2/zinc-bug-example/target/scala-2.13/classes ...
[success] Total time: 2 s, completed Nov 30, 2023, 4:25:28 p.m.

Credit to

  • @jackkoenig for providing reproduction & pinpointing exact cause of the problem
  • @armanbilge for guiding me to setup custom zinc build

Copy link
Member

@eed3si9n eed3si9n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@eed3si9n eed3si9n merged commit 99484c3 into sbt:develop Dec 2, 2023
7 checks passed
@Friendseeker Friendseeker deleted the stale-class-file branch December 2, 2023 17:41
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.

Zinc fails to delete stale .class files resulting in broken incremental compilation
2 participants