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

module.mill will only be found, when same extension as build.mill #3832

Open
lefou opened this issue Oct 24, 2024 · 8 comments
Open

module.mill will only be found, when same extension as build.mill #3832

lefou opened this issue Oct 24, 2024 · 8 comments

Comments

@lefou
Copy link
Member

lefou commented Oct 24, 2024

Mill now provides support for alternative file extensions: .mill, .mill.scala and .sc. But a <dir>/module.mill is only found, when the main build file has the name build.mill. If it is named build.sc, the sub-module is only found when it is also has the .sc extension, namely module.sc. This is irritating and doesn't seem intentional.

If this should be intentional, we should document it and print a warning for each file Mill is going to ignore.

@lefou
Copy link
Member Author

lefou commented Oct 25, 2024

Looks like we currently only support the consistent use of a same file extensions for all build.<ext> and package.<ext> files.

val buildFileExtension =
buildFileExtensions.find(ex => foundRootBuildFileName.endsWith(s".$ex")).get
val nestedBuildFileName = s"package.$buildFileExtension"

That means, if the top build file is build.mill.scala, all sub-modules need to use the package.mill.scala file name.

Although I like that this results in projects with consistent build file names, I find it quite limiting in projects in transition. Whatever the reason is to choose one extension over the other, there might be different reasonings fordifferent sub-modules and allowing non-consistent names would be better.

I think we should either warn if we ignored directories which contain a supported file but with different extension or don't enforce a consistent file extension at all but only warn if we find more than one supported file in one directory.

What do others think?

@lihaoyi
Copy link
Member

lihaoyi commented Oct 26, 2024

Currently the different extensions have somewhat different semantics, e.g. w.r.t. how import $file and stuff work. So I think it might be confusing to mix them. Better to raise an error or warning

@lefou
Copy link
Member Author

lefou commented Oct 26, 2024

Currently the different extensions have somewhat different semantics, e.g. w.r.t. how import $file and stuff work. So I think it might be confusing to mix them. Better to raise an error or warning

Can you elaborate a bit. I think the only extension we handle specially is .sc for backward compatibility. But .mill and .mill.scala should be interchangeable, which they currently aren't.

@lihaoyi
Copy link
Member

lihaoyi commented Nov 1, 2024

Can you elaborate a bit. I think the only extension we handle specially is .sc for backward compatibility. But .mill and .mill.scala should be interchangeable, which they currently aren't.

That is correct, but I would expect people who care about transitioning projects would indeed be the ones who have some build.sc and the rest either all build.mill or all build.mill.scala, which is the case where there is a semantic difference so we (and the user) may need to be careful.

I can't think of a use case where someone would want to have a mix of build.mill and build.scala, which is the case where there is no semantic difference and we can freely grab whatever build file exists.

@lefou
Copy link
Member Author

lefou commented Nov 1, 2024

@lihaoyi Can you list the semantic differences?

@lihaoyi
Copy link
Member

lihaoyi commented Nov 1, 2024

@lefou IIRC the main one is that .sc files (best-effort) follow the old discovery semantics, where file must be imported with import $file before being used. .mill files instead do the recursive discovery of package.mill files and find any .mill files adjacent to them.

The .sc semantics were left (mostly) in place in an attempt to ease the migration, so projects could update to 0.12.0 without having to mangle their build file layout at the same time

@lefou
Copy link
Member Author

lefou commented Nov 1, 2024

Thanks. I think we should make that info about different import-handling available to our user as well.

I can't think of a use case where someone would want to have a mix of build.mill and build.scala, which is the case where there is no semantic difference and we can freely grab whatever build file exists.

I can. Imagine a larger project where not all challenges are solely technical but also social.

@lihaoyi
Copy link
Member

lihaoyi commented Nov 1, 2024

I'd be ok with allowing mixed .mill/.mill.scala files in the same repo

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