Add version info in META-INF/MANIFEST.MF (#1355)

This commit is contained in:
Karlatemp 2021-06-23 14:57:34 +08:00 committed by GitHub
parent 8a1154a0d7
commit 28c2309fbb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -101,6 +101,7 @@ allprojects {
if (isKotlinJvmProject) {
configureFlattenSourceSets()
}
configureJarManifest()
}
}

View File

@ -14,6 +14,7 @@ import org.gradle.api.Project
import org.gradle.api.plugins.JavaPluginExtension
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.api.tasks.testing.Test
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.*
import org.jetbrains.kotlin.gradle.dsl.*
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
@ -182,6 +183,18 @@ fun Project.configureFlattenSourceSets() {
}
}
fun Project.configureJarManifest() {
this.tasks.withType<Jar> {
manifest {
attributes(
"Implementation-Vendor" to "Mamoe Technologies",
"Implementation-Title" to this@configureJarManifest.name.toString(),
"Implementation-Version" to this@configureJarManifest.version.toString()
)
}
}
}
inline fun <reified T> Any?.safeAs(): T? {
return this as? T
}