Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ jobs:
cache-read-only: ${{ github.ref != 'refs/heads/main' }}
- name: Build with Gradle
run: ./gradlew build
- name: Check platform compatibility modules
run: ./gradlew checkPlatformCompat
- name: Test with Gradle
run: ./gradlew test
2 changes: 1 addition & 1 deletion .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ jobs:
env:
REPOSITORY_USER: ${{ secrets.REPOSITORY_USER }}
REPOSITORY_TOKEN: ${{ secrets.REPOSITORY_TOKEN }}
run: ./gradlew publish
run: ./gradlew publish publishPlatformCompat
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,23 @@ Use `build` for the reusable FastStats libraries:
./gradlew :config:build
./gradlew :bukkit:build
./gradlew :bungeecord:build
./gradlew :fabric:build
./gradlew :fabric:versions:26.1-26.3:build
./gradlew :hytale:build
./gradlew :minestom:build
./gradlew :neoforge:versions:26.1:build
./gradlew :nukkit:build
./gradlew :sponge:build
./gradlew :velocity:build
```

Library jars are written to each module's `build/libs` directory. Fabric also produces a remapped jar through Fabric Loom as part of its build output.
Library jars are written to each module's `build/libs` directory. Fabric and NeoForge publish compatibility modules, such as `fabric:versions:26.1` and `neoforge:versions:26.1`, under stable Maven artifact IDs with Minecraft range suffixes:

```text
dev.faststats.metrics:fabric:<sdk-version>+mc26.1-26.2
dev.faststats.metrics:neoforge:<sdk-version>+mc26.1-26.2
```

The `fabric` and `neoforge` modules contain shared platform code and are not published directly.

### Bukkit, BungeeCord, Hytale, Minestom, Nukkit, Sponge, and Velocity examples

Expand Down Expand Up @@ -60,3 +68,11 @@ To compile and test all modules with the standard lifecycle, run:
```

For deployable example artifacts, run the platform-specific commands above after `build` or instead of it.

### Platform compatibility checks

Compile all published platform compatibility modules with:

```sh
./gradlew checkPlatformCompat
```
80 changes: 39 additions & 41 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,25 @@ plugins {
kotlin("jvm") version "2.4.20-Beta1" apply false
}

val javaVersionsOverride = mapOf(
":bukkit" to 21,
":bukkit:example-plugin" to 21,
":fabric" to 25,
":fabric:example-mod" to 25,
":hytale" to 25,
":hytale:example-plugin" to 25,
":minestom" to 25,
":minestom:example-server" to 25,
":neoforge" to 25,
":neoforge:example-mod" to 25,
":velocity" to 21,
":velocity:example-plugin" to 21
)
val defaultJavaVersion = 17

subprojects {
apply {
plugin("java")
plugin("java-library")
}

val example = project.name.startsWith("example")
if (example) {
apply { plugin("org.jetbrains.kotlin.jvm") }
if (project.path != ":fabric:example-mod" && project.path != ":neoforge:example-mod") {
apply { plugin("com.gradleup.shadow") }
}
} else {
apply { plugin("maven-publish") }
}

group = "dev.faststats.metrics"

repositories {
mavenCentral()
}

val javaVersion = javaVersionsOverride[project.path] ?: defaultJavaVersion

extensions.configure<JavaPluginExtension> {
toolchain.languageVersion = JavaLanguageVersion.of(javaVersion)
withSourcesJar()
withJavadocJar()
}

tasks.compileJava {
options.release.set(javaVersion)
}

val generateFastStatsProperties by tasks.registering {
val generateFastStatsProperties = tasks.register("generateFastStatsProperties") {
description = "Generates the META-INF/faststats.properties file"
val outputDir = layout.buildDirectory.dir("generated/resources/faststats")
outputs.dir(outputDir)
doLast {
Expand All @@ -76,20 +44,24 @@ subprojects {
}
}

fun ownProperty(name: String): String? {
return if (extensions.extraProperties.has(name)) extensions.extraProperties.get(name).toString() else null
}

tasks.withType<JavaCompile>().configureEach {
project.findProperty("moduleName")?.let { moduleName ->
ownProperty("moduleName")?.let { moduleName ->
options.compilerArgs.addAll(listOf("--add-reads", "$moduleName=ALL-UNNAMED"))
}
}

tasks.withType<Test>().configureEach {
project.findProperty("moduleName")?.let { moduleName ->
ownProperty("moduleName")?.let { moduleName ->
jvmArgs("--add-reads", "$moduleName=ALL-UNNAMED")
}
}

tasks.withType<JavaExec>().configureEach {
project.findProperty("moduleName")?.let { moduleName ->
ownProperty("moduleName")?.let { moduleName ->
jvmArgs("--add-reads", "$moduleName=ALL-UNNAMED")
}
}
Expand All @@ -101,20 +73,33 @@ subprojects {
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"
)
project.findProperty("moduleName")?.let { moduleName ->
ownProperty("moduleName")?.let { moduleName ->
options.addStringOption("-add-reads", "$moduleName=ALL-UNNAMED")
}
}

afterEvaluate {
if (example) return@afterEvaluate
val publishArtifactId = ownProperty("publishArtifactId")
if (!plugins.hasPlugin("maven-publish") && publishArtifactId == null) return@afterEvaluate
if (!plugins.hasPlugin("maven-publish") || publishArtifactId == null) throw IllegalStateException(
"Invalid publishing setup for project \"${project.path}\", " +
"maven-publish: ${plugins.hasPlugin("maven-publish")}, publishArtifactId: $publishArtifactId"
)

ownProperty("publishVersionSuffix")?.let { suffix ->
version = "${rootProject.version}+$suffix"
}

extensions.configure<PublishingExtension> {
publications.create<MavenPublication>("maven") {
artifactId = project.name
artifactId = publishArtifactId
groupId = "dev.faststats.metrics"

pom {
url.set("https://faststats.dev/docs")
url.set(
ownProperty("publishDocsUrl")
?: throw IllegalStateException("No docs URL provided by \"${project.path}\"")
)
scm {
val repository = "faststats-dev/faststats-java"
url.set("https://github.com/$repository")
Expand All @@ -139,3 +124,16 @@ subprojects {
}
}
}

// todo: automate dependsOn
tasks.register("checkPlatformCompat") {
group = "verification"
description = "Compiles all platform compatibility modules."
dependsOn(":fabric:versions:26.1-26.3:compileJava", ":neoforge:versions:26.1:compileJava")
}

tasks.register("publishPlatformCompat") {
group = "publishing"
description = "Publishes all platform compatibility modules."
dependsOn(":fabric:versions:26.1-26.3:publish", ":neoforge:versions:26.1:publish")
}
17 changes: 12 additions & 5 deletions bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
repositories {
maven("https://repo.papermc.io/repository/maven-public/")
extra.set("publishArtifactId", "bukkit")
extra.set("publishDocsUrl", "https://docs.faststats.dev/java/platform/bukkit")

plugins {
id("maven-publish")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(25)

tasks.compileJava {
options.release.set(17)
}

configurations.compileClasspath {
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 21)
}
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 25)
}

repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}

dependencies {
Expand Down
13 changes: 12 additions & 1 deletion bukkit/example-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
plugins {
id("com.gradleup.shadow")
kotlin("jvm")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(25)

tasks.compileJava {
options.release.set(25)
}

repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}

dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
compileOnly("io.papermc.paper:paper-api:26.2.build.+")
implementation(project(":bukkit"))
}

Expand Down
14 changes: 13 additions & 1 deletion bungeecord/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
val moduleName by extra("dev.faststats.bungee")
extra.set("moduleName", "dev.faststats.bungee")
extra.set("publishArtifactId", "bungeecord")
extra.set("publishDocsUrl", "https://docs.faststats.dev/java/platform/bungeecord")

plugins {
id("maven-publish")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

tasks.compileJava {
options.release.set(17)
}

repositories {
maven("https://repo.papermc.io/repository/maven-public/")
Expand Down
11 changes: 11 additions & 0 deletions bungeecord/example-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
plugins {
id("com.gradleup.shadow")
kotlin("jvm")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

tasks.compileJava {
options.release.set(17)
}

repositories {
maven("https://repo.papermc.io/repository/maven-public/")
}
Expand Down
13 changes: 13 additions & 0 deletions config/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
extra.set("publishArtifactId", "config")
extra.set("publishDocsUrl", "https://docs.faststats.dev/java") // todo: add dedicated docs

plugins {
id("maven-publish")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

tasks.compileJava {
options.release.set(17)
}

dependencies {
compileOnly(project(":core"))
}
13 changes: 13 additions & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
extra.set("publishArtifactId", "core")
extra.set("publishDocsUrl", "https://docs.faststats.dev/java") // todo: add dedicated docs

plugins {
id("maven-publish")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

tasks.compileJava {
options.release.set(17)
}

dependencies {
compileOnlyApi("com.google.code.gson:gson:2.14.0")
compileOnlyApi("org.jetbrains:annotations:26.1.0")
Expand Down
11 changes: 11 additions & 0 deletions core/example/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
plugins {
id("com.gradleup.shadow")
kotlin("jvm")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(17)

tasks.compileJava {
options.release.set(17)
}

dependencies {
implementation(project(":core"))
}
21 changes: 19 additions & 2 deletions fabric/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
val moduleName by extra("dev.faststats.fabric")
extra.set("moduleName", "dev.faststats.fabric")

plugins {
id("net.fabricmc.fabric-loom") version ("1.15-SNAPSHOT")
id("net.fabricmc.fabric-loom") version "1.15-SNAPSHOT"
}

java.toolchain.languageVersion = JavaLanguageVersion.of(25)

tasks.compileJava {
options.release.set(21)
}

configurations.compileClasspath {
attributes.attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 25)
}

allprojects {
if (project.name == "example-mod") return@allprojects
apply { plugin("maven-publish") }
extra.set("publishArtifactId", "fabric")
extra.set("publishDocsUrl", "https://docs.faststats.dev/java/platform/fabric")
}

dependencies {
Expand Down
14 changes: 11 additions & 3 deletions fabric/example-mod/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
plugins {
id("net.fabricmc.fabric-loom")
id("net.fabricmc.fabric-loom") version "1.15-SNAPSHOT"
kotlin("jvm")
}

java.toolchain.languageVersion = JavaLanguageVersion.of(25)

tasks.compileJava {
options.release.set(25)
}

dependencies {
implementation(project(":fabric"))
implementation(project(":fabric:versions:26.1-26.3"))
minecraft("com.mojang:minecraft:26.1.2")
implementation("net.fabricmc.fabric-api:fabric-api:0.150.0+26.1.2")
compileOnly("net.fabricmc:fabric-loader:0.19.3")
Expand All @@ -14,4 +21,5 @@ tasks.jar {
from(project(":config").sourceSets["main"].output)
from(project(":core").sourceSets["main"].output)
from(project(":fabric").sourceSets["main"].output)
}
from(project(":fabric:versions:26.1-26.3").sourceSets["main"].output)
}
Loading
Loading