-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
Make built-in Gradle tasks and java.lang.Object accepting methods more Provider<>
friendly
#4224
Comments
@mkobit great issue report. 👏 Lot's of explanation of the problem in practical terms and not just a proposed solution implementation. |
Maybe breaking this down into separate issues would help it be incrementally fixed or improved? I listed a couple tasks and areas above that had issues, but it is not exhaustive. This might make it easier to pick a few areas where I can get some guidance and contribute a fix in that area. For example, the
Lots of these take in There is, however, another thing that makes moving this forward ambiguous. The I'm sure there is similar discussion that could be had in other areas like |
Wrt |
Provider<>
friendlyProvider<>
friendly
What's the plan for fixing such a fundamental issue? This is causing tremendous pain. |
This issue has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be automatically closed if no further activity occurs. If you're interested in how we try to keep the backlog in a healthy state, please read our blog post on how we refine our backlog. If you feel this is something you could contribute, please have a look at our Contributor Guide. Thank you for your contribution. |
This issue has been automatically closed due to inactivity. If you can reproduce this on a recent version of Gradle or if you have a good use case for this feature, please feel free to to let know so we can reopen the issue. Please try to provide steps to reproduce, a quick explanation of your use case or a high-quality pull request. |
I know this is closed as unplanned, but in case others arrive here it looks like this is eventually planned to be addressed with https://github.com/orgs/gradle/projects/31/views/1 |
Gradle recently introduced the
Provider<>
types to make configuration more lazy and functional. These types are great to use in custom plugins and when composing functional pieces together. Passing around functions that produce values is a much easier way to reason about the dependency graph when you only care about inputs and outputs and not as much about the underlying dependencies. You only have to find the value you want, possibly transform it (executed lazily), and then Gradle will take care of the ordering and precedence to produce that value.Wiring tasks together that have inputs or outputs of
Provider<>
/Property
is mostly straightfoward. Taking outputs from one task that are not aProvider<>
type and wrapping them to be aProvider<>
is also easy to do (although input provenance and inferred task dependencies might not be present). However, trying to use tasks that have outputs ofProvider<>
and using them in tasks that do not accept them is painful and removes the benefits of lazy/calculated values.Expected Behavior
Gradle task types should be more aligned with the
Provider<>
type and functional/lazy model.Current Behavior
You have to call
.get()
to greedily evaluate during configuration time or extract the container value in adoFirst
block. Getting correct up-to-date checks in this manner is tricky, as build script authors may have to register dynamic task inputs in hopes of getting correct up-to-date checks. Some tasks inputs will work as under the hood they convert them withproject.file
, but not all tasks accept or produce file-like inputs and outputs. (Sort of on-topic, I'd like to see non-file type outputs be treated as close to the same as file-type outputs). Some tasks likeExec
that have methods likeargs(Object object...)
seem to work in some cases but not others. They also don't provide strong typing or clues for users who write build scripts in thekotlin-dsl
if they will work withProvider
types or not.Context
This happens anytime you want to wire a
Provider<>
type into a task that does not take in aProvider<>
.Here are a few examples I've ran into:
updating the
Manifest
of aJar
task with an output derived from another task or calculated value (say for example, a Git commit hash)Test
task system properties are generated by another taskTest
task environment variables are generated by another taskWrapper
input URL and other propertiesProvider
of some object in forcommandLine
(and I'm guessing otherObject
accepting methods that coerce toString
)Set the description on any task based on a
Provider<>
valueAdd values/links/tags to Build Scan plugin
Steps to Reproduce (for bugs)
N/A
Your Environment
Gradle 4.5
The text was updated successfully, but these errors were encountered: