aboutsummaryrefslogtreecommitdiff
path: root/src/main/kotlin
diff options
context:
space:
mode:
authornea <nea@nea.moe>2023-03-10 21:27:26 +0100
committernea <nea@nea.moe>2023-03-10 21:27:26 +0100
commit620b8c495de8c342785eff0d123bf8058080f6b8 (patch)
tree5b96237a298b4c12c8f7bf31c6b6e481ee89c397 /src/main/kotlin
parent2f45a494964050ece8724c798a58e577f1a9aeec (diff)
downloadmcprepack-620b8c495de8c342785eff0d123bf8058080f6b8.tar.gz
mcprepack-620b8c495de8c342785eff0d123bf8058080f6b8.tar.bz2
mcprepack-620b8c495de8c342785eff0d123bf8058080f6b8.zip
gradle publishing
Diffstat (limited to 'src/main/kotlin')
-rw-r--r--src/main/kotlin/mcprepack/App.kt45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/kotlin/mcprepack/App.kt b/src/main/kotlin/mcprepack/App.kt
index 1972c62..2358722 100644
--- a/src/main/kotlin/mcprepack/App.kt
+++ b/src/main/kotlin/mcprepack/App.kt
@@ -420,6 +420,51 @@ fun main(): Unit = lifecycle("Repacking") {
proguardLog.copyTo(mavenFile("official", "txt"))
}
+ lifecycle("Generate gradle publication buildscript") {
+ WorkContext.workDir.resolve("settings.gradle.kts").createFile()
+ WorkContext.workDir.resolve("build.gradle.kts").writer().use {
+ it.append(
+ """
+ plugins { `maven-publish` }
+
+ val allGroupId = "moe.nea.mcp"
+
+ publishing {
+ """
+ )
+
+ fun pub(artifactId: String, version: String, artifacts: Map<String?, Path>) {
+ it.append(
+ """
+ publications.create<MavenPublication>("artifactId") {
+ ${
+ artifacts.map { (classifier, path) ->
+ "this.artifact(file(${gson.toJson(path.toAbsolutePath().toString())})) {" +
+ (if (classifier == null) ""
+ else "this.classifier = ${gson.toJson(classifier)};") + "this.extension = \"jar\"}"
+ }.joinToString(separator = "\n")
+ }
+ this.groupId = allGroupId
+ this.artifactId = ${gson.toJson(artifactId)}
+ this.version = ${gson.toJson(version)}
+ }
+ """
+ )
+ }
+
+ pub("mcp-yarn", pubVersion, mapOf(null to yarnCompatibleJar, "v2" to yarnCompatibleJar))
+ it.append(
+ """
+ publications.filterIsInstance<MavenPublication>().forEach {
+ it.pom {
+ url.set("https://git.nea.moe/nea/mcprepack")
+ }
+ }
+ }"""
+ )
+ }
+ }
+
}
fun readCSV(path: Path): CSVFile {