2021-12-21 21:32:34 +00:00
|
|
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
2021-12-22 06:55:47 +00:00
|
|
|
import org.jetbrains.kotlin.com.google.gson.Gson
|
2021-12-23 07:02:31 +00:00
|
|
|
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
2021-12-22 06:55:47 +00:00
|
|
|
import java.io.FileWriter
|
2021-12-21 21:32:34 +00:00
|
|
|
|
2021-12-19 02:05:59 +00:00
|
|
|
plugins {
|
2021-12-21 08:58:44 +00:00
|
|
|
java
|
|
|
|
id("org.jetbrains.kotlin.jvm") version "1.6.10" apply false
|
2021-12-22 01:38:22 +00:00
|
|
|
id("org.jetbrains.kotlin.plugin.serialization") version "1.6.10" apply false
|
2021-12-21 08:58:44 +00:00
|
|
|
id("com.github.johnrengelman.shadow") version "7.1.1" apply false
|
2021-12-19 02:05:59 +00:00
|
|
|
}
|
|
|
|
|
2022-01-07 11:15:26 +00:00
|
|
|
fun Project.isFoundationPlugin() = name.startsWith("foundation-")
|
|
|
|
fun Project.isFoundationTool() = !isFoundationPlugin()
|
|
|
|
|
2021-12-21 17:22:32 +00:00
|
|
|
// Disable the JAR task for the root project.
|
|
|
|
tasks["jar"].enabled = false
|
|
|
|
|
2021-12-21 08:58:44 +00:00
|
|
|
allprojects {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
maven {
|
|
|
|
name = "papermc-repo"
|
|
|
|
url = uri("https://papermc.io/repo/repository/maven-public/")
|
|
|
|
}
|
|
|
|
maven {
|
|
|
|
name = "sonatype"
|
|
|
|
url = uri("https://oss.sonatype.org/content/groups/public/")
|
|
|
|
}
|
2021-12-19 02:05:59 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-22 06:55:47 +00:00
|
|
|
val manifestsDir = buildDir.resolve("manifests")
|
|
|
|
manifestsDir.mkdirs()
|
|
|
|
val gson = Gson()
|
|
|
|
|
|
|
|
tasks.create("updateManifests") {
|
|
|
|
// TODO: not using task dependencies, outputs, blah blah blah.
|
|
|
|
doLast {
|
|
|
|
val updateFile = manifestsDir.resolve("update.json")
|
|
|
|
val writer = FileWriter(updateFile)
|
|
|
|
writer.use {
|
|
|
|
val rootPath = rootProject.rootDir.toPath()
|
|
|
|
val updateManifest = subprojects.mapNotNull { project ->
|
2022-01-07 11:15:26 +00:00
|
|
|
if (project.isFoundationTool()) {
|
2021-12-26 08:33:23 +00:00
|
|
|
return@mapNotNull null
|
|
|
|
}
|
2021-12-22 06:55:47 +00:00
|
|
|
val files = project.tasks.getByName("shadowJar").outputs
|
|
|
|
val paths = files.files.map { rootPath.relativize(it.toPath()).toString() }
|
|
|
|
|
|
|
|
if (paths.isNotEmpty()) project.name to mapOf(
|
|
|
|
"version" to project.version,
|
|
|
|
"artifacts" to paths,
|
|
|
|
)
|
|
|
|
else null
|
|
|
|
}.toMap()
|
|
|
|
|
|
|
|
gson.toJson(
|
|
|
|
updateManifest,
|
|
|
|
writer
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.assemble {
|
|
|
|
dependsOn("updateManifests")
|
|
|
|
}
|
|
|
|
|
2021-12-21 08:58:44 +00:00
|
|
|
subprojects {
|
|
|
|
plugins.apply("org.jetbrains.kotlin.jvm")
|
2021-12-22 01:38:22 +00:00
|
|
|
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
|
2021-12-21 08:58:44 +00:00
|
|
|
plugins.apply("com.github.johnrengelman.shadow")
|
2021-12-21 00:58:22 +00:00
|
|
|
|
2021-12-23 02:23:26 +00:00
|
|
|
version = "0.2"
|
2021-12-21 08:58:44 +00:00
|
|
|
group = "io.gorence"
|
2021-12-22 05:52:10 +00:00
|
|
|
|
|
|
|
// Add build number if running under CI.
|
|
|
|
val versionWithBuild = if (System.getenv("CI_PIPELINE_IID") != null) {
|
|
|
|
version as String + ".${System.getenv("CI_PIPELINE_IID")}"
|
|
|
|
} else {
|
|
|
|
"DEV"
|
|
|
|
}
|
|
|
|
version = versionWithBuild
|
2021-12-21 00:58:22 +00:00
|
|
|
|
2021-12-21 08:58:44 +00:00
|
|
|
dependencies {
|
|
|
|
// Kotlin dependencies
|
|
|
|
implementation(platform("org.jetbrains.kotlin:kotlin-bom"))
|
|
|
|
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
|
2021-12-19 02:05:59 +00:00
|
|
|
|
2021-12-23 22:44:02 +00:00
|
|
|
implementation("io.insert-koin:koin-core:3.1.4")
|
|
|
|
testImplementation("io.insert-koin:koin-test:3.1.4")
|
|
|
|
|
2021-12-22 01:38:22 +00:00
|
|
|
// Serialization
|
|
|
|
implementation("com.charleskorn.kaml:kaml:0.38.0")
|
2021-12-22 08:11:22 +00:00
|
|
|
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.1")
|
2021-12-22 01:38:22 +00:00
|
|
|
|
2021-12-23 00:53:27 +00:00
|
|
|
// Persistence
|
|
|
|
implementation("org.jetbrains.xodus:xodus-openAPI:1.3.232")
|
|
|
|
implementation("org.jetbrains.xodus:xodus-entity-store:1.3.232")
|
|
|
|
|
2021-12-21 08:58:44 +00:00
|
|
|
// Paper API
|
|
|
|
compileOnly("io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT")
|
|
|
|
}
|
|
|
|
|
|
|
|
java {
|
|
|
|
val javaVersion = JavaVersion.toVersion(17)
|
|
|
|
sourceCompatibility = javaVersion
|
|
|
|
targetCompatibility = javaVersion
|
|
|
|
}
|
2021-12-19 02:05:59 +00:00
|
|
|
|
2021-12-23 07:02:31 +00:00
|
|
|
tasks.withType<KotlinCompile> {
|
|
|
|
kotlinOptions {
|
|
|
|
freeCompilerArgs =
|
|
|
|
freeCompilerArgs + "-Xopt-in=kotlinx.serialization.ExperimentalSerializationApi"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-12-21 08:58:44 +00:00
|
|
|
tasks.processResources {
|
|
|
|
val props = mapOf("version" to version)
|
|
|
|
inputs.properties(props)
|
|
|
|
filteringCharset = "UTF-8"
|
|
|
|
filesMatching("plugin.yml") {
|
|
|
|
expand(props)
|
|
|
|
}
|
2021-12-19 02:05:59 +00:00
|
|
|
}
|
2021-12-21 21:32:34 +00:00
|
|
|
|
2022-01-08 01:08:42 +00:00
|
|
|
if (project.isFoundationPlugin()) {
|
2021-12-26 08:33:23 +00:00
|
|
|
tasks.withType<ShadowJar> {
|
|
|
|
archiveClassifier.set("plugin")
|
|
|
|
}
|
2021-12-21 21:32:34 +00:00
|
|
|
}
|
2021-12-22 06:55:47 +00:00
|
|
|
|
|
|
|
tasks.assemble {
|
|
|
|
dependsOn("shadowJar")
|
|
|
|
}
|
2021-12-19 02:05:59 +00:00
|
|
|
}
|