mirror of
https://github.com/BlueMap-Minecraft/BlueMapAPI.git
synced 2024-11-14 22:35:30 +01:00
91 lines
2.1 KiB
Plaintext
91 lines
2.1 KiB
Plaintext
import java.io.IOException
|
|
|
|
plugins {
|
|
java
|
|
`java-library`
|
|
id("com.diffplug.spotless") version "6.1.2"
|
|
}
|
|
|
|
group = "de.bluecolored.bluemap.api"
|
|
|
|
val apiVersion: String by project
|
|
version = apiVersion
|
|
|
|
fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
|
|
.directory(projectDir)
|
|
.redirectOutput(ProcessBuilder.Redirect.PIPE)
|
|
.redirectError(ProcessBuilder.Redirect.PIPE)
|
|
.start()
|
|
.apply { waitFor(60, TimeUnit.SECONDS) }
|
|
.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()
|
|
val clean = "git status --porcelain".runCommand().isEmpty()
|
|
println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
|
|
|
|
val javaTarget = 11
|
|
java {
|
|
sourceCompatibility = JavaVersion.toVersion(javaTarget)
|
|
targetCompatibility = JavaVersion.toVersion(javaTarget)
|
|
}
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
}
|
|
|
|
dependencies {
|
|
api ("com.flowpowered:flow-math:1.0.3")
|
|
api ("com.google.code.gson:gson:2.8.0")
|
|
|
|
compileOnly ("org.jetbrains:annotations:23.0.0")
|
|
}
|
|
|
|
spotless {
|
|
java {
|
|
target ("src/*/java/**/*.java")
|
|
|
|
licenseHeaderFile("LICENSE_HEADER")
|
|
indentWithSpaces()
|
|
trimTrailingWhitespace()
|
|
}
|
|
}
|
|
|
|
tasks.withType(JavaCompile::class).configureEach {
|
|
options.apply {
|
|
encoding = "utf-8"
|
|
}
|
|
}
|
|
|
|
tasks.withType(AbstractArchiveTask::class).configureEach {
|
|
isReproducibleFileOrder = true
|
|
isPreserveFileTimestamps = false
|
|
}
|
|
|
|
tasks.javadoc {
|
|
options {
|
|
(this as? StandardJavadocDocletOptions)?.apply {
|
|
links(
|
|
"https://docs.oracle.com/javase/8/docs/api/"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
|
|
tasks.processResources {
|
|
from("src/main/resources") {
|
|
include("de/bluecolored/bluemap/api/version.json")
|
|
duplicatesStrategy = DuplicatesStrategy.INCLUDE
|
|
|
|
expand (
|
|
"version" to project.version,
|
|
"gitHash" to gitHash + if (clean) "" else " (dirty)"
|
|
)
|
|
}
|
|
}
|