Skip to content

Commit 78d13fa

Browse files
authored
feat: added fabric support (#22)
1 parent 1ec3291 commit 78d13fa

68 files changed

Lines changed: 12068 additions & 41 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build.yml

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ on:
66
branches:
77
- master
88
schedule:
9-
- cron: '0 0 * * 0' # weekly
9+
- cron: "0 0 * * 0"
10+
11+
permissions:
12+
contents: read
1013

1114
jobs:
1215
build:
@@ -15,26 +18,42 @@ jobs:
1518
strategy:
1619
matrix:
1720
include:
21+
- storageType: mariadb
22+
java: 21
1823
- storageType: h2
19-
java: 8
20-
- storageType: h2
21-
java: 11
24+
java: 21
2225

2326
steps:
24-
- uses: actions/checkout@v2
27+
- uses: actions/checkout@v4
28+
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
java-version: 17
33+
distribution: "temurin"
2534

2635
- name: Set up JDK ${{ matrix.java }}
27-
uses: actions/setup-java@v1
36+
uses: actions/setup-java@v4
2837
with:
2938
java-version: ${{ matrix.java }}
30-
31-
- name: Validate Gradle wrapper
32-
uses: gradle/wrapper-validation-action@v1
39+
distribution: "temurin"
3340

3441
- name: Setup Gradle
35-
uses: gradle/gradle-build-action@v2
42+
uses: gradle/actions/setup-gradle@v4
43+
with:
44+
cache-read-only: ${{ github.ref != 'refs/heads/master' }}
45+
46+
- uses: actions/cache@v4
47+
with:
48+
path: |
49+
.gradle/loom-cache
50+
key: ${{ runner.os }}-loom-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}
51+
restore-keys: ${{ runner.os }}-loom-
3652

3753
- name: Execute Gradle build
3854
env:
3955
STORAGE_TYPE: ${{ matrix.storageType }}
40-
run: ./gradlew build
56+
run: ./gradlew build --build-cache --info
57+
58+
- name: Build all Fabric versions
59+
run: ./gradlew :fabric:1.20.1:remapJar :fabric:1.21.1:remapJar :fabric:1.21.4:remapJar --build-cache

.github/workflows/e2e.yml

Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: E2E Tests
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
pull_request:
8+
push:
9+
branches:
10+
- master
11+
workflow_dispatch:
12+
13+
jobs:
14+
e2e-bukkit:
15+
runs-on: ubuntu-latest
16+
name: E2E - Bukkit
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- uses: actions/checkout@v4
22+
with:
23+
repository: BanManagement/BanManager
24+
path: BanManager
25+
ref: master
26+
27+
- name: Set up JDK 21
28+
uses: actions/setup-java@v4
29+
with:
30+
java-version: 21
31+
distribution: "temurin"
32+
33+
- name: Setup Gradle
34+
uses: gradle/actions/setup-gradle@v4
35+
with:
36+
cache-read-only: ${{ github.ref != 'refs/heads/master' }}
37+
38+
- name: Set up Docker Buildx
39+
uses: docker/setup-buildx-action@v3
40+
41+
- name: Cache Docker layers
42+
uses: actions/cache@v4
43+
with:
44+
path: /tmp/.buildx-cache
45+
key: ${{ runner.os }}-docker-e2e-${{ hashFiles('e2e/Dockerfile.tests', 'e2e/tests/package*.json') }}
46+
restore-keys: |
47+
${{ runner.os }}-docker-e2e-
48+
49+
- name: Build test runner image
50+
uses: docker/build-push-action@v5
51+
with:
52+
context: e2e
53+
file: e2e/Dockerfile.tests
54+
push: false
55+
load: true
56+
tags: e2e-tests:latest
57+
cache-from: type=local,src=/tmp/.buildx-cache
58+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
59+
60+
- name: Move Docker cache
61+
run: |
62+
rm -rf /tmp/.buildx-cache
63+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
64+
65+
- name: Build BanManager Bukkit
66+
working-directory: BanManager
67+
run: ./gradlew :BanManagerBukkit:shadowJar --build-cache
68+
69+
- name: Run E2E tests
70+
run: ./gradlew :BanManagerWebEnhancerE2E:testBukkit --build-cache -PbanManagerPath=BanManager
71+
timeout-minutes: 15
72+
73+
- name: Collect logs on failure
74+
if: failure()
75+
working-directory: e2e/platforms/bukkit
76+
run: |
77+
docker compose logs > ../../e2e-logs-bukkit.txt 2>&1 || true
78+
79+
- name: Upload logs on failure
80+
if: failure()
81+
uses: actions/upload-artifact@v4
82+
with:
83+
name: e2e-logs-bukkit
84+
path: e2e-logs-bukkit.txt
85+
retention-days: 7
86+
87+
- name: Cleanup
88+
if: always()
89+
working-directory: e2e/platforms/bukkit
90+
run: docker compose down -v || true
91+
92+
e2e-fabric:
93+
runs-on: ubuntu-latest
94+
name: E2E - Fabric-${{ matrix.mc_version }}
95+
strategy:
96+
fail-fast: false
97+
matrix:
98+
include:
99+
- mc_version: "1.20.1"
100+
task_suffix: "1_20_1"
101+
java_image: "java17"
102+
fabric_loader: "0.16.10"
103+
- mc_version: "1.21.1"
104+
task_suffix: "1_21_1"
105+
java_image: "java21"
106+
fabric_loader: "0.16.9"
107+
- mc_version: "1.21.4"
108+
task_suffix: "1_21_4"
109+
java_image: "java21"
110+
fabric_loader: "0.16.9"
111+
112+
steps:
113+
- uses: actions/checkout@v4
114+
115+
- uses: actions/checkout@v4
116+
with:
117+
repository: BanManagement/BanManager
118+
path: BanManager
119+
ref: master
120+
121+
- name: Set up JDK 21
122+
uses: actions/setup-java@v4
123+
with:
124+
java-version: 21
125+
distribution: "temurin"
126+
127+
- name: Set up JDK 17
128+
uses: actions/setup-java@v4
129+
with:
130+
java-version: 17
131+
distribution: "temurin"
132+
133+
- name: Set JDK 21 as default
134+
run: echo "JAVA_HOME=$JAVA_HOME_21_X64" >> $GITHUB_ENV
135+
136+
- name: Setup Gradle
137+
uses: gradle/actions/setup-gradle@v4
138+
with:
139+
cache-read-only: ${{ github.ref != 'refs/heads/master' }}
140+
141+
- uses: actions/cache@v4
142+
with:
143+
path: |
144+
.gradle/loom-cache
145+
key: ${{ runner.os }}-loom-${{ hashFiles('**/libs.versions.*', '**/*.gradle*', '**/gradle-wrapper.properties') }}
146+
restore-keys: ${{ runner.os }}-loom-
147+
148+
- name: Set up Docker Buildx
149+
uses: docker/setup-buildx-action@v3
150+
151+
- name: Cache Docker layers
152+
uses: actions/cache@v4
153+
with:
154+
path: /tmp/.buildx-cache
155+
key: ${{ runner.os }}-docker-e2e-${{ hashFiles('e2e/Dockerfile.tests', 'e2e/tests/package*.json') }}
156+
restore-keys: |
157+
${{ runner.os }}-docker-e2e-
158+
159+
- name: Build test runner image
160+
uses: docker/build-push-action@v5
161+
with:
162+
context: e2e
163+
file: e2e/Dockerfile.tests
164+
push: false
165+
load: true
166+
tags: e2e-tests:latest
167+
cache-from: type=local,src=/tmp/.buildx-cache
168+
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
169+
170+
- name: Move Docker cache
171+
run: |
172+
rm -rf /tmp/.buildx-cache
173+
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
174+
175+
- name: Build BanManager Fabric
176+
working-directory: BanManager
177+
run: ./gradlew :fabric:${{ matrix.mc_version }}:remapJar --build-cache
178+
179+
- name: Run E2E tests
180+
run: ./gradlew :BanManagerWebEnhancerE2E:testFabric_${{ matrix.task_suffix }} --build-cache -PbanManagerPath=BanManager
181+
timeout-minutes: 15
182+
env:
183+
MC_VERSION: ${{ matrix.mc_version }}
184+
JAVA_IMAGE: ${{ matrix.java_image }}
185+
FABRIC_LOADER: ${{ matrix.fabric_loader }}
186+
187+
- name: Collect logs on failure
188+
if: failure()
189+
working-directory: e2e/platforms/fabric
190+
run: |
191+
docker compose logs > ../../e2e-logs-${{ matrix.mc_version }}.txt 2>&1 || true
192+
env:
193+
MC_VERSION: ${{ matrix.mc_version }}
194+
JAVA_IMAGE: ${{ matrix.java_image }}
195+
FABRIC_LOADER: ${{ matrix.fabric_loader }}
196+
197+
- name: Upload logs on failure
198+
if: failure()
199+
uses: actions/upload-artifact@v4
200+
with:
201+
name: e2e-logs-${{ matrix.mc_version }}
202+
path: e2e-logs-${{ matrix.mc_version }}.txt
203+
retention-days: 7
204+
205+
- name: Cleanup
206+
if: always()
207+
working-directory: e2e/platforms/fabric
208+
run: docker compose down -v || true
209+
env:
210+
MC_VERSION: ${{ matrix.mc_version }}
211+
JAVA_IMAGE: ${{ matrix.java_image }}
212+
FABRIC_LOADER: ${{ matrix.fabric_loader }}

.gitignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,17 @@ build
2222
target
2323
/dependency-reduced-pom.xml
2424
*-private.sh
25+
*.txt
26+
27+
# E2E Tests (Node.js)
28+
e2e/tests/node_modules/
29+
e2e/tests/dist/
30+
e2e/tests/*.log
31+
e2e/tests/coverage/
32+
e2e/jars/
33+
34+
dependency-reduced-pom.xml
35+
36+
# Fabric/Loom
37+
.gradle/loom-cache/
38+
run/

buildSrc/build.gradle.kts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@ repositories {
1010
name = "sponge"
1111
url = uri("https://repo.spongepowered.org/repository/maven-public/")
1212
}
13+
maven {
14+
name = "Fabric"
15+
url = uri("https://maven.fabricmc.net/")
16+
}
1317
}
1418

1519
dependencies {
1620
implementation(gradleApi())
17-
implementation("com.github.jengelman.gradle.plugins:shadow:6.1.0")
18-
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:4.21.0")
21+
implementation("com.gradleup.shadow:com.gradleup.shadow.gradle.plugin:9.0.0-beta4")
22+
implementation("org.jfrog.buildinfo:build-info-extractor-gradle:5.2.5")
1923
implementation("org.spongepowered:spongegradle-plugin-development:2.0.0")
20-
}
24+
implementation("fabric-loom:fabric-loom.gradle.plugin:1.9.2")
25+
}

buildSrc/src/main/kotlin/CommonConfig.kt

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,17 @@ fun Project.applyCommonConfiguration() {
1111
mavenLocal()
1212
mavenCentral()
1313
maven { url = uri("https://repo.codemc.io/repository/maven-public/") }
14-
maven { url = uri("https://s01.oss.sonatype.org/content/repositories/snapshots") }
14+
// Central Portal snapshot repository (OSSRH sunset June 2025)
15+
maven { url = uri("https://central.sonatype.com/repository/maven-snapshots/") }
1516
maven { url = uri("https://ci.frostcast.net/plugin/repository/everything") }
1617
}
1718

1819
dependencies {
19-
"compileOnly"("org.projectlombok:lombok:1.18.22")
20-
"annotationProcessor"("org.projectlombok:lombok:1.18.22")
20+
"compileOnly"("org.projectlombok:lombok:1.18.36")
21+
"annotationProcessor"("org.projectlombok:lombok:1.18.36")
2122

22-
"testCompileOnly"("org.projectlombok:lombok:1.18.22")
23-
"testAnnotationProcessor"("org.projectlombok:lombok:1.18.22")
23+
"testCompileOnly"("org.projectlombok:lombok:1.18.36")
24+
"testAnnotationProcessor"("org.projectlombok:lombok:1.18.36")
2425
}
2526

2627
configurations.all {
@@ -29,8 +30,12 @@ fun Project.applyCommonConfiguration() {
2930
}
3031
}
3132

33+
// Only set Java 1.8 for non-Fabric modules
34+
// Fabric uses toolchain configuration in its build.gradle.kts
3235
plugins.withId("java") {
33-
the<JavaPluginExtension>().setSourceCompatibility("1.8")
34-
the<JavaPluginExtension>().setTargetCompatibility("1.8")
36+
if (!plugins.hasPlugin("fabric-loom")) {
37+
the<JavaPluginExtension>().setSourceCompatibility("1.8")
38+
the<JavaPluginExtension>().setTargetCompatibility("1.8")
39+
}
3540
}
3641
}

buildSrc/src/main/kotlin/LibsConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import javax.inject.Inject
2121
fun Project.applyLibrariesConfiguration() {
2222
apply(plugin = "java-base")
2323
apply(plugin = "maven-publish")
24-
apply(plugin = "com.github.johnrengelman.shadow")
24+
apply(plugin = "com.gradleup.shadow")
2525
apply(plugin = "com.jfrog.artifactory")
2626

2727
repositories {

buildSrc/src/main/kotlin/PlatformConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fun Project.applyPlatformAndCoreConfiguration() {
5858
}
5959

6060
fun Project.applyShadowConfiguration() {
61-
apply(plugin = "com.github.johnrengelman.shadow")
61+
apply(plugin = "com.gradleup.shadow")
6262
tasks.named<ShadowJar>("shadowJar") {
6363
archiveClassifier.set("dist")
6464
dependencies {

0 commit comments

Comments
 (0)