How to execute the tar command with Gradle exec plugin?

I’m trying to execute the following snippet in order to unzip the Postgres tar file:

task unzipPostgres(type: Exec) { commandLine 'tar' '-xf' 'postgres/postgresql.tar.bz2' }

But the task fails with:

Caused by: org.gradle.api.internal.MissingMethodException: Could not find method -xf() for arguments [postgres/postgresql.tar.bz2] on task ':postgres:unzipPostgres'.

I have tried many ways, with executable, with args but none seems to work.

Could somebody help me?

You’re missing commas, so it’s trying to interpret it like…

commandLine('tar', -xf('postgres/postgresql.tar.bz2'))

You can fix it:

task unzipPostgres(type: Exec) {
   commandLine 'tar', '-xf', 'postgres/postgresql.tar.bz2'

commandLine is just a method:

Thank you very much !! It works with the commas