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

(sbt) Files not removed on subsequent codegen run #1527

Open
kubukoz opened this issue May 16, 2024 · 5 comments
Open

(sbt) Files not removed on subsequent codegen run #1527

kubukoz opened this issue May 16, 2024 · 5 comments

Comments

@kubukoz
Copy link
Member

kubukoz commented May 16, 2024

To reproduce:

  1. Generate code for any shape
  2. Rename the shape
  3. Generate code again
  4. Look at the output

Example:

Screen.Recording.2024-05-16.at.23.42.18.mov

Happens in 0.18.18.

@kubukoz
Copy link
Member Author

kubukoz commented May 16, 2024

I'm thinking to delete previously generated files in sbt only, because:

  • CLI: people are very likely to use . as the target which could very easily turn into an annoying experience
  • Mill: we generate to a task-specific path that gets cleared on invalidation, so this shouldn't be happening in the first place

@Baccata
Copy link
Contributor

Baccata commented May 17, 2024

I'm not too sure what kind of impact deleting would have, which is why I elected not to do it in the first place. In the grand scheme of things it shouldn't matter too much, because SBT expects the sourceGenerator task to return the list of all files that were generated :

config / sourceGenerators += (config / smithy4sCodegen).map(
_.filter(_.ext == "scala")
),

So maybe this impacts the editor, but I'm not sure it's actually a good idea to clean up before regeneration.

@kubukoz
Copy link
Member Author

kubukoz commented May 17, 2024

I think it does have impact, because your app code may still have references to the old files, and it'll compile locally but e.g. won't compile anymore when you push changes and CI runs on them.

If we can access the list of previously generated files, removing them is IMO the right thing to do, but I suppose we should see what other codegens do, like scalapb.

@Baccata
Copy link
Contributor

Baccata commented May 17, 2024

and it'll compile locally

What I'm saying is that it won't compile locally, at least I don't think it will compile in SBT.

@kubukoz
Copy link
Member Author

kubukoz commented May 17, 2024

oh I see what you mean - the files not on the list shouldn't be included in the compilation, so only the IDE will see them, at least (I guess) until you re-import your project.

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

No branches or pull requests

2 participants