From e3d9cea0274a6b0ee2d883925913be9c165874c7 Mon Sep 17 00:00:00 2001 From: Jikoo Date: Sat, 16 Oct 2021 17:54:30 -0400 Subject: [PATCH] Fix spigot dependency parsing * Re-add cache * Work around reflection issues with mvn help:evaluate on Java 9+ --- scripts/get_spigot_versions.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/scripts/get_spigot_versions.sh b/scripts/get_spigot_versions.sh index 4dca717..1e079f3 100644 --- a/scripts/get_spigot_versions.sh +++ b/scripts/get_spigot_versions.sh @@ -15,21 +15,32 @@ # along with this program. If not, see . # -# TODO Fix script for bash version used in Actions images -hacky_versions=("1.17.1-R0.1-SNAPSHOT") -for hacky_version in "${hacky_versions[@]}"; do - echo "$hacky_version" -done - -exit 0 - # Note that this script is designed for use in GitHub Actions, and is not # particularly robust nor configurable. Run from project parent directory. +# Use a nameref as a cache - maven evaluation is pretty slow. +# Re-calling the script and relying on it to handle caching is way easier than passing around info. +declare -a spigot_versions + +# We don't care about concatenation - either it's not null and we handle entries or it's null and we instantiate. +# shellcheck disable=SC2199 +if [[ ${spigot_versions[@]} ]]; then + for spigot_version in "${spigot_versions[@]}"; do + echo "$spigot_version" + done + return +fi + +old_maven_opts=$MAVEN_OPTS +# Add JVM parameters to allow help plugin access to packages it needs. +export MAVEN_OPTS="$old_maven_opts --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.lang.reflect=ALL-UNNAMED --add-opens java.base/java.text=ALL-UNNAMED --add-opens java.desktop/java.awt.font=ALL-UNNAMED" + # Pull Spigot dependency information from Maven. # Since we only care about Spigot versions, only check modules in the folder internal. readarray -t modules <<< "$(mvn help:evaluate -Dexpression=project.modules -q -DforceStdout -P all | grep -oP '(?<=)(internal/.*)(?=)')" +declare -n versions="spigot_versions" + 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 "$module" | grep -c "") @@ -48,3 +59,6 @@ for module in "${modules[@]}"; do fi done done + +# Reset JVM parameters +export MAVEN_OPTS=$old_maven_opts \ No newline at end of file