-
Notifications
You must be signed in to change notification settings - Fork 3
/
build.sh
executable file
·39 lines (29 loc) · 1.53 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
set -e -o pipefail
# Make sure you update the pom.xml, too!
TCHIR_VERSION="v3.1.0"
if [ -z "$TCHIR_NAME" ] || [ -z "$TCHIR_HOME" ] || [ -z "$TCHIR_VERSION" ] || [ -z "$TCHIR_BASE_URL" ]; then
echo "You're calling build.sh without any of the required environment variables."
echo "Did you mean to run bokutachi.sh?"
exit 1;
fi
echo "BUILDING: $TCHIR_NAME $TCHIR_HOME $TCHIR_VERSION $TCHIR_BASE_URL"
# Compile time variables in java are near impossible
# And I cannot stand dependency injection.
# Am I going to hell for reinventing the C preprocessor poorly?
# Probably.
JAVA_LOC='./src/main/java/bms/player/beatoraja/ir/TachiIR.java'
# Overwrite strings with our vars
sed -i "s|\${tachi.name}|$TCHIR_NAME|" "$JAVA_LOC"
sed -i "s|\${tachi.home}|$TCHIR_HOME|" "$JAVA_LOC"
sed -i "s|\${tachi.version}|$TCHIR_VERSION|" "$JAVA_LOC"
sed -i "s|\${tachi.baseUrl}|$TCHIR_BASE_URL|" "$JAVA_LOC"
# Compile
mvn compile assembly:single
# Reset everything to what it was
sed -i "s|public static final String NAME =.*;|public static final String NAME = \"\${tachi.name}\";|" "$JAVA_LOC"
sed -i "s|public static final String HOME =.*;|public static final String HOME = \"\${tachi.home}\";|" "$JAVA_LOC"
sed -i "s|public static final String VERSION =.*;|public static final String VERSION = \"\${tachi.version}\";|" "$JAVA_LOC"
sed -i "s|private static final String BASE_URL =.*;|private static final String BASE_URL = \"\${tachi.baseUrl}\";|" "$JAVA_LOC"
# Optional 4th step: cry
echo "FINISHED BUILDING: $TCHIR_NAME $TCHIR_HOME $TCHIR_VERSION $TCHIR_BASE_URL"