Question for those developing on Gradle itself: do...
# plugin-development
k
Question for those developing on Gradle itself: does it make sense for there to be a Kotlin extension that converts something like a
Provider<List<String>>
to
Sequence<String>
or a
FileCollection
to a
Sequence<File>
? Or am I off-base in terms of the lazy semantics contained therein?
o
Sequence
vs
Iterable
is mostly a distinction for the methods available on them, not in how the data is generated -- there's no benefit in adding a specific integration here vs. just calling
asSequence()
on the existing
Iterable
implementation. https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/as-sequence.html
Well,
Provider<List<...>>
could perhaps benefit, but I don't know if it's useful enough to warrant such an extension. You also have to consider that it loses task dependency information that could be retained by staying with a
Provider
.
k
Yeah, my fear was that there was something unintended if I did
Copy code
val provider: Provider<List<String>>
val sequence = sequence {
  yieldAll(provider.get())
}
o
That will work, and would be equivalent to any extension that could be added to Gradle. Typically a
Provider
should not be resolved before execution though, so I'm unsure how much value there is in having such a sequence. You might as well just wait to get an iterator directly from the
List
once you need it.
That is, you're just trading one lazy wrapper for another -- neither is really going to work that differently in terms of when it gets resolved.