Skip to content

Commit

Permalink
feat!: add NeoForge runtime target
Browse files Browse the repository at this point in the history
  • Loading branch information
JustPyrrha committed Oct 9, 2024
1 parent 2edbbc4 commit eb4d3ed
Show file tree
Hide file tree
Showing 46 changed files with 923 additions and 429 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,23 +80,31 @@ jobs:
- name: Publish to Modrinth
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
run: ./gradlew build modrinth modrinthSyncBody
run: ./gradlew modrinthSyncBody :mod:fabric:modrinth :mod:neoforge:modrinth

- name: Publish to GitHub
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
./gradlew copySubJars
CHANGELOG='${{ steps.changelog.outputs.changelog }}'
NL=$'\n'
CHANGELOG=${CHANGELOG//$'\\n'/"${NL}"}
echo "$CHANGELOG" >> "notes.txt"
gh release create ${{ github.ref_name }} build/libs/**.jar --notes-file notes.txt
- name: Publish to Maven
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
run: ./gradlew publish

- name: Patch Changelog
run: ./gradlew patchChangelog

- name: Build Documentation (DokkaHtml)
run: ./gradlew dokkaHtml
- name: Build Documentation (Dokka)
run: ./gradlew dokkaGenerate

- name: Create Documentation Pull Request
env:
Expand All @@ -111,7 +119,7 @@ jobs:
git checkout -b $BRANCH
git add CHANGELOG.md
git add docs/
git commit -m "docs(dokka): patch docs and changelog for $VERSION"
git commit -m "docs: patch docs and changelog for $VERSION"
git push -u origin $BRANCH
gh pr create \
Expand All @@ -130,4 +138,4 @@ jobs:

- name: Deploy Dokka Artifact to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,32 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- NeoForge runtime target
- (NeoForge) `PayloadRegistrar.netlibPayload` extension function for registering SerializedPayloads with NeoForge networking.
- Created typealiases in `dev.wanderia.netlib.payload.api` for moved classes.

### Changed

- Renamed Marven artifacts to match targets: `netlib-common`, `netlib-fabric`, `netlib-neoforge`
- Moved `dev.wanderia.netlib.payload.api` classes to `dev.wanderia.netlib.payload`
- Updated `dokka` from `1.9.20` to `2.0.0-Beta`
- Updated `fabric-api` from `0.103.0+1.21.1` to `0.105.0+1.21.1`
- Updated `fabric-kotlin` from `1.12.1+kotlin.2.0.20` to `1.12.2+kotlin.2.0.20`
- Updated `fabric-loader` from `0.16.3` to `0.16.5`
- Updated `kotlinx-serialization` from `1.7.1` to `1.7.3`

### Deprecated

- Typealiases in `dev.wanderia.netlib.payload.api`, replace with `dev.wanderia.netlib.payload`.

### Removed

- Testmod, to be added back for each runtime target.

### Fixed

- Broken dokka versioning plugin configuration.

### Security

## [1.2.0] - 2024-08-28
Expand Down
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,14 @@ repositories {
maven("https://maven.wanderia.dev/releases") { name = "Wanderia" }
}
dependencies {
include("dev.wanderia:netlib:$version")
modImplementation("dev.wanderia:netlib:$version")
// Fabric
include("dev.wanderia:netlib-fabric:$version")
modImplementation("dev.wanderia:netlib-fabric:$version")

// NeoForge
jarJar("dev.wanderia:netlib-neoforge:$version") {
jarJar.pin(it, "[$version,)")
}
}
```
See the [testmod](https://github.com/wanderia/netlib/tree/main/src/testmod) for example usage.
Expand Down
244 changes: 39 additions & 205 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,136 +1,32 @@
import org.jetbrains.changelog.Changelog
import com.diffplug.gradle.spotless.SpotlessExtension
import org.jetbrains.changelog.ChangelogPluginConstants.SEM_VER_REGEX
import org.jetbrains.changelog.date
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.DokkaBaseConfiguration
import org.jetbrains.dokka.versioning.VersioningConfiguration
import org.jetbrains.dokka.versioning.VersioningPlugin

plugins {
alias(libs.plugins.kotlin)
alias(libs.plugins.loom)
alias(libs.plugins.kotlin.serialization)
alias(libs.plugins.spotless)
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.loom) apply false
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.spotless) apply false
alias(libs.plugins.changelog)
alias(libs.plugins.dokka)
alias(libs.plugins.dokka) apply false
alias(libs.plugins.dokka.javadoc) apply false
alias(libs.plugins.minotaur)
alias(libs.plugins.kotlinx.kover)

`maven-publish`
}

buildscript {
dependencies {
classpath(libs.dokka.pluginBase)
classpath(libs.dokka.pluginVersioning)
}
alias(libs.plugins.loader.common) apply false
alias(libs.plugins.loader.dokka) apply false
alias(libs.plugins.loader.runtime) apply false
}

group = "dev.wanderia"

version = "1.2.0"
version = "1.3.0"

repositories { mavenCentral() }

dependencies {
minecraft(libs.minecraft)
mappings(loom.officialMojangMappings())
modImplementation(libs.fabric.kotlin)
modImplementation(libs.fabric.loader)
modImplementation(fabricApi.module("fabric-networking-api-v1", libs.versions.fabricApi.get()))
implementation(libs.kotlinx.serializationCore)

testImplementation(libs.kotlin.test)
testImplementation(libs.kotlin.test.junit5)
testImplementation(libs.junit.params)
}

tasks {
processResources {
inputs.property("version", project.version)
filesMatching("fabric.mod.json") { expand(mutableMapOf("version" to project.version)) }
}

dokkaHtml {
pluginConfiguration<DokkaBase, DokkaBaseConfiguration> {
customAssets = listOf(file("artSrc/logo-icon.svg"))
footerMessage = "(c) 2024 Wanderia"
}

val docsVersionDir = projectDir.resolve("docs/version")
val docsVersion = project.version.toString()
val currentDocsDir = docsVersionDir.resolve(docsVersion)
outputDirectory = currentDocsDir

pluginConfiguration<VersioningPlugin, VersioningConfiguration> {
version = docsVersion
olderVersionsDir = docsVersionDir
}

doLast {
currentDocsDir.copyRecursively(file("docs-publishing/"), overwrite = true)
currentDocsDir.resolve("older").deleteRecursively()
}
}

val dokkaJar by
registering(Jar::class) {
from(dokkaHtml)
dependsOn(dokkaHtml)
archiveClassifier = "javadoc"
}

jar { from("LICENSE") { rename { "${it}_${project.base.archivesName.get()}" } } }

test { useJUnitPlatform() }
}

val enableDCEVM: Boolean =
if (System.getProperty("java.vendor") == "JetBrains s.r.o.") {
println("JetBrains Runtime found, enabling Enhanced Class Redefinition (DCEVM)")
true
} else {
false
}

val testmod: SourceSet by
sourceSets.creating {
compileClasspath += sourceSets.main.get().compileClasspath
compileClasspath += sourceSets.main.get().output
runtimeClasspath += sourceSets.main.get().runtimeClasspath
runtimeClasspath += sourceSets.main.get().output
}

loom {
runtimeOnlyLog4j = true
runs {
configureEach {
if (enableDCEVM) {
vmArgs("-XX:+AllowEnhancedClassRedefinition")
}
property("dev.wanderia.netlib.debug", "true")
ideConfigGenerated(name.contains("testmod"))
runDir("runs/$name")
}

create("testmodClient") {
client()
name = "Testmod Client"
source(testmod)
}

create("testmodServer") {
server()
name = "Testmod Server"
source(testmod)
}
}

mods {
create("wanderia-netlib") { sourceSet(sourceSets.main.get()) }

create("testmod") { sourceSet(testmod) }
}
kover(projects.mod.common)
kover(projects.mod.fabric)
kover(projects.mod.neoforge)
}

changelog {
Expand All @@ -146,103 +42,41 @@ changelog {
combinePreReleases = true
}

kotlin {
jvmToolchain(21)
explicitApi()
}

java {
withSourcesJar()
targetCompatibility = JavaVersion.VERSION_21
sourceCompatibility = JavaVersion.VERSION_21
}

modrinth {
token = System.getenv("MODRINTH_TOKEN")
debugMode = System.getenv("MODRINTH_DEBUG") == "1"
projectId = "netlib"
versionNumber = project.version.toString()
versionType =
with(project.version.toString()) {
when {
contains("alpha") -> "alpha"
contains("beta") -> "beta"
else -> "release"
}
}
uploadFile.set(tasks.remapJar)
additionalFiles.set(listOf(tasks.remapSourcesJar))
gameVersions = listOf(libs.versions.minecraft.get())
dependencies {
required.project("fabric-api")
required.project("fabric-language-kotlin")
}
changelog =
rootProject.changelog.renderItem(
rootProject.changelog.getUnreleased().withEmptySections(false).withHeader(false),
Changelog.OutputType.MARKDOWN,
)
syncBodyFrom = rootProject.file("README.md").readText()
}

spotless {
kotlin {
ktfmt().kotlinlangStyle()
licenseHeaderFile("$projectDir/HEADER")
}
kotlinGradle { ktfmt().kotlinlangStyle() }
java {
googleJavaFormat()
licenseHeaderFile("$projectDir/HEADER")
}
}

publishing {
publications {
create<MavenPublication>("maven") {
pom {
name = "netlib"
description = "netlib $version - Kotlinx Serialization for custom payloads."
url = "https://github.com/wanderia/netlib"
licenses {
license {
name = "Mozilla Public License v2.0"
url = "https://www.mozilla.org/en-US/MPL/2.0/"
}
}
developers {
developer {
name = "Pyrrha Wills"
id = "JustPyrrha"
email = "contact@pyrrha.gay"
}
}
scm {
connection = "scm:git:git://github.com/wanderia/netlib.git"
developerConnection = "scm:git:ssh://github.com:wanderia/netlib.git"
url = "https://github.com/wanderia/netlib/tree/main"
}
subprojects {
if (!project.name.endsWith("mod") && project.name != "docs") {
apply(plugin = "com.diffplug.spotless")
extensions.configure<SpotlessExtension> {
kotlin {
ktfmt().kotlinlangStyle()
licenseHeaderFile("${rootProject.projectDir}/HEADER")
}
kotlinGradle { ktfmt().kotlinlangStyle() }
java {
googleJavaFormat()
licenseHeaderFile("${rootProject.projectDir}/HEADER")
}
artifact(tasks.remapJar)
artifact(tasks.remapSourcesJar)
artifact(tasks["dokkaJar"])
}
}

repositories {
val repositoryUrl =
with(project.version.toString()) {
when {
contains("alpha") || contains("beta") -> "s3://maven.wanderia.dev/snapshots"
else -> "s3://maven.wanderia.dev/releases"
}
}
group = rootProject.group
version = rootProject.version
}

maven(repositoryUrl) {
credentials(AwsCredentials::class) {
accessKey = System.getenv("AWS_ACCESS_KEY_ID")
secretKey = System.getenv("AWS_SECRET_ACCESS_KEY")
}
}
tasks {
val copySubJars by registering(Copy::class) {
dependsOn(
":mod:common:build",
":mod:fabric:build",
":mod:neoforge:build",
":docs:dokkaHtmlJar"
)
from(rootProject.subprojects.map { it.layout.buildDirectory.file("libs/").get().asFile })
into(rootProject.layout.buildDirectory.dir("libs"))
}
}
Loading

0 comments on commit eb4d3ed

Please sign in to comment.