Improve Travis build script (#2338)

I've added a new script at `scripts/buildtools.sh` that is responsible for:
* Checking whether CraftBukkit 1.8 and 1.8.3 are already available in the local Maven repo
* Downloading BuildTools if not already present
* Running BuildTools if necessary

This improves Travis build times as it now doesn't run BuildTools twice for *every single build*, instead running it only if the Travis cache fails and CraftBukkit is missing for some other reason.
This commit is contained in:
md678685 2019-01-01 16:13:50 +00:00 committed by GitHub
commit 3b41bb47b6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 63 additions and 21 deletions

1
.gitignore vendored
View file

@ -39,6 +39,7 @@
/jars /jars
/out /out
.idea/ .idea/
.buildtools/
*.iml *.iml
*.classpath *.classpath
*.project *.project

View file

@ -1,20 +1,10 @@
language: java language: java
branches:
only:
- 2.x
- 1.13
cache: cache:
directories: directories:
- .buildtools - .buildtools
- $HOME/.m2 - $HOME/.m2
before_install: before_install:
- mkdir -p .buildtools - chmod +x scripts/buildtools.sh
- cd .buildtools - scripts/buildtools.sh
- wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
- rm -r work/
- java -jar BuildTools.jar --rev 1.8
- java -jar BuildTools.jar --rev 1.8.3
- cd ..

View file

@ -41,14 +41,14 @@ Building
-------- --------
EssentialsX builds against the Spigot/CraftBukkit server software for legacy support. EssentialsX builds against the Spigot/CraftBukkit server software for legacy support.
To compile EssentialsX, you first need to run [BuildTools](https://www.spigotmc.org/wiki/buildtools) several times:
``` To compile EssentialsX, you first need to run [BuildTools](https://www.spigotmc.org/wiki/buildtools).
java -jar BuildTools.jar --rev 1.8 This only needs to be done once. There are two ways to do this:
java -jar BuildTools.jar --rev 1.8.3
```
Then, to build with Maven, run the following command: * Use the provided script at `scripts/buildtools.sh` to automatically download and run BuildTools if needed.
* Download and run BuildTools yourself for versions `1.8` and `1.8.3`.
Next, to build EssentialsX with Maven, run the following command:
``` ```
mvn clean install mvn clean install
``` ```

51
scripts/buildtools.sh Normal file
View file

@ -0,0 +1,51 @@
#!/bin/bash
mkdir -p .buildtools
pushd .buildtools
is_installed() {
mvn dependency:get -q -Dartifact=$1 -DremoteRepositories=file://$HOME/.m2/repository 1>/dev/null 2>&1
return $?
}
ensure_buildtools() {
if [ ! -f "BuildTools.jar" ]; then
echo "Downloading BuildTools..."
wget -O BuildTools.jar https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
fi
}
run_buildtools() {
ensure_buildtools
java -jar BuildTools.jar --rev $1
if [ $? -ne 0 ]; then
echo "Running BuildTools for CB $1 failed! Aborting."
popd
exit 255
else
echo "Successfully built version $1"
fi
}
# Check CB 1.8
is_installed org.bukkit:craftbukkit:1.8-R0.1-SNAPSHOT
is_18=$? # 0 = present, 1 = not present
# Check CB 1.8.3
is_installed org.bukkit:craftbukkit:1.8.3-R0.1-SNAPSHOT
is_183=$?
if [ $is_18 -ne 0 ]; then
echo "Installing CraftBukkit 1.8..."
run_buildtools 1.8
else
echo "CraftBukkit 1.8 installed; skipping BuildTools..."
fi
if [ $is_183 -ne 0 ]; then
echo "Installing CraftBukkit 1.8.3..."
run_buildtools 1.8.3
else
echo "CraftBukkit 1.8.3 installed; skipping BuildTools..."
fi
popd