Ben Berman
07/09/2025, 10:22 PMexec { }
is really annoying
where is it documented what the conversion is? what am i supposed to do?
https://github.com/search?q=%22exec+%7B%22+language%3Agradle&type=code
there are 38,000 usages of exec {
ephemient
07/09/2025, 10:36 PMBen Berman
07/10/2025, 4:03 PMtasks.register("...") {
doLast {
exec {
}
exec {
}
}
}
becomes
def execOperations = services.get(ExecOperations)
tasks.register("...") {
doLast {
execOperations.exec {
}
execOperations.exec {
}
}
}
?Vampire
07/10/2025, 4:12 PMservices.
is not public API but internal, so if you use it it can break any time
⢠you use a build script reference so if you try to use configuration cache it will also failephemient
07/10/2025, 4:12 PMVampire
07/10/2025, 4:13 PMinterface ExecOperationsProvider {
@Inject
ExecOperations getExecOperations()
}
tasks.register("...") {
def execOperations = objects.newInstance(ExecOperationsProvider).execOperations
doLast {
execOperations.exec {
}
execOperations.exec {
}
}
}
but it might be better to make it a proper task class where you can inject the ExecOperations
without that provider-trickBen Berman
07/10/2025, 4:19 PMephemient
07/10/2025, 4:20 PMBen Berman
07/10/2025, 4:20 PMexecOperations.exec
but it would have been nice if it were just the right exec based on the context, it almost always is related to the scope of where it is calledBen Berman
07/10/2025, 4:20 PMVampire
07/10/2025, 4:21 PMBen Berman
07/10/2025, 4:21 PMBen Berman
07/10/2025, 4:21 PMVampire
07/10/2025, 4:21 PMVampire
07/10/2025, 4:22 PMBen Berman
07/10/2025, 4:22 PMVampire
07/10/2025, 4:22 PMVampire
07/10/2025, 4:22 PMBen Berman
07/10/2025, 4:42 PMBen Berman
07/10/2025, 4:42 PM