Skip to content

Commit 00a948c

Browse files
Merge pull request #2 from OffsetMods538/1-support-paper
Support paper
2 parents dfe99d8 + b9cbd38 commit 00a948c

29 files changed

+336
-168
lines changed

.github/workflows/build_artifacts.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@ jobs:
2929
env:
3030
DISABLE_PROPERTIES_UPDATE: true
3131

32+
- name: Delete common libs
33+
run: rm -r ./common/build/libs
34+
3235
- name: Upload build artifacts
3336
uses: actions/upload-artifact@v4
3437
with:
3538
name: Artifacts
36-
path: build/libs/
39+
path: ./*/build/libs/

.github/workflows/publish.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ jobs:
4545
MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
4646
MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}
4747

48+
- name: Delete common libs
49+
run: rm -r ./common/build/libs
50+
4851
- name: Upload to GitHub
4952
uses: softprops/action-gh-release@v2
5053
with:
51-
files: build/libs/*.jar
54+
files: ./*/build/libs/*.jar

build.gradle

Lines changed: 72 additions & 139 deletions
Original file line numberDiff line numberDiff line change
@@ -1,168 +1,101 @@
11
import dex.plugins.outlet.v2.util.ReleaseType
22

33
plugins {
4-
id 'fabric-loom' version '1.8-SNAPSHOT'
5-
id 'io.github.dexman545.outlet' version '1.6.1'
6-
id 'com.modrinth.minotaur' version '2.+'
4+
id 'fabric-loom' version '1.9-SNAPSHOT' apply false
5+
id 'io.github.dexman545.outlet' version '1.6.1' apply false
6+
id 'com.modrinth.minotaur' version '2.+' apply false
77
id 'maven-publish'
88
}
99

10-
sourceCompatibility = JavaVersion.VERSION_17
11-
targetCompatibility = JavaVersion.VERSION_17
12-
13-
archivesBaseName = "mesh-lib"
14-
version = "${project.mod_version}+${project.minecraft_version}"
15-
group = "top.offsetmonkey538.meshlib"
16-
17-
outlet {
18-
maintainPropertiesFile = System.getenv("DISABLE_PROPERTIES_UPDATE") == null
19-
mcVersionRange = project.supported_minecraft_versions
20-
allowedReleaseTypes = Set.of(ReleaseType.RELEASE)
21-
propertiesData = [
22-
'yarn_version': outlet.yarnVersion(project.minecraft_version),
23-
'loader_version': outlet.loaderVersion()
24-
]
10+
ext {
11+
debugVersion = System.currentTimeMillis()
2512
}
2613

27-
28-
loom {
29-
runs {
30-
client {
31-
runDir "run/client"
32-
}
33-
server {
34-
runDir "run/server"
35-
}
36-
}
37-
}
38-
39-
// https://gist.github.com/maityyy/3dbcd558d58a6412c3a2a38c72706e8e
40-
afterEvaluate {
41-
loom.runs.configureEach {
42-
vmArg "-javaagent:${configurations.compileClasspath.find{ it.name.contains("sponge-mixin") }}"
43-
if (System.getenv("DISABLE_PROPERTIES_UPDATE") == null) vmArg "-Ddevauth.enabled=true"
44-
}
14+
allprojects {
15+
group = "top.offsetmonkey538.meshlib"
4516
}
4617

47-
configurations {
48-
includeModImplementation
49-
50-
include.extendsFrom includeModImplementation
51-
modImplementation.extendsFrom includeModImplementation
52-
53-
54-
includeImplementation
18+
subprojects {
19+
apply plugin: "maven-publish"
20+
apply plugin: "java"
21+
apply plugin: "java-library"
5522

56-
include.extendsFrom includeImplementation
57-
implementation.extendsFrom includeImplementation
23+
archivesBaseName = "mesh-lib-${project.nameSuffix}"
24+
version = "${rootProject.mod_version}+${rootProject.minecraft_version}"
5825

26+
tasks.named("javadoc", Javadoc) {
27+
options.addFileOption('-add-stylesheet', rootProject.file("javadoc-stylesheet.css"))
28+
}
5929

60-
includeApi
61-
62-
include.extendsFrom includeApi
63-
api.extendsFrom includeApi
64-
}
30+
java {
31+
withSourcesJar()
32+
withJavadocJar()
33+
}
6534

66-
repositories {
67-
mavenCentral()
68-
mavenLocal()
69-
maven {
70-
name = "DevAuth"
71-
url = "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1"
72-
content {
73-
includeGroup "me.djtheredstoner"
35+
jar {
36+
from("${rootProject.projectDir}/LICENSE") {
37+
rename { "${it}" }
7438
}
7539
}
76-
}
77-
78-
dependencies {
79-
minecraft "com.mojang:minecraft:${project.minecraft_version}"
80-
mappings "net.fabricmc:yarn:${project.yarn_version}:v2"
81-
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
82-
83-
// DevAuth
84-
modLocalRuntime "me.djtheredstoner:DevAuth-fabric:${devauth_version}"
85-
86-
// Netty
87-
includeApi "io.netty:netty-codec-http:${project.netty_version}"
88-
89-
// Uncomment for including a module of fabric api
90-
// includeModImplementation fabricApi.module("fabric-api-base", project.fapi_version)
91-
}
9240

93-
processResources {
94-
final Map properties = Map<String, String>.of(
95-
"modVersion", project.mod_version,
96-
"supportedMinecraftVersions", project.supported_minecraft_versions
97-
)
98-
99-
inputs.properties(properties)
100-
101-
filesMatching("fabric.mod.json") {
102-
expand(properties)
41+
dependencies {
42+
compileOnly "org.jetbrains:annotations:24.0.0"
43+
compileOnly "org.slf4j:slf4j-api:2.0.16"
10344
}
10445

105-
exclude ".cache/**"
106-
}
107-
108-
tasks.withType(JavaCompile).configureEach {
109-
it.options.release = 17
110-
}
111-
112-
java {
113-
withSourcesJar()
114-
withJavadocJar()
115-
}
116-
117-
tasks.named("javadoc", Javadoc) {
118-
options.addFileOption('-add-stylesheet', project.file("javadoc-stylesheet.css"))
119-
}
46+
publishing {
47+
repositories {
48+
maven {
49+
name = "OffsetMonkey538"
50+
url = "https://maven.offsetmonkey538.top/releases"
51+
credentials {
52+
username = providers.gradleProperty("OffsetMonkey538Username").getOrElse(System.getenv("MAVEN_USERNAME"))
53+
password = providers.gradleProperty("OffsetMonkey538Password").getOrElse(System.getenv("MAVEN_PASSWORD"))
54+
}
55+
authentication {
56+
basic(BasicAuthentication)
57+
}
58+
}
59+
}
60+
publications {
61+
maven(MavenPublication) {
62+
artifactId = project.archivesBaseName
12063

121-
jar {
122-
from("LICENSE") {
123-
rename { "${it}_${project.archivesBaseName}" }
64+
from(components["java"])
65+
}
66+
}
67+
}
68+
tasks.publishMavenPublicationToMavenLocal.doLast {
69+
if (System.getenv("IS_DEBUG") == "true") System.out.println("Version: " + version)
12470
}
12571
}
12672

127-
modrinth {
128-
token = System.getenv("MODRINTH_TOKEN")
129-
projectId = "mesh-lib"
130-
def customVersionName = System.getenv("VERSION_NAME")
131-
if (customVersionName != null) versionName = customVersionName
132-
versionNumber = "${project.version}"
133-
versionType = "alpha"
134-
def isPreRelease = System.getenv("VERSION_IS_PRERELEASE")
135-
versionType = !"false".equals(isPreRelease) ? "beta" : "release"
136-
uploadFile = remapJar.archiveFile
137-
//additionalFiles = [sourcesJar.archiveFile, javadocJar.archiveFile]
138-
additionalFiles = [sourcesJar.archiveFile]
139-
gameVersions = outlet.mcVersions()
140-
syncBodyFrom = rootProject.file("README.md").text
141-
def changelogEnv = System.getenv("VERSION_CHANGELOG")
142-
if (changelogEnv != null) changelog = changelogEnv
143-
}
73+
configure(subprojects.findAll { it.name != "common" }) {
74+
apply plugin: 'com.modrinth.minotaur'
75+
apply plugin: 'io.github.dexman545.outlet'
14476

145-
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
77+
if (System.getenv("IS_DEBUG") == "true") version = "${version}-${rootProject.debugVersion}"
14678

147-
publishing {
148-
repositories {
149-
maven {
150-
name = "OffsetMonkey538"
151-
url = "https://maven.offsetmonkey538.top/releases"
152-
credentials {
153-
username = providers.gradleProperty("OffsetMonkey538Username").getOrElse(System.getenv("MAVEN_USERNAME"))
154-
password = providers.gradleProperty("OffsetMonkey538Password").getOrElse(System.getenv("MAVEN_PASSWORD"))
155-
}
156-
authentication {
157-
basic(BasicAuthentication)
158-
}
159-
}
79+
outlet {
80+
mcVersionRange = rootProject.supported_minecraft_versions
81+
allowedReleaseTypes = Set.of(ReleaseType.RELEASE)
16082
}
161-
publications {
162-
maven(MavenPublication) {
163-
artifactId = "mesh-lib"
16483

165-
from(components["java"])
166-
}
84+
modrinth {
85+
token = System.getenv("MODRINTH_TOKEN")
86+
projectId = "mesh-lib"
87+
def customVersionName = System.getenv("VERSION_NAME")
88+
if (customVersionName != null) versionName = customVersionName
89+
versionNumber = "${project.version}"
90+
versionType = "alpha"
91+
def isPreRelease = System.getenv("VERSION_IS_PRERELEASE")
92+
versionType = !"false".equals(isPreRelease) ? "beta" : "release"
93+
additionalFiles = [sourcesJar.archiveFile]
94+
gameVersions = outlet.mcVersions()
95+
syncBodyFrom = rootProject.file("README.md").text
96+
def changelogEnv = System.getenv("VERSION_CHANGELOG")
97+
if (changelogEnv != null) changelog = changelogEnv
16798
}
99+
100+
tasks.modrinth.dependsOn(tasks.modrinthSyncBody)
168101
}

common/build.gradle

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
plugins {
2+
id 'com.gradleup.shadow' version '9.0.0-beta4'
3+
id 'maven-publish'
4+
}
5+
6+
repositories {
7+
mavenCentral()
8+
}
9+
10+
dependencies {
11+
// Netty
12+
api "io.netty:netty-codec-http:${project.netty_version}"
13+
}
14+
15+
processResources {
16+
final Map properties = Map<String, String>.of(
17+
"modVersion", project.mod_version,
18+
"supportedMinecraftVersions", project.supported_minecraft_versions
19+
)
20+
21+
inputs.properties(properties)
22+
23+
filesMatching("fabric.mod.json") {
24+
expand(properties)
25+
}
26+
27+
exclude ".cache/**"
28+
}

common/gradle.properties

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## Netty, only used for netty-codec-http. Hopefully this version won't conflict with other versions of Netty
2+
netty_version = 4.1.82.Final
3+
4+
5+
nameSuffix = api

src/main/java/top/offsetmonkey538/meshlib/api/HttpHandler.java renamed to common/src/main/java/top/offsetmonkey538/meshlib/api/HttpHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import io.netty.handler.codec.http.FullHttpResponse;
1010
import io.netty.handler.codec.http.HttpResponseStatus;
1111
import io.netty.util.CharsetUtil;
12+
import top.offsetmonkey538.meshlib.example.SimpleHttpHandler;
1213
import org.jetbrains.annotations.NotNull;
1314
import org.jetbrains.annotations.Nullable;
1415

@@ -23,7 +24,7 @@
2324
* <br>
2425
* For example {@link #sendError(ChannelHandlerContext, HttpResponseStatus)} {@link #sendError(ChannelHandlerContext, HttpResponseStatus, String)}
2526
* <p>
26-
* Look at {@link top.offsetmonkey538.meshlib.example.SimpleHttpHandler SimpleHttpHandler} for an example
27+
* Look at {@link SimpleHttpHandler SimpleHttpHandler} for an example
2728
*
2829
* @see HttpHandlerRegistry
2930
*/

src/main/java/top/offsetmonkey538/meshlib/example/ExampleMain.java renamed to common/src/main/java/top/offsetmonkey538/meshlib/example/ExampleMain.java

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,25 @@
11
package top.offsetmonkey538.meshlib.example;
22

3-
import net.fabricmc.api.DedicatedServerModInitializer;
43
import top.offsetmonkey538.meshlib.api.HttpHandlerRegistry;
54

65
import static top.offsetmonkey538.meshlib.MESHLib.LOGGER;
76

87
/**
9-
* Mod initializer for the example handlers
8+
* Initializer for the example handlers
9+
* <p>
10+
* Called from either the plugin initializer {@code MeshLibPlugin} or defined as an entrypoint in the {@code fabric.mod.json} file
1011
*/
11-
public class ExampleMain implements DedicatedServerModInitializer {
12+
public final class ExampleMain {
13+
private ExampleMain() {
14+
15+
}
1216

1317
/**
1418
* Initializer for example handlers
1519
* <br>
16-
* Checks if {@code meshEnableExamples} is enabled and registers the example handlers if so
20+
* Checks if the {@code meshEnableExamples} system property is enabled and registers the example handlers if so
1721
*/
18-
@Override
19-
public void onInitializeServer() {
22+
public static void onInitialize() {
2023
// Ignore if "meshEnableExamples" isn't set
2124
if (System.getProperty("meshEnableExamples", "").isEmpty()) return;
2225

0 commit comments

Comments
 (0)