Skip to content

Commit 006f331

Browse files
committed
Build with Preprocessor.
1 parent faea06f commit 006f331

File tree

61 files changed

+782
-204
lines changed

Some content is hidden

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

61 files changed

+782
-204
lines changed

.github/workflows/build.yml

+9-7
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,16 @@ jobs:
4040
- name: build
4141
if: ${{ !startsWith(github.event.head_commit.message, '[ci skip]') }}
4242
run: ./gradlew build
43+
- name: collect artifacts to out folder
44+
run: |
45+
mkdir out
46+
mv ./versions/1.17.1/build/libs/* ./out
47+
mv ./versions/1.18.2/build/libs/* ./out
48+
mv ./versions/1.19.3/build/libs/* ./out
49+
mv ./versions/1.20.1/build/libs/* ./out
4350
- name: capture build artifacts
44-
if: ${{ runner.os == 'Linux' && matrix.java == '17' && !startsWith(github.event.head_commit.message, '[ci skip]') }} # Only upload artifacts built from the latest java on one OS
51+
if: ${{ runner.os == 'Linux' && matrix.java == '17' && !startsWith(github.event.head_commit.message, '[ci skip]') }}
4552
uses: actions/upload-artifact@v3.1.2
4653
with:
4754
name: Artifacts
48-
path: build/libs/
49-
- name: upload to modrinth
50-
if: ${{ runner.os == 'Linux' && matrix.java == '17' && startsWith(github.event.head_commit.message, 'update mod version to ') && startsWith(github.ref_type, 'branch') }}
51-
run: ./gradlew modrinth
52-
env:
53-
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
55+
path: out/

.gitignore

+11
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,14 @@ bin/
3232
# fabric
3333

3434
run/
35+
36+
# preprocessor
37+
38+
versions/1.17.1/.gradle
39+
versions/1.17.1/build
40+
versions/1.18.2/.gradle
41+
versions/1.18.2/build
42+
versions/1.19.3/.gradle
43+
versions/1.19.3/build
44+
versions/1.20.1/.gradle
45+
versions/1.20.1/build

README-en.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Language: English | [中文](https://github.com/OptiJava/OptCarpetAddition/blob/
55
This is an extension module of CarpetMod. The goal is to add some functions that do not greatly change the original game
66
mechanism but optimize the player experience/~~reduce the blood pressure of server owner~~.
77

8+
Build with [Preprocessor](https://github.com/ReplayMod/preprocessor)
9+
810
**Dependencies:`Carpet` `fabric-api`**
911

1012
## Rules

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ Language: [English](https://github.com/OptiJava/OptCarpetAddition/blob/master/RE
44

55
这是一个CarpetMod的扩展模组,目标是添加一些没有太大改变原版游戏机制但优化玩家体验/~~降低腐竹血压~~的一些功能。
66

7+
使用[Preprocessor](https://github.com/ReplayMod/preprocessor)构建
8+
79
**本模组需要前置:`Carpet` `fabric-api`**
810

911
**使用前一定仔细阅读README.md!!!!**

build.gradle

100755100644
+11-112
Original file line numberDiff line numberDiff line change
@@ -1,119 +1,18 @@
11
plugins {
2-
id 'fabric-loom' version '1.2.7'
2+
id 'fabric-loom' version '1.3.8' apply false
33
id 'maven-publish'
4-
id "com.modrinth.minotaur" version "2.+"
4+
id "com.modrinth.minotaur" version "2.+" apply false
5+
id 'com.replaymod.preprocess' version '20c7ec554a'
56
}
67

7-
sourceCompatibility = JavaVersion.VERSION_16
8-
targetCompatibility = JavaVersion.VERSION_16
98

10-
archivesBaseName = project.archives_base_name
11-
version = 'v' + project.mod_version + '-1.17-' + new Date().format('yyMMddHHmmss')
12-
group = project.maven_group
9+
preprocess {
10+
def mc117 = createNode('1.17.1' , 1_17_01, 'yarn')
11+
def mc118 = createNode('1.18.2' , 1_18_02, 'yarn')
12+
def mc1193 = createNode('1.19.3' , 1_19_03, 'yarn')
13+
def mc1201 = createNode('1.20.1' , 1_20_01, 'yarn')
1314

14-
repositories {
15-
// Add repositories to retrieve artifacts from in here.
16-
// You should only use this when depending on other mods because
17-
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
18-
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
19-
// for more information about repositories.
20-
maven {
21-
name = "CurseMaven"
22-
url = "https://www.cursemaven.com"
23-
}
24-
25-
maven {
26-
name = "Modrinth"
27-
url = "https://api.modrinth.com/maven"
28-
}
29-
}
30-
31-
dependencies {
32-
// To change the versions see the gradle.properties file
33-
minecraft "com.mojang:minecraft:${project.minecraft_version}"
34-
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
35-
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
36-
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
37-
38-
modImplementation("curse.maven:carpet-349239:${project.carpet_core_version}")
39-
}
40-
41-
processResources {
42-
inputs.property "version", mod_version
43-
44-
filesMatching("fabric.mod.json") {
45-
expand "version": mod_version
46-
}
47-
}
48-
49-
tasks.withType(JavaCompile).configureEach {
50-
// Minecraft 1.17 (21w19a) upwards uses Java 16.
51-
it.options.release = 16
52-
}
53-
54-
loom {
55-
accessWidenerPath.set(file("src/main/resources/opt-carpet-addition.accesswidener"))
56-
}
57-
58-
java {
59-
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
60-
// if it is present.
61-
// If you remove this line, sources will not be generated.
62-
withSourcesJar()
63-
}
64-
65-
jar {
66-
from("LICENSE") {
67-
rename { "${it}_${archivesBaseName}" }
68-
}
69-
}
70-
71-
modrinth {
72-
// Token
73-
token = System.getenv("MODRINTH_TOKEN")
74-
75-
// Project ID
76-
projectId = "opt-carpet-addition"
77-
78-
// Version
79-
if (project.mod_version.contains("alpha")) {
80-
versionType = "alpha"
81-
} else if (project.mod_version.contains("beta")) {
82-
versionType = "beta"
83-
} else {
84-
versionType = "release"
85-
}
86-
gameVersions = ["1.17", "1.17.1"] // Must be an array, even with only one version
87-
versionNumber = project.mod_version
88-
versionName = "v" + project.mod_version + " For Minecraft 1.17"
89-
90-
// Upload
91-
uploadFile = remapJar
92-
93-
// Loader
94-
loaders = ["fabric"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
95-
96-
// Dependencies
97-
dependencies {
98-
required.project "fabric-api"
99-
}
100-
101-
// ChangeLogs
102-
changelog = "Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases)."
103-
}
104-
105-
// configure the maven publication
106-
publishing {
107-
publications {
108-
mavenJava(MavenPublication) {
109-
from components.java
110-
}
111-
}
112-
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
113-
repositories {
114-
// Add repositories to publish to here.
115-
// Notice: This block does NOT have the same function as the block in the top level.
116-
// The repositories here will be used for publishing your artifact, not for
117-
// retrieving dependencies.
118-
}
15+
mc117 .link(mc118, null)
16+
mc118 .link(mc1193, null)
17+
mc1193.link(mc1201, null)
11918
}

common.gradle

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
// plugins
2+
apply plugin: 'fabric-loom'
3+
apply plugin: 'maven-publish'
4+
apply plugin: 'com.replaymod.preprocess'
5+
apply plugin: 'com.modrinth.minotaur'
6+
7+
8+
archivesBaseName = project.archives_base_name // in central gradle.properties
9+
10+
version = 'v' + project.mod_version + '-' + project.minecraft_version + '-' + new Date().format('yyMMddHHmmss')
11+
def simple_version = 'v' + project.mod_version
12+
13+
group = project.maven_group
14+
15+
16+
if (project.mcVersion >= 11800) {
17+
sourceCompatibility = JavaVersion.VERSION_17
18+
targetCompatibility = JavaVersion.VERSION_17
19+
} else if (project.mcVersion >= 11700) {
20+
sourceCompatibility = JavaVersion.VERSION_16
21+
targetCompatibility = JavaVersion.VERSION_16
22+
}
23+
24+
25+
repositories {
26+
maven {
27+
url 'https://jitpack.io'
28+
}
29+
maven {
30+
url 'https://www.cursemaven.com'
31+
}
32+
33+
maven {
34+
name = "Modrinth"
35+
url = "https://api.modrinth.com/maven"
36+
}
37+
}
38+
39+
40+
// https://github.com/FabricMC/fabric-loader/issues/783
41+
configurations {
42+
modRuntimeOnly.exclude group: 'net.fabricmc', module: 'fabric-loader'
43+
}
44+
45+
46+
dependencies {
47+
// loom
48+
minecraft "com.mojang:minecraft:${project.minecraft_version}"
49+
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
50+
51+
// loader
52+
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}" // in central gradle.properties
53+
54+
// mods
55+
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
56+
modImplementation("curse.maven:carpet-349239:${project.carpet_core_version}")
57+
}
58+
59+
60+
processResources {
61+
from "opt-carpet-addition.accesswidener"
62+
63+
inputs.property "version", simple_version
64+
inputs.property "minecraft_requirement_version", project.minecraft_requirement_version
65+
inputs.property "carpet_requirement_version", project.carpet_requirement_version
66+
67+
filesMatching("fabric.mod.json") {
68+
def valueMap = [
69+
"version": simple_version,
70+
"carpet_requirement_version": project.carpet_requirement_version,
71+
"minecraft_requirement_version": project.minecraft_requirement_version,
72+
]
73+
expand valueMap
74+
}
75+
}
76+
77+
78+
tasks.withType(JavaCompile).configureEach {
79+
options.encoding = "UTF-8"
80+
}
81+
82+
83+
loom {
84+
accessWidenerPath.set(file("src/main/resources/opt-carpet-addition.accesswidener"))
85+
86+
runConfigs.configureEach {
87+
// to make sure it generates all "Minecraft Client (:subproject_name)" applications
88+
ideConfigGenerated = true
89+
runDir '../../run'
90+
}
91+
}
92+
93+
remapJar {
94+
remapperIsolation = true
95+
}
96+
97+
98+
java {
99+
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
100+
// if it is present.
101+
// If you remove this line, sources will not be generated.
102+
withSourcesJar()
103+
}
104+
105+
106+
jar {
107+
from("LICENSE") {
108+
rename { "${it}_${archivesBaseName}" }
109+
}
110+
}
111+
112+
// Publish to modrinth
113+
modrinth {
114+
// Token
115+
token = System.getenv("MODRINTH_TOKEN")
116+
117+
// Project ID
118+
projectId = "opt-carpet-addition"
119+
120+
// Version
121+
if (project.mod_version.contains("alpha")) {
122+
versionType = "alpha"
123+
} else if (project.mod_version.contains("beta")) {
124+
versionType = "beta"
125+
} else {
126+
versionType = "release"
127+
}
128+
gameVersions = ["1.17", "1.17.1"] // Must be an array, even with only one version
129+
versionNumber = project.mod_version
130+
versionName = "v" + project.mod_version + " For Minecraft 1.17"
131+
132+
// Upload
133+
uploadFile = remapJar
134+
135+
// Loader
136+
loaders = ["fabric"] // Must also be an array - no need to specify this if you're using Loom or ForgeGradle
137+
138+
// Dependencies
139+
dependencies {
140+
required.project "fabric-api"
141+
}
142+
143+
// ChangeLogs
144+
changelog = "Got full change logs in [GitHub](https://github.com/OptiJava/OptCarpetAddition/releases)."
145+
}

gradle.properties

+4-12
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
# Done to increase the memory available to gradle.
2-
org.gradle.jvmargs=-Xmx1096M
1+
org.gradle.jvmargs=-Xmx3g
32
org.gradle.parallel=true
4-
# Fabric Properties
5-
# check these on https://fabricmc.net/versions.html
6-
minecraft_version=1.17.1
7-
yarn_mappings=1.17.1+build.65
8-
loader_version=0.12.12
9-
# Mod Properties
3+
4+
loader_version=0.14.21
5+
106
mod_version=1.5.0+beta.1
117
maven_group=io.github.optijava
128
archives_base_name=opt-carpet-addition
13-
# Dependencies
14-
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api (or https://fabricmc.net/versions.html)
15-
fabric_version=0.42.1+1.17
16-
carpet_core_version=3613865
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)