forked from YatopiaMC/Yatopia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yatopia
executable file
·224 lines (217 loc) · 6.96 KB
/
yatopia
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
#!/usr/bin/env bash
# Yatopia Build Script
############################################################################
# Multicore building #
# By JosephWorks #
# -------------------------------------------------------------------------#
# To use multicore building, use "$mvncmd" instead of "maven" #
# 20-50% speed improvement is quite common. #
############################################################################
# Exit immediately if a command exits with a non-zero status
set -e
source "./scripts/functions.sh"
JAVA_VERSION=$(java -version 2>&1 | awk 'NR==1{ gsub(/"/,""); print $3 }')
failed=0
case "$1" in
"reset")
(
$scriptdir/resetToUpstream.sh "$basedir"
) || failed=1
;;
"i" | "in" | "init" | "initsubmodules")
(
set -e
basedir
$scriptdir/initUpstream.sh "$basedir" || exit 1
) || failed=1
;;
"r" | "rb" | "rbp" | "rebuild")
(
set -e
basedir
$scriptdir/rebuildPatches.sh "$basedir" || exit 1
) || failed=1
;;
"a" | "p" | "patch" | "apply")
(
set -e
$scriptdir/applyPatches.sh "$basedir" || exit 1
) || failed=1
;;
"b" | "bu" | "build" | "install")
(
echo "$JAVA_VERSION"
basedir
$mvncmd -N install surefire-report:report
cd ${FORK_NAME}-API
$mvncmd -e clean install && (cd ../Tuinity/Paper/Paper-MojangAPI && $mvncmd -e clean install) && cd ../${FORK_NAME}-Server && $mvncmd -e clean install
) || failed=1
;;
"j" | "launcher" | "jar" | "paperclip")
(
basedir
$scriptdir/installLauncher.sh "$basedir"
) || failed=1
;;
"u" | "up" | "upstream" | "update")
(
basedir
$scriptdir/updateUpstream.sh "$basedir"
)
;;
"tu" | "tup" | "tupstream" | "tupdate")
(
$scriptdir/updateUpstream.sh "$basedir" true
)
;;
"r" | "root")
basedir
;;
"a" | "api")
cd "$basedir/Yatopia-API"
;;
"s" | "server")
cd "$basedir/Yatopia-Server"
;;
"c" | "clean")
rm -rf Yatopia-API
rm -rf Yatopia-Server
rm -rf Paper
echo "Cleaned build files"
;;
"clear")
rm -rf Yatopia-API
rm -rf Yatopia-Server
;;
"fp" | "fpatch" | "fixpatch")
$scriptdir/fixPatch.sh "$basedir" $2 || exit 1
;;
"f" | "fu" | "full" | "fullbuild")
(
echo "$JAVA_VERSION"
basedir
$scriptdir/updateUpstream.sh "$basedir" false true || exit 1
set -e
$scriptdir/applyPatches.sh "$basedir" || exit 1
basedir
$mvncmd -N install surefire-report:report
cd ${FORK_NAME}-API
($mvncmd -e clean install && (cd ../Tuinity/Paper/Paper-MojangAPI && $mvncmd -e clean install) && cd ../${FORK_NAME}-Server && $mvncmd -e clean install surefire-report:report) || exit 1
$scriptdir/installLauncher.sh "$basedir" || exit 1
) || failed=1
;;
"e" | "edit")
case "$2" in
"s" | "server")
export Yatopia_LAST_EDIT="$basedir/Yatopia-Server"
cd "$basedir/Yatopia-Server"
(
set -e
gitstash
cd "$basedir/Paper/Paper-Server"
$gitcmd fetch --all
# Create the upstream branch in Paper project with current state
$gitcmd checkout master # possibly already in
$gitcmd branch -D upstream || true
$gitcmd branch -f upstream HEAD
cd "$basedir/Yatopia-Server"
$gitcmd rebase -i upstream/upstream
gitunstash
)
;;
"a" | "api")
export Yatopia_LAST_EDIT="$basedir/Yatopia-API"
cd "$basedir/Yatopia-API"
(
set -e
gitstash
cd "$basedir/Paper/Paper-API"
$gitcmd fetch --all
# Create the upstream branch in Paper project with current state
$gitcmd checkout master # possibly already in
$gitcmd branch -D upstream || true
$gitcmd branch -f upstream HEAD
cd "$basedir/Yatopia-API"
$gitcmd rebase -i upstream/upstream
gitunstash
)
;;
"c" | "continue")
cd "$Yatopia_LAST_EDIT"
unset Yatopia_LAST_EDIT
(
set -e
$gitcmd add .
$gitcmd commit --amend
$gitcmd rebase --continue
basedir
$scriptdir/rebuildPatches.sh "$basedir"
)
;;
*)
echo "You must edit either the api or server."
;;
esac
;;
"setup")
if [[ -f ~/.bashrc ]]; then
NAME="Yatopia"
if [[ ! -z "${2+x}" ]]; then
NAME="$2"
fi
(grep "alias $NAME=" ~/.bashrc >/dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >>~/.bashrc)
alias "$NAME=. $SOURCE"
echo "You can now just type '$NAME' at any time to access the Yatopia tool."
fi
;;
"mcserverdep")
./scripts/instRemappedJar.sh
;;
"commitUpstream" | "cu" | "commitUp" | "commerge")
./scripts/commitUpstream.sh
;;
*)
echo "Yatopia build tool command. This provides a variety of commands to build and manage the Yatopia build"
echo "environment. For all of the functionality of this command to be available, you must first run the"
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
echo ""
echo " Normal commands:"
echo " * r, rebuild | Rebuild patches, can be called from anywhere."
echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere."
echo " * u, update | Updates all submodules. Can be run from anywhere."
echo " * b, build | Build the projects, including the API and the Server. Can be ran anywhere."
echo " * j, jar | Build the projects and build the launcher jar. Can be ran anywhere."
echo " * d, deploy | Build the projects and deploy through Maven. Can be ran anywhere."
echo " * tupstream | Updates only tuinity submodule. Can be ran everywhere."
echo ""
echo " These commands require the setup command before use:"
echo " * r, root | Change directory to the root of the project."
echo " * a. api | Move to the Yatopia-API directory."
echo " * s, server | Move to the Yatopia-Server directory."
echo " * e, edit | Use to edit a specific patch, give it the argument \"server\" or \"api\""
echo " | respectively to edit the correct project. Use the argument \"continue\" after"
echo " | the changes have been made to finish and rebuild patches. Can be called from anywhere."
echo ""
echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
echo " | . ./Yatopia setup"
echo " | After you run this command you'll be able to just run 'Yatopia' from anywhere."
echo " | The default name for the resulting alias is 'Yatopia', you can give an argument to override"
echo " | this default, such as:"
echo " | . ./Yatopia setup example"
echo " | Which will allow you to run 'example' instead."
;;
esac
unset RCPATH
unset SOURCE
unset basedir
unset -f color
unset -f colorend
unset -f gitstash
unset -f gitunstash
if [[ "$failed" == "1" ]]; then
unset failed
false
else
unset failed
true
fi