mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Add MANIFEST.MF
This commit is contained in:
parent
e958fc5f73
commit
f1752db580
@ -10,9 +10,11 @@
|
|||||||
@file:Suppress("UnstableApiUsage")
|
@file:Suppress("UnstableApiUsage")
|
||||||
|
|
||||||
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
import com.github.jengelman.gradle.plugins.shadow.ShadowPlugin
|
||||||
|
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||||
import org.gradle.api.Plugin
|
import org.gradle.api.Plugin
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.kotlin.dsl.apply
|
import org.gradle.kotlin.dsl.apply
|
||||||
|
import org.gradle.kotlin.dsl.attributes
|
||||||
import org.gradle.kotlin.dsl.creating
|
import org.gradle.kotlin.dsl.creating
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import kotlin.math.pow
|
import kotlin.math.pow
|
||||||
@ -26,22 +28,17 @@ class MiraiConsoleBuildPlugin : Plugin<Project> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.getByName("shadowJar") {
|
tasks.getByName("shadowJar") {
|
||||||
doLast {
|
with(this as ShadowJar) {
|
||||||
this.outputs.files.forEach {
|
archiveFileName.set(
|
||||||
if (it.nameWithoutExtension.endsWith("-all")) {
|
"${target.name}-${target.version}.jar"
|
||||||
val output = File(
|
)
|
||||||
it.path.substringBeforeLast(File.separator) + File.separator + it.nameWithoutExtension.substringBeforeLast(
|
manifest {
|
||||||
"-all"
|
attributes(
|
||||||
) + "." + it.extension
|
"Manifest-Version" to "1",
|
||||||
)
|
"Implementation-Vendor" to "Mamoe Technologies",
|
||||||
|
"Implementation-Title" to target.name.toString(),
|
||||||
println("Renaming to ${output.path}")
|
"Implementation-Version" to target.version.toString() + "-" + gitVersion
|
||||||
if (output.exists()) {
|
)
|
||||||
output.delete()
|
|
||||||
}
|
|
||||||
|
|
||||||
it.renameTo(output)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -113,3 +110,16 @@ fun Project.findLatestFile(): Map.Entry<String, File> {
|
|||||||
}
|
}
|
||||||
} ?: error("cannot find any file to upload")
|
} ?: error("cannot find any file to upload")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val gitVersion: String by lazy {
|
||||||
|
runCatching {
|
||||||
|
val exec = Runtime.getRuntime().exec("git rev-parse HEAD")
|
||||||
|
exec.waitFor()
|
||||||
|
exec.inputStream.readBytes().toString(Charsets.UTF_8).trim().also {
|
||||||
|
println("Git commit id: $it")
|
||||||
|
}
|
||||||
|
}.onFailure {
|
||||||
|
it.printStackTrace()
|
||||||
|
return@lazy "UNKNOWN"
|
||||||
|
}.getOrThrow()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user