| git checkout gerrit/{branch} |
| git fetch https://gerrit.googlesource.com/plugins/{name} $REFS_CHANGE |
| git read-tree -u --prefix=plugins/{name} FETCH_HEAD |
| if [ -f plugins/{name}/external_plugin_deps.bzl ] |
| cp -f plugins/{name}/external_plugin_deps.bzl plugins/ |
| TARGETS=$(echo "{targets}" | sed -e 's/{{name}}/{name}/g') |
| bazel build --spawn_strategy=standalone --genrule_strategy=standalone $TARGETS |
| for JAR in $(find bazel-genfiles/plugins/{name} -name {name}*.jar) |
| PLUGIN_VERSION=$(git describe --always origin/{branch}) |
| echo -e "Implementation-Version: $PLUGIN_VERSION" > MANIFEST.MF |
| jar ufm $JAR MANIFEST.MF && rm MANIFEST.MF |
| DEST_JAR=bazel-genfiles/plugins/{name}/$(basename $JAR) |
| [ "$JAR" -ef "$DEST_JAR" ] || mv $JAR $DEST_JAR |
| echo "$PLUGIN_VERSION" > bazel-genfiles/plugins/{name}/$(basename $JAR-version) |