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 0.13] Support sourceGenerators += Def.task { ... } #2943

Merged
merged 1 commit into from
Feb 7, 2017

Conversation

eed3si9n
Copy link
Member

@eed3si9n eed3si9n commented Jan 23, 2017

This is a backport of #2942

Adds an Append instance that extracts taskValue

This adds a macro-level hack to support += op for sourceGenerators and resourceGenerators using RHS of Initialize[Task[Seq[File]]].
When the types match up, the macro now calls .taskValue automatically.

Before:

sourceGenerators in Compile += buildInfo.taskValue,
sourceGenerators in Compile += (Def.task { Nil }).taskValue

After:

sourceGenerators in Compile += buildInfo,
sourceGenerators in Compile += Def.task { Nil }

This adds a macro-level hack to support += op for sourceGenerators and resourceGenerators using RHS of Initialize[Task[Seq[File]]].
When the types match up, the macro now calls `.taskValue` automatically.
@eed3si9n eed3si9n merged commit b646662 into sbt:0.13 Feb 7, 2017
@eed3si9n eed3si9n deleted the backport/generators branch February 7, 2017 17:26
@eed3si9n eed3si9n mentioned this pull request Apr 4, 2017
7 tasks
@jvican
Copy link
Member

jvican commented Jun 14, 2017

Note that this only works for settings.

The macro code to implement this looks scary. Are we sure we want to special case this for settings and +=? This is IMO a big hack that can confuse people even more since they won't know where they should actually do .taskValue or not...

@eed3si9n Can you comment on this?

@eed3si9n
Copy link
Member Author

What we colloquially call "tasks" are Def.Initialize[Task[A]], which TaskKey[A] also extends. Importantly, it's not just Task[A]. The build user expects sourceGenerators to also collect reference to "tasks", and the fact that its type is SettingKey[Seq[Task[Seq[File]]]] is not that important. It's just the matter of matching types.

See discussion in #2942 for more details.

@jvican
Copy link
Member

jvican commented Jun 14, 2017

I'm well aware of those details.

My comment is that this only works for setting keys (source generators) but it won't work for task keys. We're still forcing users to match the types in that case.

@eed3si9n
Copy link
Member Author

Sure. But why would anyone wrap Task in a Task?

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

Successfully merging this pull request may close these issues.

None yet

2 participants