Skip to content

Commit

Permalink
[ci skip] chore: use Kotlin Gradle and TOML library config (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
granny authored Jun 17, 2024
1 parent f7c0df6 commit b9a3f17
Show file tree
Hide file tree
Showing 21 changed files with 1,001 additions and 432 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ jobs:
return core.exportVariable("NEXT_BUILD_NUMBER", process.env.NEXT_BUILD_NUMBER);
- name: Build
run: ./gradlew build modrinth --stacktrace
run: ./gradlew modrinth --stacktrace
env:
MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }}
COMMIT_MESSAGE: ${{ join(github.event.commits.*.message, '<br>') }}
Expand Down
15 changes: 15 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# TODO

## General

- [x] move versions to `gradle/libs.versions.toml`
- [ ] Share logic in [`buildSrc`](https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html#sec:using_buildsrc)

## Individual project jars

- [ ] bukkit: should dev jar include missing core dependency?
- [ ] fabric: devlibs jar is missing core dependency

## uber-jar shenanigans
- [x] fix missing `jars/` directory in `META-INF`
- [x] fix incorrect `MANIFEST.MF`
171 changes: 0 additions & 171 deletions build.gradle

This file was deleted.

70 changes: 70 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
plugins {
id("java-library")
alias(libs.plugins.minotaur)
}

val buildNum = System.getenv("NEXT_BUILD_NUMBER") ?: "SNAPSHOT"
project.version = "${libs.versions.minecraft.get()}-$buildNum"

tasks {
jar {
duplicatesStrategy = DuplicatesStrategy.EXCLUDE

subprojects {
dependsOn(project.tasks.build)
}

archiveClassifier = ""

// this is janky, but it works
val manifestFiles = subprojects.filter({ it.name != "webmap" && it.name != "core" }).map {
val regularFile = it.layout.buildDirectory.file("libs/${project.name}-${it.name}-${it.version}.jar")
if (regularFile.isPresent) {
zipTree(regularFile)
} else {
null
}
}.filterNotNull()

from(manifestFiles) {
exclude("META-INF/MANIFEST.MF")
}

// this is janky, but it works
doFirst {
manifestFiles.forEach {
it.matching { include("META-INF/MANIFEST.MF") }.files.forEach {
manifest.from(it)
}
}
}
}
}

modrinth {
autoAddDependsOn = false
token = System.getenv("MODRINTH_TOKEN")
projectId = "pl3xmap"
versionName = "${project.version}"
versionNumber = "${project.version}"
versionType = "beta"
uploadFile = rootProject.layout.buildDirectory.file("libs/${rootProject.name}-${project.version}.jar").get()
//additionalFiles.addAll([
// rootProject.layout.buildDirectory.file("libs/${rootProject.name}-${project.version}-javadoc.jar").get(),
// rootProject.layout.buildDirectory.file("libs/${rootProject.name}-${project.version}-sources.jar").get()
//])
gameVersions.addAll(listOf(libs.versions.minecraft.get()))
loaders.addAll(listOf("bukkit", "fabric", /*"forge",*/ "paper", "purpur", "quilt", "spigot", "folia"))
changelog = System.getenv("COMMIT_MESSAGE")
dependencies {
required.project("fabric-api")
//optional.project(
// "pl3xmap-banners",
// "pl3xmap-claims",
// "pl3xmap-mobs",
// "pl3xmap-signs",
// "pl3xmap-warps",
// "deathspots",
//)
}
}
7 changes: 7 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
41 changes: 0 additions & 41 deletions bukkit/build.gradle

This file was deleted.

80 changes: 80 additions & 0 deletions bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
plugins {
id("java")
alias(libs.plugins.paperweight.userdev)
alias(libs.plugins.shadow)
}

val buildNum = System.getenv("NEXT_BUILD_NUMBER") ?: "SNAPSHOT"
project.version = "${libs.versions.minecraft.get()}-$buildNum"
project.group = "net.pl3x.map.bukkit"

base {
archivesName = "${rootProject.name}-${project.name}"
}

repositories {
maven("https://oss.sonatype.org/content/repositories/snapshots/") {
name = "oss-sonatype-snapshots"
mavenContent {
snapshotsOnly()
}
}
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") {
name = "s01-sonatype-snapshots"
mavenContent {
snapshotsOnly()
}
}
mavenCentral()
maven("https://jitpack.io")
}

dependencies {
implementation(project(":core", configuration = "shadow"))

implementation(libs.cloudBrigadier)
implementation(libs.cloudPaper)

implementation(libs.adventurePlatformBukkit)

paperweight.paperDevBundle(libs.versions.bukkit)
}

tasks {
reobfJar {
dependsOn(shadowJar)
}

// needed for below jank
compileJava {
dependsOn(":core:jar")
}

shadowJar {
mergeServiceFiles()

// this is janky, but it works
manifest {
from(project(":core").tasks.named<Jar>("shadowJar").get().manifest)
}
}

build {
dependsOn(reobfJar)
}

processResources {
inputs.properties(mapOf(
"name" to rootProject.name,
"group" to project.group,
"version" to project.version,
"authors" to project.properties["authors"],
"description" to project.properties["description"],
"website" to project.properties["website"]
))

filesMatching("plugin.yml") {
expand(inputs.properties)
}
}
}
Loading

0 comments on commit b9a3f17

Please sign in to comment.