Task execution using 'sudo'

(Valeriy Pogrebitskiy) #1

Looking for help…

I’m working on a plugin that exposes some tasks that must be executed using ‘sudo’ (have ‘root’ permissions). This is different from executing entire build process by starting it using ‘sudo’, as well as from executing an existing executable using ‘exec sudo … ’ command.

I would suspect that executing a separate task using ‘sudo’ – is a common requirement, and that there must be a way to do that in Gradle; but I can’t find information on how to do that…

Again, just to clarify – I am looking for a way to define a Gradle task that can be executed using ‘sudo’, while the rest of the build runs using normal user ownership. Is there a plugin that allows executing task (Java code) using ‘sudo’ without resorting to ‘exec’ (this is NOT an executable program that can be executed using ‘exec’) ?

Can you help?