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

Add scalafmt option to binding generating tasks #264

Open
keynmol opened this issue Jan 15, 2024 · 0 comments
Open

Add scalafmt option to binding generating tasks #264

keynmol opened this issue Jan 15, 2024 · 0 comments

Comments

@keynmol
Copy link
Contributor

keynmol commented Jan 15, 2024

The general plan I have in my head:

  1. bindgenRunScalafmt - new Boolean setting, default to false
  2. All Scala-generating bindgen tasks check that option and if it's true, then run scalafmtOnly with the list of generated files

We don't need to depend on sbt-scalafmt, we can look up the task by name:

val task  = InputKey[Unit]("scalafmtOnly")

And then refer to it by (Compile / task).toTask(" <list of files, space-separated>").

Can use Def.sequential to do both tasks:

    Def.sequential(
      codeGeneratingTask,
      Def.taskDyn {
        // get list of generated files somehow
        (Compile / task).toTask(s" ${files.mkString(" ")}")
      }
    )

To get list of generated files, we can modify the existing tasks to return a list of files (unless they already do that).

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

1 participant