So I'm trying to make an automated bash script to help build certain versions of the Minecraft Spigot server. In order to "build" the server, you have to decompile the .jar file by running the following commands in the terminal.
export MAVEN_OPTS="-Xmx2G"
export JAVA_HOME="/usr/libexec/java_home -v 1.8"
(Omit this line unless you are building a previous version then the current 1.13 build, which uses Java 11 and not Java 8)
java -jar BuildTools.jar
(Optional: --rev
flag can be used to dictate what version you would like to download of the server)
Now this is what I have come up with so far to make a simple "double click and done" bash script. I'm extremely new to running, compiling, writing, etc of bash scripts. The error I'm getting is something along the lines of "Can't find BuildTools.jar", however this is blocked by a pop up from my terminal that I can't get rid of and still see the message. Once I click ok, it just closes the window.
#!/bin/sh
cd "$( dirname "$0" )"
export MAVEN_OPTS="-Xmx2G"
export JAVA_HOME="/usr/libexec/java_home -v 1.8"
exec java -jar BuildTools.jar --rev 1.8.8
My main objective is to just be able to edit the script manually and dictate what version I would like to download by changing the --rev
flag, and deleting the "java version" line if not using the current 1.13 build.
Ideally I would like the script once run, to ask me what version I would like to use. If i hit enter it omits the --rev
flag & java version line, and downloads the current version (1.13), if I specify a version (i.e. "1.9") it runs the export JAVA_HOME="/usr/libexec/java_home -v 1.8"
line and adds the --rev
flag to the end of the exec line.
If this doesn't make any sense, here is the article explaining how to do what I'm doing through the terminal with no "automated script".
https://www.spigotmc.org/wiki/buildtools/
I would like to get this script to work as I would forward this script along to other server developers that would be able to use the script in their every day development and not have to run multiple commands through the terminal every time they want to build a server.