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

Task.Sources() does not compile #4612

Open
informarte opened this issue Feb 23, 2025 · 1 comment
Open

Task.Sources() does not compile #4612

informarte opened this issue Feb 23, 2025 · 1 comment

Comments

@informarte
Copy link

I have a Scala 3 project with a resources folder that I don't want to be included into the jar. With the old T syntax, it was easy:

override def resources = T.sources()

As the release notes for 0.12.0 recommend to migrate to the new Task syntax, I changed the above line to:

override def resources = Task.Sources()

which does not compile due to the vararg overloads:

[build.mill-61] [error] /home/informarte/Workspaces/yuck/build.mill:30:35: ambiguous reference to overloaded definition,
[build.mill-61] [error] both macro method Sources in object Task of type (values: os.SubPath*)(implicit ctx: mill.define.Ctx): mill.define.Target[Seq[mill.api.PathRef]]
[build.mill-61] [error] and  macro method Sources in object Task of type (values: mill.api.Result[os.Path]*)(implicit ctx: mill.define.Ctx): mill.define.Target[Seq[mill.api.PathRef]]
[build.mill-61] [error] match argument types () and expected result type mill.T[Seq[mill.api.PathRef]]
[build.mill-61] [error]     override def resources = Task.Sources()
[build.mill-61] [error]                                   ^
[build.mill-61] [error] one error found

I tried to work-around this issue by using an empty list:

override def resources = Task.Sources(List[os.SubPath](): _*)

which does not compiler either:

[build.mill-61] [error] /home/informarte/Workspaces/yuck/build.mill:30:61: Sequence argument type annotation `: _*` cannot be used here:
[build.mill-61] [error] the single parameter has type os.SubPath which is not a repeated parameter type
[build.mill-61] [error]     override def resources = Task.Sources(List[os.SubPath](): _*)
[build.mill-61] [error]                                                             ^
[build.mill-61] [error] one error found

This error message does not make any sense to me.

I wonder how to proceed.
Is there a way to use one of the existing Sources overloads with an empty list?
Renaming the resources folder is of course an option but what about adding a Sources() method without arguments?

@lolgab
Copy link
Member

lolgab commented Feb 23, 2025

Now Sources doesn't have anymore a different type than Task. So you can work around the issue by having a Task that returns an empty sequence:

def resources = Task { Seq.empty[PathRef] }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants