fix: 修复构建脚本错误

This commit is contained in:
2024-03-12 02:43:47 +08:00
parent 64313b9997
commit 093f003109

View File

@@ -2,14 +2,13 @@
plugins { plugins {
id("java") id("java")
id("com.github.johnrengelman.shadow") version "8+"
} }
group = "cn.hamster3.mc.plugin" group = "cn.hamster3.mc.plugin"
version = "1.0.3" version = "1.0.3"
description = "为Minecraft服务器导入 OpenJDK Nashorn 引擎来执行 JavaScript 脚本" description = "为Minecraft服务器导入 OpenJDK Nashorn 引擎来执行 JavaScript 脚本"
val shade = configurations.create("shade")
repositories { repositories {
maven { maven {
url = uri("https://maven.airgame.net/maven-public/") url = uri("https://maven.airgame.net/maven-public/")
@@ -27,7 +26,6 @@ dependencies {
// https://mvnrepository.com/artifact/org.openjdk.nashorn/nashorn-core // https://mvnrepository.com/artifact/org.openjdk.nashorn/nashorn-core
implementation("org.openjdk.nashorn:nashorn-core:15.4") implementation("org.openjdk.nashorn:nashorn-core:15.4")
shade("org.openjdk.nashorn:nashorn-core:15.4")
} }
tasks { tasks {
@@ -42,24 +40,21 @@ tasks {
} }
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
} }
val shadeJar = create<Jar>("shadeJar") {
archiveBaseName = "HamsterScript"
archiveClassifier = "all"
destinationDirectory = rootProject.layout.buildDirectory
from(shade.map { if (it.isDirectory) it else zipTree(it) })
}
jar { jar {
archiveBaseName = "HamsterScript" destinationDirectory = rootProject.layout.buildDirectory
}
shadowJar {
destinationDirectory = rootProject.layout.buildDirectory destinationDirectory = rootProject.layout.buildDirectory
} }
withType<JavaCompile>().configureEach { withType<JavaCompile>().configureEach {
options.encoding = "UTF-8" options.encoding = "UTF-8"
} }
withType<Jar>().configureEach { withType<Jar>().configureEach {
archiveBaseName = "HamsterScript"
from(rootProject.file("LICENSE")) from(rootProject.file("LICENSE"))
duplicatesStrategy = DuplicatesStrategy.EXCLUDE duplicatesStrategy = DuplicatesStrategy.EXCLUDE
} }
build { build {
dependsOn(shadeJar) dependsOn(shadowJar)
} }
} }