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

Ignore empty module.sc files when generating code #3427

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion runner/src/mill/runner/FileImportGraph.scala
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ object FileImportGraph {
p == projectRoot / millBuild ||
(os.isDir(p) && !os.exists(p / "module.sc"))
)
.filter(_.last == "module.sc")
.filter(p => p.last == "module.sc" && os.read(p).nonEmpty)
Copy link
Member

Choose a reason for hiding this comment

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

What about spaces and comments?

I think it's reasonable to allow build maintainers to document the purpose of a file:

// file: module.sc
// marker for mill to search for sub-modules in this directory

or even leave some commented out stuff in it

// todo: finishe migration
// import mill._, scalalib._
// object foo extends ScalaModule 

Copy link
Member Author

Choose a reason for hiding this comment

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

good point. For that to work robustly, we would likely need to filter it out after the parser. We could probably make our existing compiler plugins perform that filtering

Copy link
Member

Choose a reason for hiding this comment

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

Sometimes perfect is the enemy of a working solution. Let's ignore comments on a best effort basis and improve later.

Suggested change
.filter(p => p.last == "module.sc" && os.read(p).nonEmpty)
.filter(p => p.last == "module.sc" &&
!os.read.lines(p).map(_.trim())
.forall(l => l.isEmpty || l.startsWith("//"))

Copy link
Member

Choose a reason for hiding this comment

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

@lihaoyi WDYT?

Copy link
Member Author

Choose a reason for hiding this comment

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

@lefou let's hold off on this a bit, I suspect #3426 will change how this needs to be done


buildFiles.foreach(walkScripts(_))

Expand Down
Loading