This message was deleted.
# configuration-cache
s
This message was deleted.
a
zipTree is evaluated at execution time, and it's a method from Project. Also the report is missing information https://github.com/gradle/gradle/issues/24030#issuecomment-1731096249 try this:
Copy code
val task by tasks.registering {
  val archives = serviceOf<ArchiveOperations>

  val unzipped = elements.map { archives.zipTree(it) }
}
i
Thanks! That does solve my problems.
🙌 1
v
You shouldn't use
serviceOf
though. It is considered internal API, not public API and thus could change any time.
i
What should I use instead?
a
it's not been marked or documented as internal for 7 years 🤷‍♀️. The alternative is verbose and boilerplatey https://docs.gradle.org/current/userguide/configuration_cache.html#config_cache:requirements:use_project_during_execution
Copy code
interface Injected {
    @get:Inject val fs: FileSystemOperations 
}
tasks.register("someTask") {
    val injected = project.objects.newInstance<Injected>() 
}
v
> What should I use instead? Ah, sorry, was distracted. Actually, if you need such a service it is a strong sign that it is time to create a dedicated class for that task into which you can simply inject the service instead of an ad-hoc task. Other than that, like @Adam and the docs show it. > it's not been marked or documented as internal for 7 years That's not actually correct. https://docs.gradle.org/current/userguide/authoring_maintainable_build_scripts.html#alternatives_for_oft_used_internal_apis lists the packages containing public API.
serviceOf
is in
org.gradle.kotlin.dsl.support
which is not part of that list and thus not public API. Another strong sign is, that you need an explicit import to use id. And another "strong sign" is, that the author of that function said it is internal API. 🙂