From a64cfedb0832a146304582552c725fa314f986f0 Mon Sep 17 00:00:00 2001 From: Zach Levis Date: Mon, 8 Mar 2021 13:08:32 -0800 Subject: [PATCH 1/2] build: Add extra metadata to jar manifests Fixes GH-290 --- api/build.gradle | 6 +----- build.gradle | 19 +++++++++++++++++++ extra-kotlin/build.gradle | 6 +----- key/build.gradle | 6 +----- nbt/build.gradle | 6 +----- serializer-configurate3/build.gradle | 6 +----- serializer-configurate4/build.gradle | 6 +----- text-serializer-gson-legacy-impl/build.gradle | 6 +----- text-serializer-gson/build.gradle | 6 +----- text-serializer-legacy/build.gradle | 6 +----- text-serializer-plain/build.gradle | 6 +----- 11 files changed, 29 insertions(+), 50 deletions(-) diff --git a/api/build.gradle b/api/build.gradle index 654880fd7..58572fd69 100644 --- a/api/build.gradle +++ b/api/build.gradle @@ -11,8 +11,4 @@ dependencies { testImplementation("com.google.guava:guava:23.0") } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure" - ) -} +applyJarMetadata(this, "net.kyori.adventure") diff --git a/build.gradle b/build.gradle index cba93d9d9..adaa082df 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,25 @@ group "net.kyori" version "4.7.0-SNAPSHOT" description "A user-interface library for Minecraft: Java Edition." +def applyJarMetadata(project, moduleName) { + if("jar" in project.tasks.names) { + project.tasks.named("jar", Jar).configure { + manifest.attributes( + "Automatic-Module-Name": moduleName, + "Specification-Title": moduleName, + "Specification-Version": project.version, + "Specification-Vendor": "KyoriPowered" + ) + if(project.grgit) { + manifest.attributes( + "Git-Commit": project.grgit.head().id, + "Git-Branch": project.grgit.branch.current().name + ) + } + } + } +} + subprojects { // The bom is special... this is a bit ugly, but not much more we can do without making our own script plugin if(name != "adventure-bom") { diff --git a/extra-kotlin/build.gradle b/extra-kotlin/build.gradle index 9273fb143..31d8e9f1c 100644 --- a/extra-kotlin/build.gradle +++ b/extra-kotlin/build.gradle @@ -20,8 +20,4 @@ dependencies { testImplementation("org.jetbrains.kotlin:kotlin-test-junit5") } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.extra.kotlin" - ) -} +applyJarMetadata(this, "net.kyori.adventure.extra.kotlin") diff --git a/key/build.gradle b/key/build.gradle index f1366d454..95d7536d1 100644 --- a/key/build.gradle +++ b/key/build.gradle @@ -10,8 +10,4 @@ dependencies { testImplementation("com.google.guava:guava:23.0") } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.key" - ) -} +applyJarMetadata(this, "net.kyori.adventure.key") diff --git a/nbt/build.gradle b/nbt/build.gradle index c413be13b..d0d1883b5 100644 --- a/nbt/build.gradle +++ b/nbt/build.gradle @@ -5,8 +5,4 @@ dependencies { compileOnlyApi("org.jetbrains:annotations:20.1.0") } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.nbt" - ) -} +applyJarMetadata(this, "net.kyori.adventure.nbt") diff --git a/serializer-configurate3/build.gradle b/serializer-configurate3/build.gradle index e40fed0a2..20c15a576 100644 --- a/serializer-configurate3/build.gradle +++ b/serializer-configurate3/build.gradle @@ -4,8 +4,4 @@ dependencies { testImplementation(project(":adventure-text-serializer-gson")) } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.serializer.configurate3" - ) -} +applyJarMetadata(this, "net.kyori.adventure.serializer.configurate3") diff --git a/serializer-configurate4/build.gradle b/serializer-configurate4/build.gradle index f25a1b018..16227a3a4 100644 --- a/serializer-configurate4/build.gradle +++ b/serializer-configurate4/build.gradle @@ -4,8 +4,4 @@ dependencies { testImplementation(project(":adventure-text-serializer-gson")) } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.serializer.configurate4" - ) -} +applyJarMetadata(this, "net.kyori.adventure.serializer.configurate4") diff --git a/text-serializer-gson-legacy-impl/build.gradle b/text-serializer-gson-legacy-impl/build.gradle index 611de35ea..268cd62ea 100644 --- a/text-serializer-gson-legacy-impl/build.gradle +++ b/text-serializer-gson-legacy-impl/build.gradle @@ -4,8 +4,4 @@ dependencies { api(project(":adventure-nbt")) } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.text.serializer.gson.legacyimpl" - ) -} +applyJarMetadata(this, "net.kyori.adventure.text.serializer.gson.legacyimpl") diff --git a/text-serializer-gson/build.gradle b/text-serializer-gson/build.gradle index 2761e1c2a..0c7254589 100644 --- a/text-serializer-gson/build.gradle +++ b/text-serializer-gson/build.gradle @@ -4,8 +4,4 @@ dependencies { testImplementation(project(":adventure-nbt")) } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.text.serializer.gson" - ) -} +applyJarMetadata(this, "net.kyori.adventure.text.serializer.gson") diff --git a/text-serializer-legacy/build.gradle b/text-serializer-legacy/build.gradle index d2e043d45..c35fc7c79 100644 --- a/text-serializer-legacy/build.gradle +++ b/text-serializer-legacy/build.gradle @@ -2,8 +2,4 @@ dependencies { api(project(":adventure-api")) } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.text.serializer.legacy" - ) -} +applyJarMetadata(this, "net.kyori.adventure.text.serializer.legacy") diff --git a/text-serializer-plain/build.gradle b/text-serializer-plain/build.gradle index 233de35cf..6c33c068e 100644 --- a/text-serializer-plain/build.gradle +++ b/text-serializer-plain/build.gradle @@ -2,8 +2,4 @@ dependencies { api(project(":adventure-api")) } -jar { - manifest.attributes( - "Automatic-Module-Name": "net.kyori.adventure.text.serializer.plain" - ) -} +applyJarMetadata(this, "net.kyori.adventure.text.serializer.plain") From 4faba742a022278b94ce11a22c6221f312e9db5a Mon Sep 17 00:00:00 2001 From: Zach Levis Date: Mon, 8 Mar 2021 13:11:58 -0800 Subject: [PATCH 2/2] bom: Add extra-kotlin --- bom/build.gradle | 1 + 1 file changed, 1 insertion(+) diff --git a/bom/build.gradle b/bom/build.gradle index 5660aadd2..eeaf942a3 100644 --- a/bom/build.gradle +++ b/bom/build.gradle @@ -12,6 +12,7 @@ dependencies { constraints { [ "api", + "extra-kotlin", "key", "nbt", "serializer-configurate3",