anand mishra
anand mishra

Reputation: 900

How to add the bash and shell script directory path in gradle build script?

I want to add the path of a directory which contains the multiple scripts for windows and linux in my build.gradle script. Currently i am defining the task like this and its working fine.

task initdb(type: Exec){
    if (System.getProperty('os.name').toLowerCase().contains('windows')) {
        commandLine 'cmd', '/c', 'My_CONF\\pgdb\\initdb.cmd'
    } else {
        commandLine 'My_CONF/pgdb/initdb.sh'
    }
}

But I want to define this task as-

task initdb(type: Exec){
    if (System.getProperty('os.name').toLowerCase().contains('windows')) {
        commandLine 'cmd', '/c', 'initdb.cmd'
    } else {
        commandLine 'initdb.sh'
    }
}

These scripts also uses the another scripts which is in My_CONF\pgdb directory.

Upvotes: 3

Views: 1474

Answers (1)

Stanislav
Stanislav

Reputation: 28126

You can try to use the workingDir property of the task with type Exec, which is defaults to the build script root dir. Take a look at the documentation about it here.

Upvotes: 2

Related Questions