Skip to content

Commit cdb9c20

Browse files
committed
Added example Fabric project
1 parent 4f30e5a commit cdb9c20

File tree

14 files changed

+619
-0
lines changed

14 files changed

+619
-0
lines changed

.github/workflows/build.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Automatically build the project and run any configured tests for every push
2+
# and submitted pull request. This can help catch issues that only occur on
3+
# certain platforms or Java versions, and provides a first line of defence
4+
# against bad commits.
5+
6+
name: build
7+
on: [pull_request, push]
8+
9+
jobs:
10+
build:
11+
strategy:
12+
matrix:
13+
# Use these Java versions
14+
java: [
15+
17, # Current Java LTS & minimum supported by Minecraft
16+
]
17+
# and run on both Linux and Windows
18+
os: [ubuntu-22.04, windows-2022]
19+
runs-on: ${{ matrix.os }}
20+
steps:
21+
- name: checkout repository
22+
uses: actions/checkout@v3
23+
- name: validate gradle wrapper
24+
uses: gradle/wrapper-validation-action@v1
25+
- name: setup jdk ${{ matrix.java }}
26+
uses: actions/setup-java@v3
27+
with:
28+
java-version: ${{ matrix.java }}
29+
distribution: 'microsoft'
30+
- name: make gradle wrapper executable
31+
if: ${{ runner.os != 'Windows' }}
32+
run: chmod +x ./gradlew
33+
- name: build
34+
run: ./gradlew build
35+
- name: capture build artifacts
36+
if: ${{ runner.os == 'Linux' && matrix.java == '17' }} # Only upload artifacts built from latest java on one OS
37+
uses: actions/upload-artifact@v3
38+
with:
39+
name: Artifacts
40+
path: build/libs/

.gitignore

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# gradle
2+
3+
.gradle/
4+
build/
5+
out/
6+
classes/
7+
8+
# eclipse
9+
10+
*.launch
11+
12+
# idea
13+
14+
.idea/
15+
*.iml
16+
*.ipr
17+
*.iws
18+
19+
# vscode
20+
21+
.settings/
22+
.vscode/
23+
bin/
24+
.classpath
25+
.project
26+
27+
# macos
28+
29+
*.DS_Store
30+
31+
# fabric
32+
33+
run/
34+
35+
# java
36+
37+
hs_err_*.log
38+
replay_*.log
39+
*.hprof
40+
*.jfr

build.gradle

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
plugins {
2+
id 'fabric-loom' version '1.2-SNAPSHOT'
3+
id 'maven-publish'
4+
}
5+
6+
version = project.mod_version
7+
group = project.maven_group
8+
9+
repositories {
10+
// Add repositories to retrieve artifacts from in here.
11+
// You should only use this when depending on other mods because
12+
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
13+
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
14+
// for more information about repositories.
15+
}
16+
17+
dependencies {
18+
// To change the versions see the gradle.properties file
19+
minecraft "com.mojang:minecraft:${project.minecraft_version}"
20+
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
21+
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
22+
23+
// Fabric API. This is technically optional, but you probably want it anyway.
24+
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
25+
26+
// Uncomment the following line to enable the deprecated Fabric API modules.
27+
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
28+
29+
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
30+
}
31+
32+
base {
33+
archivesName = project.archives_base_name
34+
}
35+
36+
processResources {
37+
inputs.property "version", project.version
38+
39+
filesMatching("fabric.mod.json") {
40+
expand "version": project.version
41+
}
42+
}
43+
44+
tasks.withType(JavaCompile).configureEach {
45+
// Minecraft 1.18 (1.18-pre2) upwards uses Java 17.
46+
it.options.release = 17
47+
}
48+
49+
java {
50+
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
51+
// if it is present.
52+
// If you remove this line, sources will not be generated.
53+
withSourcesJar()
54+
55+
sourceCompatibility = JavaVersion.VERSION_17
56+
targetCompatibility = JavaVersion.VERSION_17
57+
}
58+
59+
jar {
60+
from("LICENSE") {
61+
rename { "${it}_${base.archivesName.get()}"}
62+
}
63+
}
64+
65+
// configure the maven publication
66+
publishing {
67+
publications {
68+
mavenJava(MavenPublication) {
69+
from components.java
70+
}
71+
}
72+
73+
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
74+
repositories {
75+
// Add repositories to publish to here.
76+
// Notice: This block does NOT have the same function as the block in the top level.
77+
// The repositories here will be used for publishing your artifact, not for
78+
// retrieving dependencies.
79+
}
80+
}

gradle.properties

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Done to increase the memory available to gradle.
2+
org.gradle.jvmargs=-Xmx1G
3+
org.gradle.parallel=true
4+
5+
# Fabric Properties
6+
# check these on https://fabricmc.net/develop
7+
minecraft_version=1.19.4
8+
yarn_mappings=1.19.4+build.2
9+
loader_version=0.14.19
10+
11+
# Mod Properties
12+
mod_version = 1.0.0
13+
maven_group = com.example
14+
archives_base_name = fabric-example-mod
15+
16+
# Dependencies
17+
fabric_version=0.79.0+1.19.4

gradle/wrapper/gradle-wrapper.jar

60.6 KB
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
4+
networkTimeout=10000
5+
zipStoreBase=GRADLE_USER_HOME
6+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)