mirror of
https://github.com/TotalFreedomMC/OpenInv.git
synced 2024-12-22 16:05:03 +00:00
Fix cache breaking build on Spigot version change
This commit is contained in:
parent
1bd7932cc5
commit
519dd7da33
3 changed files with 79 additions and 11 deletions
13
.github/workflows/ci.yml
vendored
13
.github/workflows/ci.yml
vendored
|
@ -9,8 +9,6 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
|
||||||
fail-fast: true
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout Code
|
- name: Checkout Code
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
|
@ -28,15 +26,10 @@ jobs:
|
||||||
path: ~/.m2/repository
|
path: ~/.m2/repository
|
||||||
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
||||||
|
|
||||||
# If the cache was not present, run BuildTools to install the relevant versions to Maven.
|
# Install Spigot dependencies.
|
||||||
# This will take approximately forever.
|
# This script uses Maven to check all required installations and ensure that they are present.
|
||||||
- name: Install Spigot Dependencies
|
- name: Install Spigot Dependencies
|
||||||
if: steps.cache.outputs.cache-hit != 'true'
|
run: . scripts/install_spigot_dependencies.sh
|
||||||
run: |
|
|
||||||
mkdir ~/buildtools
|
|
||||||
cd ~/buildtools
|
|
||||||
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
|
|
||||||
java -jar BuildTools.jar --rev 1.16.4
|
|
||||||
|
|
||||||
- name: Build With Maven
|
- name: Build With Maven
|
||||||
run: mvn -e clean package -am -P all
|
run: mvn -e clean package -am -P all
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.16.4-R0.1-SNAPSHOT</version>
|
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
75
scripts/install_spigot_dependencies.sh
Normal file
75
scripts/install_spigot_dependencies.sh
Normal file
|
@ -0,0 +1,75 @@
|
||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Copyright (C) 2011-2021 lishid. All rights reserved.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, version 3.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
# A script for installing required Spigot versions.
|
||||||
|
#
|
||||||
|
# Note that this script is designed for use in GitHub Actions, and is
|
||||||
|
# not particularly robust nor configurable.
|
||||||
|
# In its current state, the script must be run from OpenInv's parent
|
||||||
|
# project directory and will always install BuildTools to ~/buildtools.
|
||||||
|
|
||||||
|
buildtools_dir=~/buildtools
|
||||||
|
buildtools=$buildtools_dir/BuildTools.jar
|
||||||
|
|
||||||
|
get_spigot_versions () {
|
||||||
|
# Get all submodules of internal module
|
||||||
|
modules=$(mvn help:evaluate -Dexpression=project.modules -q -DforceStdout -P all -pl internal | grep -oP '(?<=<string>)(.*)(?=<\/string>)')
|
||||||
|
for module in "${modules[@]}"; do
|
||||||
|
|
||||||
|
# Get number of dependencies declared in pom of specified internal module
|
||||||
|
max_index=$(mvn help:evaluate -Dexpression=project.dependencies -q -DforceStdout -P all -pl internal/"$module" | grep -c "<dependency>")
|
||||||
|
|
||||||
|
for ((i=0; i < max_index; i++)); do
|
||||||
|
# Get artifactId of dependency
|
||||||
|
artifact_id=$(mvn help:evaluate -Dexpression=project.dependencies["$i"].artifactId -q -DforceStdout -P all -pl internal/"$module")
|
||||||
|
|
||||||
|
# Ensure dependency is spigot
|
||||||
|
if [[ "$artifact_id" == spigot ]]; then
|
||||||
|
# Get spigot version
|
||||||
|
spigot_version=$(mvn help:evaluate -Dexpression=project.dependencies["$i"].version -q -DforceStdout -P all -pl internal/"$module")
|
||||||
|
echo "$spigot_version"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
get_buildtools () {
|
||||||
|
if [[ -d $buildtools_dir && -f $buildtools ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir $buildtools_dir
|
||||||
|
wget https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar -O $buildtools
|
||||||
|
}
|
||||||
|
|
||||||
|
versions=$(get_spigot_versions)
|
||||||
|
echo Found Spigot dependencies: "$versions"
|
||||||
|
|
||||||
|
for version in "${versions[@]}"; do
|
||||||
|
set -e
|
||||||
|
exit_code=0
|
||||||
|
mvn dependency:get -Dartifact=org.spigotmc:spigot:"$version" -q -o || exit_code=$?
|
||||||
|
if [ $exit_code -ne 0 ]; then
|
||||||
|
echo Installing missing Spigot version "$version"
|
||||||
|
revision=$(echo "$version" | grep -oP '(\d+\.\d+(\.\d+)?)(?=-R[0-9\.]+-SNAPSHOT)')
|
||||||
|
get_buildtools
|
||||||
|
java -jar $buildtools -rev "$revision"
|
||||||
|
else
|
||||||
|
echo Spigot "$version" is already installed
|
||||||
|
fi
|
||||||
|
done
|
Loading…
Reference in a new issue