Initial update manifest generation.

This commit is contained in:
Logan Gorence 2021-12-22 06:55:47 +00:00
parent b410fdf9e0
commit 3b47ec75bb
No known key found for this signature in database
GPG Key ID: 9743CEF10935949A
2 changed files with 42 additions and 1 deletions

View File

@ -5,7 +5,7 @@ variables:
build:
stage: build
script: gradle --build-cache shadowJar
script: gradle --build-cache assemble
cache:
key: "$CI_COMMIT_REF_NAME"
policy: push
@ -14,4 +14,5 @@ build:
- .gradle
artifacts:
paths:
- "build/manifests/update.json"
- "**/build/libs/*-plugin.jar"

View File

@ -1,4 +1,6 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.com.google.gson.Gson
import java.io.FileWriter
plugins {
java
@ -24,6 +26,40 @@ allprojects {
}
}
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 ->
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")
}
subprojects {
plugins.apply("org.jetbrains.kotlin.jvm")
plugins.apply("org.jetbrains.kotlin.plugin.serialization")
@ -70,4 +106,8 @@ subprojects {
tasks.withType<ShadowJar> {
archiveClassifier.set("plugin")
}
tasks.assemble {
dependsOn("shadowJar")
}
}