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

Projects
None yet
2 participants
@eed3si9n
Member

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 }
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.

@eed3si9n eed3si9n merged commit b646662 into sbt:0.13 Feb 7, 2017

2 checks passed

codacy/pr Good work! A positive pull request.
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@eed3si9n eed3si9n deleted the eed3si9n:backport/generators branch Feb 7, 2017

@eed3si9n eed3si9n removed the in progress label Feb 7, 2017

@eed3si9n eed3si9n referenced this pull request Apr 4, 2017

Closed

[sbt 1.0] Forward port 0.13 changes #2352

7 of 7 tasks complete
@jvican

This comment has been minimized.

Show comment
Hide comment
@jvican

jvican Jun 14, 2017

Member

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?

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

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Jun 14, 2017

Member

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.

Member

eed3si9n commented Jun 14, 2017

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

This comment has been minimized.

Show comment
Hide comment
@jvican

jvican Jun 14, 2017

Member

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.

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

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Jun 14, 2017

Member

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

Member

eed3si9n commented Jun 14, 2017

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