mirror of
https://github.com/BlueMap-Minecraft/BlueMap.git
synced 2024-11-27 04:55:18 +01:00
Rework gradle-build system (#574)
* Rework gradle-build setup * Fix versioning * Fix github build * Configure publishing * Push BlueMapAPI * Reorganize project naming * Update neoforge-gradle * Add gradle-stracktrace to github action * Remove clean gradle target to hopefully no longer upset neogradle for some reason * Update gradle and add stacktrace to github action again * Update neogradle * Switch to neoforges ModDevGradle
This commit is contained in:
parent
38a8423428
commit
1454297bbd
2
.github/translation-checker/index.js
vendored
2
.github/translation-checker/index.js
vendored
@ -80,7 +80,7 @@ function parse(str) {
|
|||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
const langFolder = "../../BlueMapCommon/webapp/public/lang/";
|
const langFolder = "../../common/webapp/public/lang/";
|
||||||
const languageFiles = readdirSync(langFolder).filter(
|
const languageFiles = readdirSync(langFolder).filter(
|
||||||
(f) => f.endsWith(".conf") && f !== "settings.conf"
|
(f) => f.endsWith(".conf") && f !== "settings.conf"
|
||||||
);
|
);
|
||||||
|
7
.github/workflows/build.yml
vendored
7
.github/workflows/build.yml
vendored
@ -23,13 +23,10 @@ jobs:
|
|||||||
uses: actions/setup-java@v4
|
uses: actions/setup-java@v4
|
||||||
with:
|
with:
|
||||||
distribution: 'temurin'
|
distribution: 'temurin'
|
||||||
java-version: |
|
java-version: 21
|
||||||
16
|
|
||||||
17
|
|
||||||
21
|
|
||||||
cache: 'gradle'
|
cache: 'gradle'
|
||||||
- name: Build with Gradle
|
- name: Build with Gradle
|
||||||
run: ./gradlew clean spotlessCheck test build
|
run: ./gradlew spotlessCheck test release --stacktrace
|
||||||
- uses: actions/upload-artifact@v4
|
- uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: artifacts
|
name: artifacts
|
||||||
|
30
.github/workflows/publish.yml
vendored
30
.github/workflows/publish.yml
vendored
@ -1,30 +0,0 @@
|
|||||||
name: Publish
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- "**"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v4
|
|
||||||
with:
|
|
||||||
submodules: recursive
|
|
||||||
fetch-depth: 0 # needed for versioning
|
|
||||||
- name: Set up Java
|
|
||||||
uses: actions/setup-java@v4
|
|
||||||
with:
|
|
||||||
distribution: 'temurin'
|
|
||||||
java-version: |
|
|
||||||
16
|
|
||||||
17
|
|
||||||
21
|
|
||||||
cache: 'gradle'
|
|
||||||
- name: Build with Gradle
|
|
||||||
run: ./gradlew clean :BlueMapCore:publish :BlueMapCommon:publish
|
|
||||||
env:
|
|
||||||
BLUECOLORED_USERNAME: ${{ secrets.BLUECOLORED_USERNAME }}
|
|
||||||
BLUECOLORED_PASSWORD: ${{ secrets.BLUECOLORED_PASSWORD }}
|
|
5
.gitignore
vendored
5
.gitignore
vendored
@ -6,6 +6,7 @@ doc/
|
|||||||
logs/
|
logs/
|
||||||
.run/
|
.run/
|
||||||
run/
|
run/
|
||||||
|
runs/
|
||||||
node_modules/
|
node_modules/
|
||||||
|
|
||||||
.classpath
|
.classpath
|
||||||
@ -17,8 +18,8 @@ node_modules/
|
|||||||
release.md
|
release.md
|
||||||
|
|
||||||
# exclude generated resource
|
# exclude generated resource
|
||||||
BlueMapCommon/src/main/resources/de/bluecolored/bluemap/webapp.zip
|
common/src/main/resources/de/bluecolored/bluemap/webapp.zip
|
||||||
BlueMapCore/src/main/resources/de/bluecolored/bluemap/resourceExtensions.zip
|
core/src/main/resources/de/bluecolored/bluemap/resourceExtensions.zip
|
||||||
|
|
||||||
#exclude-test-data
|
#exclude-test-data
|
||||||
data/test-render
|
data/test-render
|
||||||
|
2
.gitmodules
vendored
2
.gitmodules
vendored
@ -1,3 +1,3 @@
|
|||||||
[submodule "BlueMapAPI"]
|
[submodule "BlueMapAPI"]
|
||||||
path = BlueMapAPI
|
path = api
|
||||||
url = https://github.com/BlueMap-Minecraft/BlueMapAPI
|
url = https://github.com/BlueMap-Minecraft/BlueMapAPI
|
||||||
|
@ -1 +0,0 @@
|
|||||||
Subproject commit ec977113495dacd6f2e24239015f4b94b305fc52
|
|
@ -1,148 +0,0 @@
|
|||||||
import com.github.gradle.node.npm.task.NpmTask
|
|
||||||
import java.io.IOException
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
java
|
|
||||||
`java-library`
|
|
||||||
`maven-publish`
|
|
||||||
id("com.diffplug.spotless") version "6.1.2"
|
|
||||||
id ("com.github.node-gradle.node") version "3.5.0"
|
|
||||||
}
|
|
||||||
|
|
||||||
group = "de.bluecolored.bluemap"
|
|
||||||
version = System.getProperty("bluemap.version") ?: "?" // set by BlueMapCore
|
|
||||||
val lastVersion = System.getProperty("bluemap.lastVersion") ?: "?" // set by BlueMapCore
|
|
||||||
|
|
||||||
val javaTarget = 16
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.toVersion(javaTarget)
|
|
||||||
targetCompatibility = JavaVersion.toVersion(javaTarget)
|
|
||||||
withSourcesJar()
|
|
||||||
withJavadocJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven ("https://libraries.minecraft.net")
|
|
||||||
maven ("https://repo.bluecolored.de/releases")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api ("com.mojang:brigadier:1.0.17")
|
|
||||||
|
|
||||||
api ("de.bluecolored.bluemap:BlueMapCore")
|
|
||||||
|
|
||||||
compileOnly ("org.jetbrains:annotations:16.0.2")
|
|
||||||
compileOnly ("org.projectlombok:lombok:1.18.32")
|
|
||||||
|
|
||||||
annotationProcessor ("org.projectlombok:lombok:1.18.32")
|
|
||||||
|
|
||||||
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
|
||||||
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
|
||||||
}
|
|
||||||
|
|
||||||
spotless {
|
|
||||||
java {
|
|
||||||
target ("src/*/java/**/*.java")
|
|
||||||
|
|
||||||
licenseHeaderFile("../HEADER")
|
|
||||||
indentWithSpaces()
|
|
||||||
trimTrailingWhitespace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.javadoc {
|
|
||||||
options {
|
|
||||||
(this as? StandardJavadocDocletOptions)?.apply {
|
|
||||||
links(
|
|
||||||
"https://docs.oracle.com/en/java/javase/16/docs/api/",
|
|
||||||
"https://javadoc.io/doc/com.flowpowered/flow-math/1.0.3/",
|
|
||||||
"https://javadoc.io/doc/com.google.code.gson/gson/2.8.0/",
|
|
||||||
)
|
|
||||||
addStringOption("Xdoclint:none", "-quiet")
|
|
||||||
addBooleanOption("html5", true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
node {
|
|
||||||
version.set("20.14.0")
|
|
||||||
download.set(true)
|
|
||||||
nodeProjectDir.set(file("webapp/"))
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile::class).configureEach {
|
|
||||||
options.apply {
|
|
||||||
encoding = "utf-8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(AbstractArchiveTask::class).configureEach {
|
|
||||||
isReproducibleFileOrder = true
|
|
||||||
isPreserveFileTimestamps = false
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.clean {
|
|
||||||
doFirst {
|
|
||||||
if (!file("webapp/dist/").deleteRecursively())
|
|
||||||
throw IOException("Failed to delete build directory!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("buildWebapp", type = NpmTask::class) {
|
|
||||||
dependsOn ("npmInstall")
|
|
||||||
args.set(listOf("run", "build"))
|
|
||||||
|
|
||||||
inputs.dir("webapp/")
|
|
||||||
outputs.dir("webapp/dist/")
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("zipWebapp", type = Zip::class) {
|
|
||||||
dependsOn ("buildWebapp")
|
|
||||||
from (fileTree("webapp/dist/"))
|
|
||||||
archiveFileName.set("webapp.zip")
|
|
||||||
destinationDirectory.set(file("src/main/resources/de/bluecolored/bluemap/"))
|
|
||||||
|
|
||||||
inputs.dir("webapp/dist/")
|
|
||||||
outputs.file("src/main/resources/de/bluecolored/bluemap/webapp.zip")
|
|
||||||
}
|
|
||||||
|
|
||||||
//always update the zip before build
|
|
||||||
tasks.processResources { dependsOn("zipWebapp") }
|
|
||||||
tasks.getByName("sourcesJar") { dependsOn("zipWebapp") }
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "bluecolored"
|
|
||||||
|
|
||||||
val releasesRepoUrl = "https://repo.bluecolored.de/releases"
|
|
||||||
val snapshotsRepoUrl = "https://repo.bluecolored.de/snapshots"
|
|
||||||
url = uri(if (version == lastVersion) releasesRepoUrl else snapshotsRepoUrl)
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
username = project.findProperty("bluecoloredUsername") as String? ?: System.getenv("BLUECOLORED_USERNAME")
|
|
||||||
password = project.findProperty("bluecoloredPassword") as String? ?: System.getenv("BLUECOLORED_PASSWORD")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("maven") {
|
|
||||||
groupId = project.group.toString()
|
|
||||||
artifactId = project.name
|
|
||||||
version = project.version.toString()
|
|
||||||
|
|
||||||
from(components["java"])
|
|
||||||
|
|
||||||
versionMapping {
|
|
||||||
usage("java-api") {
|
|
||||||
fromResolutionOf("runtimeClasspath")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,4 +0,0 @@
|
|||||||
rootProject.name = "BlueMapCommon"
|
|
||||||
|
|
||||||
includeBuild("../BlueMapAPI")
|
|
||||||
includeBuild("../BlueMapCore")
|
|
@ -1,179 +0,0 @@
|
|||||||
import java.io.IOException
|
|
||||||
import java.util.concurrent.TimeoutException
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
java
|
|
||||||
`java-library`
|
|
||||||
`maven-publish`
|
|
||||||
id("com.diffplug.spotless") version "6.1.2"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
|
|
||||||
.directory(projectDir)
|
|
||||||
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
|
||||||
.redirectError(ProcessBuilder.Redirect.PIPE)
|
|
||||||
.start()
|
|
||||||
.apply {
|
|
||||||
if (!waitFor(10, TimeUnit.SECONDS)) {
|
|
||||||
throw TimeoutException("Failed to execute command: '" + this@runCommand + "'")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
.run {
|
|
||||||
val error = errorStream.bufferedReader().readText().trim()
|
|
||||||
if (error.isNotEmpty()) {
|
|
||||||
throw IOException(error)
|
|
||||||
}
|
|
||||||
inputStream.bufferedReader().readText().trim()
|
|
||||||
}
|
|
||||||
|
|
||||||
val gitHash = "git rev-parse --verify HEAD".runCommand()
|
|
||||||
var clean = false;
|
|
||||||
try {
|
|
||||||
clean = "git status --porcelain".runCommand().isEmpty();
|
|
||||||
} catch (ex: TimeoutException) {
|
|
||||||
println("Failed to run 'git status --porcelain', assuming dirty version.")
|
|
||||||
}
|
|
||||||
val lastTag = if ("git tag".runCommand().isEmpty()) "" else "git describe --tags --abbrev=0".runCommand()
|
|
||||||
val lastVersion = if (lastTag.isEmpty()) "dev" else lastTag.substring(1) // remove the leading 'v'
|
|
||||||
val commits = "git rev-list --count $lastTag..HEAD".runCommand()
|
|
||||||
println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
|
|
||||||
|
|
||||||
group = "de.bluecolored.bluemap"
|
|
||||||
version = lastVersion +
|
|
||||||
(if (commits == "0") "" else "-$commits") +
|
|
||||||
(if (clean) "" else "-dirty")
|
|
||||||
|
|
||||||
System.setProperty("bluemap.version", version.toString())
|
|
||||||
System.setProperty("bluemap.lastVersion", lastVersion)
|
|
||||||
println("Version: $version")
|
|
||||||
|
|
||||||
val javaTarget = 16
|
|
||||||
java {
|
|
||||||
sourceCompatibility = JavaVersion.toVersion(javaTarget)
|
|
||||||
targetCompatibility = JavaVersion.toVersion(javaTarget)
|
|
||||||
withSourcesJar()
|
|
||||||
withJavadocJar()
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven ("https://repo.bluecolored.de/releases")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Suppress("GradlePackageUpdate")
|
|
||||||
dependencies {
|
|
||||||
api ("com.github.ben-manes.caffeine:caffeine:3.1.8")
|
|
||||||
api ("org.spongepowered:configurate-hocon:4.1.2")
|
|
||||||
api ("org.spongepowered:configurate-gson:4.1.2")
|
|
||||||
api ("de.bluecolored.bluenbt:BlueNBT:2.3.0")
|
|
||||||
api ("org.apache.commons:commons-dbcp2:2.9.0")
|
|
||||||
api ("io.airlift:aircompressor:0.24")
|
|
||||||
api ("org.lz4:lz4-java:1.8.0")
|
|
||||||
|
|
||||||
api ("de.bluecolored.bluemap:BlueMapAPI")
|
|
||||||
|
|
||||||
compileOnly ("org.jetbrains:annotations:23.0.0")
|
|
||||||
compileOnly ("org.projectlombok:lombok:1.18.32")
|
|
||||||
|
|
||||||
annotationProcessor ("org.projectlombok:lombok:1.18.32")
|
|
||||||
|
|
||||||
testImplementation ("org.junit.jupiter:junit-jupiter:5.8.2")
|
|
||||||
testRuntimeOnly ("org.junit.jupiter:junit-jupiter-engine:5.8.2")
|
|
||||||
testCompileOnly ("org.projectlombok:lombok:1.18.32")
|
|
||||||
testAnnotationProcessor ("org.projectlombok:lombok:1.18.32")
|
|
||||||
}
|
|
||||||
|
|
||||||
spotless {
|
|
||||||
java {
|
|
||||||
target ("src/*/java/**/*.java")
|
|
||||||
|
|
||||||
licenseHeaderFile("../HEADER")
|
|
||||||
indentWithSpaces()
|
|
||||||
trimTrailingWhitespace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.javadoc {
|
|
||||||
options {
|
|
||||||
(this as? StandardJavadocDocletOptions)?.apply {
|
|
||||||
links(
|
|
||||||
"https://docs.oracle.com/en/java/javase/16/docs/api/",
|
|
||||||
"https://javadoc.io/doc/com.flowpowered/flow-math/1.0.3/",
|
|
||||||
"https://javadoc.io/doc/com.google.code.gson/gson/2.8.0/",
|
|
||||||
)
|
|
||||||
addStringOption("Xdoclint:none", "-quiet")
|
|
||||||
addBooleanOption("html5", true)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(JavaCompile::class).configureEach {
|
|
||||||
options.apply {
|
|
||||||
encoding = "utf-8"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType(AbstractArchiveTask::class).configureEach {
|
|
||||||
isReproducibleFileOrder = true
|
|
||||||
isPreserveFileTimestamps = false
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.test {
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.processResources {
|
|
||||||
outputs.upToDateWhen { false }
|
|
||||||
from("src/main/resources") {
|
|
||||||
include("de/bluecolored/bluemap/version.json")
|
|
||||||
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
||||||
|
|
||||||
expand (
|
|
||||||
"version" to project.version,
|
|
||||||
"gitHash" to gitHash + if (clean) "" else " (dirty)",
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("zipResourceExtensions", type = Zip::class) {
|
|
||||||
from(fileTree("src/main/resourceExtensions"))
|
|
||||||
archiveFileName.set("resourceExtensions.zip")
|
|
||||||
destinationDirectory.set(file("src/main/resources/de/bluecolored/bluemap/"))
|
|
||||||
outputs.upToDateWhen{ false }
|
|
||||||
}
|
|
||||||
|
|
||||||
//always update the zip before build
|
|
||||||
tasks.processResources { dependsOn("zipResourceExtensions") }
|
|
||||||
tasks.getByName("sourcesJar") { dependsOn("zipResourceExtensions") }
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
name = "bluecolored"
|
|
||||||
|
|
||||||
val releasesRepoUrl = "https://repo.bluecolored.de/releases"
|
|
||||||
val snapshotsRepoUrl = "https://repo.bluecolored.de/snapshots"
|
|
||||||
url = uri(if (version == lastVersion) releasesRepoUrl else snapshotsRepoUrl)
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
username = project.findProperty("bluecoloredUsername") as String? ?: System.getenv("BLUECOLORED_USERNAME")
|
|
||||||
password = project.findProperty("bluecoloredPassword") as String? ?: System.getenv("BLUECOLORED_PASSWORD")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
publications {
|
|
||||||
create<MavenPublication>("maven") {
|
|
||||||
groupId = project.group.toString()
|
|
||||||
artifactId = project.name
|
|
||||||
version = project.version.toString()
|
|
||||||
|
|
||||||
from(components["java"])
|
|
||||||
|
|
||||||
versionMapping {
|
|
||||||
usage("java-api") {
|
|
||||||
fromResolutionOf("runtimeClasspath")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
rootProject.name = "BlueMapCore"
|
|
1
api
Submodule
1
api
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 8e14a344e9385144698ee7f21a2ef668b26d5fe7
|
@ -1,57 +0,0 @@
|
|||||||
tasks.register("clean") {
|
|
||||||
gradle.includedBuilds.forEach {
|
|
||||||
// workaround for https://github.com/neoforged/NeoGradle/issues/18
|
|
||||||
if (it.name == "neoforge-1.20.2") return@forEach
|
|
||||||
|
|
||||||
dependsOn(it.task(":clean"))
|
|
||||||
}
|
|
||||||
|
|
||||||
doFirst {
|
|
||||||
if (!file("build").deleteRecursively())
|
|
||||||
throw java.io.IOException("Failed to delete build directory!")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("build") {
|
|
||||||
gradle.includedBuilds.forEach {
|
|
||||||
if (it.name == "BlueMapCore") return@forEach
|
|
||||||
if (it.name == "BlueMapCommon") return@forEach
|
|
||||||
|
|
||||||
dependsOn(it.task(":release"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("test") {
|
|
||||||
gradle.includedBuilds.forEach {
|
|
||||||
dependsOn(it.task(":test"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("spotlessApply") {
|
|
||||||
gradle.includedBuilds.forEach {
|
|
||||||
dependsOn(it.task(":spotlessApply"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("spotlessCheck") {
|
|
||||||
gradle.includedBuilds.forEach {
|
|
||||||
dependsOn(it.task(":spotlessCheck"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.register("publish") {
|
|
||||||
gradle.includedBuilds.forEach {
|
|
||||||
if (it.name == "BlueMapCore") return@forEach
|
|
||||||
if (it.name == "BlueMapCommon") return@forEach
|
|
||||||
|
|
||||||
dependsOn(it.task(":publish"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// adding repositories here so intellij can download source-files and javadocs
|
|
||||||
repositories {
|
|
||||||
mavenCentral()
|
|
||||||
maven ("https://libraries.minecraft.net")
|
|
||||||
maven ("https://repo.papermc.io/repository/maven-public/")
|
|
||||||
maven ("https://repo.bluecolored.de/releases")
|
|
||||||
}
|
|
25
buildSrc/build.gradle.kts
Normal file
25
buildSrc/build.gradle.kts
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
plugins {
|
||||||
|
`kotlin-dsl`
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
gradlePluginPortal()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
fun plugin(dependency: Provider<PluginDependency>) = dependency.map {
|
||||||
|
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}"
|
||||||
|
}
|
||||||
|
|
||||||
|
implementation ( plugin( libs.plugins.spotless ) )
|
||||||
|
implementation ( plugin( libs.plugins.shadow ) )
|
||||||
|
implementation ( plugin( libs.plugins.minotaur ) )
|
||||||
|
implementation ( plugin( libs.plugins.cursegradle ) )
|
||||||
|
implementation ( plugin( libs.plugins.hangar ) )
|
||||||
|
implementation ( plugin( libs.plugins.sponge.ore ) )
|
||||||
|
|
||||||
|
// explicitly set guava version to resolve a build-dependency issue
|
||||||
|
implementation( libs.guava )
|
||||||
|
|
||||||
|
}
|
9
buildSrc/settings.gradle.kts
Normal file
9
buildSrc/settings.gradle.kts
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
|
||||||
|
// use version-catalog from root project
|
||||||
|
dependencyResolutionManagement {
|
||||||
|
versionCatalogs {
|
||||||
|
register("libs") {
|
||||||
|
from(files("../gradle/libs.versions.toml"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
buildSrc/src/main/kotlin/CopyFileTask.kt
Normal file
23
buildSrc/src/main/kotlin/CopyFileTask.kt
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import org.gradle.api.DefaultTask
|
||||||
|
import org.gradle.api.file.RegularFileProperty
|
||||||
|
import org.gradle.api.tasks.InputFile
|
||||||
|
import org.gradle.api.tasks.OutputFile
|
||||||
|
import org.gradle.api.tasks.TaskAction
|
||||||
|
|
||||||
|
abstract class CopyFileTask : DefaultTask() {
|
||||||
|
|
||||||
|
@get:InputFile
|
||||||
|
abstract val inputFile: RegularFileProperty
|
||||||
|
|
||||||
|
@get:OutputFile
|
||||||
|
abstract val outputFile: RegularFileProperty
|
||||||
|
|
||||||
|
@TaskAction
|
||||||
|
fun action() {
|
||||||
|
inputFile.get().asFile.copyTo(
|
||||||
|
outputFile.get().asFile,
|
||||||
|
overwrite = true
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
78
buildSrc/src/main/kotlin/bluemap.base.gradle.kts
Normal file
78
buildSrc/src/main/kotlin/bluemap.base.gradle.kts
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
plugins {
|
||||||
|
java
|
||||||
|
`java-library`
|
||||||
|
`maven-publish`
|
||||||
|
id ( "com.diffplug.spotless" )
|
||||||
|
}
|
||||||
|
|
||||||
|
group = "de.bluecolored"
|
||||||
|
version = gitVersion()
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven ("https://repo.bluecolored.de/releases") {
|
||||||
|
content { includeGroupByRegex ("de\\.bluecolored\\..*") }
|
||||||
|
}
|
||||||
|
maven ("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") {
|
||||||
|
content { includeGroup ("org.spigotmc") }
|
||||||
|
}
|
||||||
|
|
||||||
|
mavenCentral()
|
||||||
|
maven ("https://libraries.minecraft.net")
|
||||||
|
maven ( "https://maven.minecraftforge.net" )
|
||||||
|
maven ("https://repo.papermc.io/repository/maven-public/")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(JavaCompile::class).configureEach {
|
||||||
|
options.encoding = "utf-8"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType(AbstractArchiveTask::class).configureEach {
|
||||||
|
isReproducibleFileOrder = true
|
||||||
|
isPreserveFileTimestamps = false
|
||||||
|
}
|
||||||
|
|
||||||
|
java {
|
||||||
|
toolchain.languageVersion = JavaLanguageVersion.of(21)
|
||||||
|
withSourcesJar()
|
||||||
|
withJavadocJar()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.javadoc {
|
||||||
|
(options as StandardJavadocDocletOptions).apply {
|
||||||
|
links(
|
||||||
|
"https://docs.oracle.com/en/java/javase/16/docs/api/",
|
||||||
|
"https://javadoc.io/doc/com.flowpowered/flow-math/1.0.3/",
|
||||||
|
"https://javadoc.io/doc/com.google.code.gson/gson/2.8.9/",
|
||||||
|
)
|
||||||
|
addStringOption("Xdoclint:none", "-quiet")
|
||||||
|
addBooleanOption("html5", true)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.test {
|
||||||
|
useJUnitPlatform()
|
||||||
|
}
|
||||||
|
|
||||||
|
spotless {
|
||||||
|
java {
|
||||||
|
target ("src/*/java/**/*.java")
|
||||||
|
|
||||||
|
licenseHeaderFile(rootProject.file("LICENSE_HEADER"))
|
||||||
|
indentWithSpaces()
|
||||||
|
trimTrailingWhitespace()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
name = "bluecolored"
|
||||||
|
url = uri( "https://repo.bluecolored.de/releases" )
|
||||||
|
|
||||||
|
credentials {
|
||||||
|
username = project.findProperty("bluecoloredUsername") as String? ?: System.getenv("BLUECOLORED_USERNAME")
|
||||||
|
password = project.findProperty("bluecoloredPassword") as String? ?: System.getenv("BLUECOLORED_PASSWORD")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
20
buildSrc/src/main/kotlin/bluemap.curseforge.gradle.kts
Normal file
20
buildSrc/src/main/kotlin/bluemap.curseforge.gradle.kts
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import com.matthewprenger.cursegradle.Options
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
id ( "bluemap.implementation" )
|
||||||
|
id ( "com.matthewprenger.cursegradle" )
|
||||||
|
}
|
||||||
|
|
||||||
|
curseforge {
|
||||||
|
apiKey = System.getenv("CURSEFORGE_TOKEN") ?: ""
|
||||||
|
options(closureOf<Options> {
|
||||||
|
javaVersionAutoDetect = false
|
||||||
|
javaIntegration = false
|
||||||
|
forgeGradleIntegration = false
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.curseforge {
|
||||||
|
group = "publishing"
|
||||||
|
dependsOn(tasks.getByName("release"))
|
||||||
|
}
|
23
buildSrc/src/main/kotlin/bluemap.hangar.gradle.kts
Normal file
23
buildSrc/src/main/kotlin/bluemap.hangar.gradle.kts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
id ( "bluemap.implementation" )
|
||||||
|
id ( "io.papermc.hangar-publish-plugin" )
|
||||||
|
}
|
||||||
|
|
||||||
|
hangarPublish {
|
||||||
|
publications.register("bluemap") {
|
||||||
|
apiKey = System.getenv("HANGAR_TOKEN")
|
||||||
|
|
||||||
|
id = "BlueMap"
|
||||||
|
channel = "Release"
|
||||||
|
version = project.version as String
|
||||||
|
changelog = project.releaseNotes()
|
||||||
|
|
||||||
|
platforms.paper {
|
||||||
|
jar = tasks.getByName("release").outputs.files.singleFile
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.publishAllPublicationsToHangar {
|
||||||
|
dependsOn(tasks.getByName("release"))
|
||||||
|
}
|
23
buildSrc/src/main/kotlin/bluemap.implementation.gradle.kts
Normal file
23
buildSrc/src/main/kotlin/bluemap.implementation.gradle.kts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
plugins {
|
||||||
|
id ( "bluemap.base" )
|
||||||
|
id ( "io.github.goooler.shadow" )
|
||||||
|
}
|
||||||
|
|
||||||
|
val Project.releaseDirectory: File
|
||||||
|
get() = rootProject.projectDir.resolve("build/release")
|
||||||
|
|
||||||
|
tasks.shadowJar {
|
||||||
|
archiveFileName = "${project.name}-${project.version}-shadow.jar"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<CopyFileTask>("release") {
|
||||||
|
group = "publishing"
|
||||||
|
dependsOn(tasks.shadowJar, tasks.spotlessCheck)
|
||||||
|
|
||||||
|
inputFile = tasks.shadowJar.flatMap { it.archiveFile }
|
||||||
|
outputFile = releaseDirectory.resolve("bluemap-${project.version}-${project.name}.jar")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.getByName<Delete>("clean") {
|
||||||
|
delete(releaseDirectory.listFiles())
|
||||||
|
}
|
17
buildSrc/src/main/kotlin/bluemap.modrinth.gradle.kts
Normal file
17
buildSrc/src/main/kotlin/bluemap.modrinth.gradle.kts
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
plugins {
|
||||||
|
id ( "bluemap.implementation" )
|
||||||
|
id ( "com.modrinth.minotaur" )
|
||||||
|
}
|
||||||
|
|
||||||
|
modrinth {
|
||||||
|
token = System.getenv("MODRINTH_TOKEN")
|
||||||
|
projectId = "swbUV1cr"
|
||||||
|
uploadFile = tasks.getByName("release").outputs.files.singleFile
|
||||||
|
versionNumber = "${project.version}-${project.name}"
|
||||||
|
changelog = project.releaseNotes()
|
||||||
|
debugMode = true
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.modrinth {
|
||||||
|
dependsOn(tasks.getByName("release"))
|
||||||
|
}
|
18
buildSrc/src/main/kotlin/bluemap.ore.gradle.kts
Normal file
18
buildSrc/src/main/kotlin/bluemap.ore.gradle.kts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
plugins {
|
||||||
|
id ( "bluemap.implementation" )
|
||||||
|
id ( "org.spongepowered.gradle.ore" )
|
||||||
|
}
|
||||||
|
|
||||||
|
oreDeployment {
|
||||||
|
apiKey(System.getenv("ORE_TOKEN"))
|
||||||
|
defaultPublication {
|
||||||
|
projectId = "bluemap"
|
||||||
|
createForumPost = true
|
||||||
|
versionBody = project.releaseNotes()
|
||||||
|
publishArtifacts.setFrom(tasks.getByName("release").outputs.files.singleFile)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.publishToOre {
|
||||||
|
dependsOn(tasks.getByName("release"))
|
||||||
|
}
|
17
buildSrc/src/main/kotlin/curseforge.kt
Normal file
17
buildSrc/src/main/kotlin/curseforge.kt
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
import com.matthewprenger.cursegradle.CurseProject
|
||||||
|
import gradle.kotlin.dsl.accessors._0d85c8abe599c3884bce56e72c18751a.curseforge
|
||||||
|
import org.gradle.api.Action
|
||||||
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.kotlin.dsl.closureOf
|
||||||
|
|
||||||
|
fun Project.curseforgeBlueMap (configuration: Action<CurseProject>) {
|
||||||
|
curseforge.project(closureOf<CurseProject> {
|
||||||
|
id = "406463"
|
||||||
|
changelogType = "markdown"
|
||||||
|
changelog = project.releaseNotes()
|
||||||
|
releaseType = "release"
|
||||||
|
mainArtifact(tasks.getByName("release").outputs.files.singleFile)
|
||||||
|
|
||||||
|
configuration.execute(this)
|
||||||
|
})
|
||||||
|
}
|
53
buildSrc/src/main/kotlin/versioning.kt
Normal file
53
buildSrc/src/main/kotlin/versioning.kt
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import org.gradle.api.Project
|
||||||
|
import java.io.IOException
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
import java.util.concurrent.TimeoutException
|
||||||
|
|
||||||
|
fun Project.gitHash(): String {
|
||||||
|
return runCommand("git rev-parse --verify HEAD", "-")
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.gitClean(): Boolean {
|
||||||
|
return runCommand("git status --porcelain", "NOT_CLEAN").isEmpty()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.gitVersion(): String {
|
||||||
|
val lastTag = if (runCommand("git tag", "").isEmpty()) "" else runCommand("git describe --tags --abbrev=0", "")
|
||||||
|
val lastVersion = if (lastTag.isEmpty()) "0.0" else lastTag.substring(1) // remove the leading 'v'
|
||||||
|
val commits = runCommand("git rev-list --count $lastTag..HEAD", "0")
|
||||||
|
val gitVersion = lastVersion +
|
||||||
|
(if (commits == "0") "" else "-$commits") +
|
||||||
|
(if (gitClean()) "" else "-dirty")
|
||||||
|
|
||||||
|
logger.lifecycle("${project.name} version: $gitVersion")
|
||||||
|
|
||||||
|
return gitVersion
|
||||||
|
}
|
||||||
|
|
||||||
|
fun Project.releaseNotes(): String {
|
||||||
|
val file = rootProject.projectDir.resolve("release.md")
|
||||||
|
if (!file.exists()) return ""
|
||||||
|
|
||||||
|
return file
|
||||||
|
.readText()
|
||||||
|
.replace("{version}", project.version.toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Project.runCommand(cmd: String, fallback: String? = null): String {
|
||||||
|
ProcessBuilder(cmd.split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
|
||||||
|
.directory(projectDir)
|
||||||
|
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
||||||
|
.redirectError(ProcessBuilder.Redirect.PIPE)
|
||||||
|
.start()
|
||||||
|
.apply {
|
||||||
|
if (!waitFor(10, TimeUnit.SECONDS))
|
||||||
|
throw TimeoutException("Failed to execute command: '$cmd'")
|
||||||
|
}
|
||||||
|
.run {
|
||||||
|
val error = errorStream.bufferedReader().readText().trim()
|
||||||
|
if (error.isEmpty()) return inputStream.bufferedReader().readText().trim()
|
||||||
|
logger.warn("Failed to execute command '$cmd': $error")
|
||||||
|
if (fallback != null) return fallback
|
||||||
|
throw IOException(error)
|
||||||
|
}
|
||||||
|
}
|
75
common/build.gradle.kts
Normal file
75
common/build.gradle.kts
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
import com.github.gradle.node.npm.task.NpmTask
|
||||||
|
import java.io.IOException
|
||||||
|
|
||||||
|
plugins {
|
||||||
|
bluemap.base
|
||||||
|
alias ( libs.plugins.node.gradle )
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api ( project( ":core" ) )
|
||||||
|
|
||||||
|
api ( libs.brigadier )
|
||||||
|
|
||||||
|
compileOnly ( libs.jetbrains.annotations )
|
||||||
|
compileOnly ( libs.lombok )
|
||||||
|
|
||||||
|
annotationProcessor ( libs.lombok )
|
||||||
|
|
||||||
|
// tests
|
||||||
|
testImplementation ( libs.junit.core )
|
||||||
|
testRuntimeOnly ( libs.junit.engine )
|
||||||
|
testRuntimeOnly ( libs.lombok )
|
||||||
|
testAnnotationProcessor ( libs.lombok )
|
||||||
|
}
|
||||||
|
|
||||||
|
node {
|
||||||
|
version = "20.14.0"
|
||||||
|
download = true
|
||||||
|
nodeProjectDir = file("webapp/")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("buildWebapp", type = NpmTask::class) {
|
||||||
|
dependsOn ("npmInstall")
|
||||||
|
args = listOf("run", "build")
|
||||||
|
|
||||||
|
inputs.dir("webapp/")
|
||||||
|
outputs.dir("webapp/dist/")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("zipWebapp", type = Zip::class) {
|
||||||
|
dependsOn ("buildWebapp")
|
||||||
|
from (fileTree("webapp/dist/"))
|
||||||
|
archiveFileName = "webapp.zip"
|
||||||
|
destinationDirectory = file("src/main/resources/de/bluecolored/bluemap/")
|
||||||
|
|
||||||
|
inputs.dir("webapp/dist/")
|
||||||
|
outputs.file("src/main/resources/de/bluecolored/bluemap/webapp.zip")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.processResources {
|
||||||
|
dependsOn("zipWebapp")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.getByName("sourcesJar") {
|
||||||
|
dependsOn("zipWebapp")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.clean {
|
||||||
|
doFirst {
|
||||||
|
if (!file("webapp/dist/").deleteRecursively())
|
||||||
|
throw IOException("Failed to delete build directory!")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
create<MavenPublication>("maven") {
|
||||||
|
groupId = project.group.toString()
|
||||||
|
artifactId = "bluemap-${project.name}"
|
||||||
|
version = project.version.toString()
|
||||||
|
|
||||||
|
from(components["java"])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user