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

Provider.map is incompatible with excluded tasks #21179

Open
ejona86 opened this issue Jul 6, 2022 · 2 comments
Open

Provider.map is incompatible with excluded tasks #21179

ejona86 opened this issue Jul 6, 2022 · 2 comments
Labels
a:bug in:exec-tasks in:provider-api property lazy provider MapProperty ListProperty DirectoryProperty

Comments

@ejona86
Copy link

ejona86 commented Jul 6, 2022

Expected Behavior

Calling get() on a provider created with provider.map { it } succeeds in a task action, even if the task that produced the original provider is excluded.

Dealing with excluded tasks (-x) in a build is strange and might be open to interpretation on precise behavior, but it seems it should behave similarly to a disabled task (enable = false) and definitely not penalize .map{} usage. If the current behavior is working as designed then modern providers are incompatible with task exclusion and exclusion should be deprecated to allow using provider.map in plugins.

Current Behavior

Within a task action, calling provider.get() for output of an excluded task commonly works. But if the provider was mapped (provider.map { it }.get()) then the build fails:

Querying the mapped value of provider(interface java.util.Set) before task ':excludedTask' has completed is not supported

Context

A user complained about a bug in my plugin after the plugin introduced a .map {} usage. (It is unclear what caused the issue for the original poster, but that later user did provide a clear repro which I used to investigate.)

Steps to Reproduce

https://github.com/ejona86/gradle-bug-map-exclude

$ ./gradlew build --continue

> Task :brokenWithMapInActionWhenTaskExcluded FAILED
[/tmp/gradle-exclude-mapped/build/created1]

> Task :brokenWithMapWhenTaskExcluded FAILED
Execution optimizations have been disabled for task ':brokenWithMapWhenTaskExcluded' to ensure correctness due to the following reasons:
  - Type 'ProcessInput' property 'inputArg' cannot be resolved:  Querying the mapped value of provider(interface java.util.Set) before task ':excludedTask' has completed is not supported. Reason: An input file collection couldn't be resolved, making it impossible to determine task inputs. Please refer to https://docs.gradle.org/7.4.2/userguide/validation_problems.html#unresolvable_input for more details about this problem.

> Task :workingWithMapWhenTaskDisabled
[/tmp/gradle-exclude-mapped/build/created3]

> Task :workingWithMapWhenTaskNormal
[/tmp/gradle-exclude-mapped/build/created2]

> Task :workingWithoutMapWhenTaskExcluded
[/tmp/gradle-exclude-mapped/build/created1]

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/tmp/gradle-exclude-mapped/build.gradle' line: 34

* What went wrong:
Execution failed for task ':brokenWithMapInActionWhenTaskExcluded'.
> Querying the mapped value of provider(interface java.util.Set) before task ':excludedTask' has completed is not supported

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

2: Task failed with an exception.
-----------
* Where:
Build file '/tmp/gradle-exclude-mapped/build.gradle' line: 7

* What went wrong:
Execution failed for task ':brokenWithMapWhenTaskExcluded'.
> Querying the mapped value of provider(interface java.util.Set) before task ':excludedTask' has completed is not supported

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
==============================================================================

Your Environment

Build scan URL: https://gradle.com/s/tpslxaztlxvma

@stmlange
Copy link

Bumped into this issue as well and find it very frustrating. Any plans to triage this soonish and perhaps even get it fixed?

@stmlange
Copy link

stmlange commented Feb 3, 2023

Any updates on this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:bug in:exec-tasks in:provider-api property lazy provider MapProperty ListProperty DirectoryProperty
Projects
None yet
Development

No branches or pull requests

3 participants