Execute Gradle command with Gradle task

Solution 1:

Are you working on windows machine?

We had the problem that on windows machine you have to call gradlew.bat

Example:

task prodRepackage(type: Exec) {
    group = "Build"
    if (OperatingSystem.current().isWindows()) {
        executable "gradlew.bat"
        args "-Pprod", "bootJar"
    } else {
        executable "./gradlew"
        args "-Pprod", "bootJar"
    }
}