Skip to content

Commit

Permalink
Miscellaneous build improvements (#3916)
Browse files Browse the repository at this point in the history
* Fix PaperMC Maven repository URL

* Bump Gradle to 8.12

* Remove redundant "java" plugin declaration

* Use new coordinates for shadow plugin

* Bump loom to 1.9-SNAPSHOT

* Use new coordinates for RedisBungee

* Use server-only platform for Sponge

* Target Java 11 for API (already required by the plugin)

* Use first-party gradle/setup-gradle action for build caching

* Copycat better workflow conditions from PaperMC

* Revert "Target Java 11 for API (already required by the plugin)"

This reverts commit dd09e85.
  • Loading branch information
AnttiMK authored Jan 5, 2025
1 parent 364a3fe commit 2860203
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 41 deletions.
38 changes: 26 additions & 12 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@

name: CI

on: [push, pull_request]
on:
push:
pull_request:
types:
- opened
- reopened
- synchronize

jobs:
test:
if: >
(
(github.event_name == 'push')
|| (github.event_name == 'pull_request' && github.repository != github.event.pull_request.head.repo.full_name && contains(fromJSON('["opened", "reopened", "synchronize"]'), github.event.action))
)
name: Test, Build & Upload

runs-on: ubuntu-latest
Expand All @@ -22,24 +34,26 @@ jobs:
options: --health-cmd="mariadb-admin ping" --health-interval=5s --health-timeout=2s --health-retries=3

steps:
- name: 📥 Checkout git repository
- if: ${{ github.event_name == 'push' }}
name: 📥 Checkout git repository
uses: actions/checkout@v4
with:
fetch-depth: 0

- if: ${{ github.event_name == 'pull_request' }}
name: 📥 Checkout git repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.sha }}

- name: ☕ Setup JDK
uses: actions/setup-java@v4
with:
distribution: 'adopt'
distribution: 'temurin'
java-version: '21'
- name: 💼 Load Gradle Cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: 💼 Setup Gradle
uses: gradle/actions/setup-gradle@v4
- name: 🛠 Build jars
run: |
cd Plan
Expand Down
10 changes: 4 additions & 6 deletions Plan/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@ buildscript {
}

plugins {
id "com.github.johnrengelman.shadow" version "8.1.1" apply false
id "java"
id 'java-library'
id "jacoco"
id "checkstyle"
id "org.sonarqube" version "6.0.1.5171"
id 'fabric-loom' version '1.6-SNAPSHOT' apply false
id "com.gradleup.shadow" version "8.3.5" apply false
id 'fabric-loom' version '1.9-SNAPSHOT' apply false
}

apply plugin: 'nebula-aggregate-javadocs'
Expand Down Expand Up @@ -55,10 +54,9 @@ logger.lifecycle("Building artifact for version $fullVersion / $fullVersionFilen

subprojects {
// Build plugins
apply plugin: "com.github.johnrengelman.shadow"
apply plugin: "java"
apply plugin: "java-library"
apply plugin: "maven-publish"
apply plugin: "com.gradleup.shadow"

// Report plugins
apply plugin: "checkstyle"
Expand Down Expand Up @@ -116,7 +114,7 @@ subprojects {
mavenCentral()
google()
maven { url = "https://hub.spigotmc.org/nexus/content/repositories/snapshots/" } // Spigot
maven { url = "https://papermc.io/repo/repository/maven-public/" } // Paper
maven { url = "https://repo.papermc.io/repository/maven-public/" } // Paper
maven { url = "https://repo.spongepowered.org/repository/maven-public/" } // Sponge
maven { url = "https://oss.sonatype.org/content/repositories/snapshots" } // BungeeCord
maven { url = "https://repo.playeranalytics.net/releases" } // Plan
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public abstract class SQLDB extends AbstractDatabase {
private static boolean downloadDriver = true;

private static final List<Repository> DRIVER_REPOSITORIES = Arrays.asList(
new StandardRepository("https://papermc.io/repo/repository/maven-public"),
new StandardRepository("https://repo.papermc.io/repository/maven-public"),
new StandardRepository("https://repo1.maven.org/maven2")
);

Expand Down
Binary file modified Plan/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion Plan/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
14 changes: 7 additions & 7 deletions Plan/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -145,15 +145,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -202,11 +202,11 @@ fi
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions Plan/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
2 changes: 1 addition & 1 deletion Plan/sponge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ sponge {

minecraft {
version("1.16.5")
platform(MinecraftPlatform.JOINED)
platform(MinecraftPlatform.SERVER)
}

compileJava {
Expand Down
6 changes: 3 additions & 3 deletions Plan/velocity/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ dependencies {

compileOnly "com.velocitypowered:velocity-api:$velocityVersion"
annotationProcessor "com.velocitypowered:velocity-api:$velocityVersion"
compileOnly "com.github.ProxioDev.RedisBungee:RedisBungee-API:$redisBungeeProxioDevVersion"
compileOnly "com.github.ProxioDev.ValioBungee:RedisBungee-API:$redisBungeeProxioDevVersion"

testImplementation "com.velocitypowered:velocity-api:$velocityVersion"
testImplementation "com.github.ProxioDev.RedisBungee:RedisBungee-API:$redisBungeeProxioDevVersion"
testImplementation "com.github.ProxioDev.ValioBungee:RedisBungee-API:$redisBungeeProxioDevVersion"
testImplementation project(path: ":common", configuration: 'testArtifacts')
}

shadowJar {
configurations = [project.configurations.shadow]
relocate 'org.bstats', 'net.playeranalytics.bstats.utilities.metrics'
}
}

0 comments on commit 2860203

Please sign in to comment.