Compare commits

...

6 Commits

Author SHA1 Message Date
Lukas Rieger (Blue)
d76816711d
Merge remote-tracking branch 'origin/master' into feat/build 2024-07-25 15:56:04 +02:00
Lukas Rieger (Blue)
6c04036047
Merge remote-tracking branch 'origin/master' into feat/build 2024-07-21 09:57:35 +02:00
Lukas Rieger (Blue)
cc9f0e3add
Merge branch 'master' into feat/build 2024-07-15 00:48:38 +02:00
Lukas Rieger (Blue)
50908b9f6a
Fix github build 2024-07-15 00:37:56 +02:00
Lukas Rieger (Blue)
ee55476580
Fix versioning 2024-07-15 00:30:39 +02:00
Lukas Rieger (Blue)
0b537e7ad2
Rework gradle-build setup 2024-07-15 00:25:40 +02:00
807 changed files with 809 additions and 9632 deletions

View File

@ -80,7 +80,7 @@ function parse(str) {
return nodes;
}
const langFolder = "../../BlueMapCommon/webapp/public/lang/";
const langFolder = "../../common/webapp/public/lang/";
const languageFiles = readdirSync(langFolder).filter(
(f) => f.endsWith(".conf") && f !== "settings.conf"
);

View File

@ -29,7 +29,7 @@ jobs:
21
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew clean spotlessCheck test build
run: ./gradlew clean spotlessCheck test release
- uses: actions/upload-artifact@v4
with:
name: artifacts

View File

@ -24,7 +24,7 @@ jobs:
21
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew clean :BlueMapCore:publish :BlueMapCommon:publish
run: ./gradlew clean :core:publish :common:publish
env:
BLUECOLORED_USERNAME: ${{ secrets.BLUECOLORED_USERNAME }}
BLUECOLORED_PASSWORD: ${{ secrets.BLUECOLORED_PASSWORD }}

4
.gitignore vendored
View File

@ -17,8 +17,8 @@ node_modules/
release.md
# exclude generated resource
BlueMapCommon/src/main/resources/de/bluecolored/bluemap/webapp.zip
BlueMapCore/src/main/resources/de/bluecolored/bluemap/resourceExtensions.zip
common/src/main/resources/de/bluecolored/bluemap/webapp.zip
core/src/main/resources/de/bluecolored/bluemap/resourceExtensions.zip
#exclude-test-data
data/test-render

2
.gitmodules vendored
View File

@ -1,3 +1,3 @@
[submodule "BlueMapAPI"]
path = BlueMapAPI
path = api
url = https://github.com/BlueMap-Minecraft/BlueMapAPI

@ -1 +0,0 @@
Subproject commit ec977113495dacd6f2e24239015f4b94b305fc52

View File

@ -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")
}
}
}
}
}

View File

@ -1,4 +0,0 @@
rootProject.name = "BlueMapCommon"
includeBuild("../BlueMapAPI")
includeBuild("../BlueMapCore")

View File

@ -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")
}
}
}
}
}

View File

@ -1 +0,0 @@
rootProject.name = "BlueMapCore"

1
api Submodule

@ -0,0 +1 @@
Subproject commit 40f0724dfbfbc9eac7f3f4296544ff456fd7f568

View File

@ -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")
}

17
buildSrc/build.gradle.kts Normal file
View File

@ -0,0 +1,17 @@
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 ) )
}

View File

@ -0,0 +1,9 @@
// use version-catalog from root project
dependencyResolutionManagement {
versionCatalogs {
register("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}

View File

@ -0,0 +1,63 @@
plugins {
java
`java-library`
id ( "com.diffplug.spotless" )
}
group = "de.bluecolored.bluemap"
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.set(JavaLanguageVersion.of(16))
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()
}
}

View File

@ -0,0 +1,24 @@
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<Copy>("release") {
dependsOn(tasks.shadowJar)
from ( tasks.shadowJar.map { it.outputs.files.singleFile } )
into ( releaseDirectory )
rename { "bluemap-${version}-${project.name}.jar" }
duplicatesStrategy = DuplicatesStrategy.INCLUDE
}
tasks.getByName<Delete>("clean") {
delete(releaseDirectory.listFiles())
}

View File

@ -0,0 +1,44 @@
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
}
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)
}
}

63
common/build.gradle.kts Normal file
View File

@ -0,0 +1,63 @@
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.set("20.14.0")
download.set(true)
nodeProjectDir.set(file("webapp/"))
}
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")
}
tasks.processResources {
dependsOn("zipWebapp")
}
tasks.getByName("sourcesJar") {
dependsOn("zipWebapp")
}
tasks.clean {
doFirst {
if (!file("webapp/dist/").deleteRecursively())
throw IOException("Failed to delete build directory!")
}
}

Some files were not shown because too many files have changed in this diff Show More