generated from MineBuilders/allaymc-kotlin-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: more automated, modular shared libs
- Loading branch information
Showing
10 changed files
with
128 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,3 @@ | ||
plugins { | ||
alias(libs.plugins.kotlin.jvm) | ||
} | ||
|
||
dependencies { | ||
compileOnly(libs.allaymc.api) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,59 @@ | ||
plugins { | ||
alias(libs.plugins.kotlin.jvm) | ||
alias(libs.plugins.gradleup.shadow) | ||
} | ||
|
||
dependencies { | ||
@Suppress("VulnerableLibrariesLocal", "RedundantSuppression") | ||
compileOnly(libs.allaymc.api) | ||
api(projects.core) | ||
|
||
api(kotlin("stdlib")) | ||
api(kotlin("stdlib-jdk7")) | ||
api(kotlin("stdlib-jdk8")) | ||
api(kotlin("reflect")) | ||
api(libs.kotlinx.coroutines.core) | ||
api(libs.kotlinx.coroutines.swing) | ||
class Names(val words: Array<String>) { | ||
constructor(name: String) : this(name.split('-').toTypedArray()) | ||
val lodash get() = words.joinToString("_") | ||
val kebab get() = words.joinToString("-") | ||
val upperCamel get() = words.joinToString("") { word -> word.replaceFirstChar { it.uppercase() } } | ||
} | ||
|
||
kotlin { | ||
jvmToolchain(21) | ||
fun basePluginClassPackage(names: Names) = "vip.cdms.allaymc.kotlinx.shared.${names.lodash}" | ||
fun basePluginClassName(names: Names) = "Kotlinx${names.upperCamel}SharedLib" | ||
fun basePluginClass(names: Names) = """ | ||
|package ${basePluginClassPackage(names)} | ||
| | ||
|import org.allaymc.api.plugin.Plugin | ||
| | ||
|/** Automatically generated. Do NOT edit this file directly! */ | ||
|class ${basePluginClassName(names)} : Plugin() | ||
| | ||
""".trimMargin() | ||
|
||
fun basePluginDescriptor(names: Names) = """ | ||
{ | ||
"entrance": "${basePluginClassPackage(names)}.${basePluginClassName(names)}", | ||
"name": "kotlinx-${names.kebab}-lib", | ||
"description": "${ | ||
if (names.lodash == "core") "Kotlin-style Extension Library and Shared Standard Library for Allay Server" | ||
else "Kotlinx Shared Library for Allay Server -- ${names.upperCamel}" | ||
}", | ||
"authors": [ | ||
"MineBuilder" | ||
], | ||
"version": "${'$'}{version}", | ||
"dependencies": [], | ||
"website": "https://github.com/MineBuilders/allaymc-kotlinx" | ||
} | ||
""".trimIndent() | ||
|
||
subprojects { | ||
val names = Names(name) | ||
if (names.lodash == "build" || names.words.getOrNull(1) == "generated") return@subprojects | ||
|
||
val generatePath = arrayOf("build", "plugin-generated-$name") | ||
val generateDir = File(projectDir, "../" + generatePath.joinToString("/")).apply { mkdirs() } | ||
val sourceDir = File(generateDir, "src/main/kotlin/" + basePluginClassPackage(names).split('.').joinToString("/")) | ||
val resourcesDir = File(generateDir, "src/main/resources") | ||
File(sourceDir.apply { mkdirs() }, basePluginClassName(names) + ".kt").writeText(basePluginClass(names)) | ||
File(resourcesDir.apply { mkdirs() }, "plugin.json").writeText(basePluginDescriptor(names)) | ||
|
||
plugins.apply(rootProject.libs.plugins.kotlin.jvm.get().pluginId) | ||
plugins.apply(rootProject.libs.plugins.gradleup.shadow.get().pluginId) | ||
version = rootProject.rootProject.version | ||
afterEvaluate { | ||
dependencies { implementation(project(":plugin:" + generatePath.joinToString(":"))) } | ||
kotlin { jvmToolchain(21) } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
dependencies { | ||
api(projects.core) | ||
|
||
api(kotlin("stdlib")) | ||
api(kotlin("stdlib-jdk7")) | ||
api(kotlin("stdlib-jdk8")) | ||
api(kotlin("reflect")) | ||
api(libs.kotlinx.coroutines.core) | ||
api(libs.kotlinx.coroutines.swing) | ||
} |
6 changes: 0 additions & 6 deletions
6
plugin/src/main/kotlin/vip/cdms/allaymc/kotlinx/KotlinxPlugin.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters