A shell script is a very versatile way to extend your build to basically anything you can think of.

As an exmaple, here is a simple script to compile protobuf files and add the result java files to the source directory for further compilation:

def compilePb() {
    exec {
        // NOTICE: gradle will fail if there's an error in the protoc file...
        executable "../pbScript.sh"
    }
}

project.afterEvaluate {
    compilePb()
}

The ‘pbScript.sh’ shell script for this example, located in the project’s root folder:

#!/usr/bin/env bash
pp=/home/myself/my/proto

/usr/local/bin/protoc -I=$pp \\
 --java_out=./src/main/java \\
  --proto_path=$pp \\
 $pp/my.proto \\
 --proto_path=$pp \\
 $pp/my_other.proto