PickShadow/build.sh
JeremyStarTM 77f7c34298
Implement support for git commit versioning
This commit also removes the Makefile introduced in 80236e6130 as make doesn't seem to like $().
2024-04-23 19:47:46 +02:00

21 lines
900 B
Bash
Executable file

#!/bin/bash
set -euo pipefail
echo ":: Renaming GitHead.java to GitHead.javabak"
mv src/main/java/de/pickshadow/plugin/GitHead.java src/main/java/de/pickshadow/plugin/GitHead.javabak
echo ":: Writing new GitHead.java"
cat << EOF >> src/main/java/de/pickshadow/plugin/GitHead.java
package de.pickshadow.plugin;
public class GitHead {
public static String commitSha = "$(git rev-parse HEAD)";
public static String commitShaShort = "$(git rev-parse --short HEAD)";
public static String commitMessage = "$(PAGER= git log --format=%B -n 1 $(git rev-parse HEAD)|head -1|sed "s/\\\/\\\\/g"|sed "s/\"/\\\\\"/g")";
}
EOF
echo ":: Compiling plugin"
./gradlew shadowJar
EXITCODE="${?}"
echo ":: Renaming GitHead.javabak to GitHead.java"
mv src/main/java/de/pickshadow/plugin/GitHead.javabak src/main/java/de/pickshadow/plugin/GitHead.java
echo ":: Exiting with code ${EXITCODE}"
exit "${EXITCODE}"