build: 将构建脚本转换成 kotlin 语言
This commit is contained in:
102
build.gradle.kts
Normal file
102
build.gradle.kts
Normal file
@@ -0,0 +1,102 @@
|
||||
//file:noinspection GrDeprecatedAPIUsage
|
||||
|
||||
plugins {
|
||||
id("java")
|
||||
id("maven-publish")
|
||||
id("com.github.johnrengelman.shadow") version "8+"
|
||||
}
|
||||
|
||||
group = "cn.hamster3.mc.plugin"
|
||||
version = "1.0.0-SNAPSHOT"
|
||||
|
||||
subprojects {
|
||||
apply {
|
||||
plugin("java")
|
||||
plugin("maven-publish")
|
||||
plugin("com.github.johnrengelman.shadow")
|
||||
}
|
||||
|
||||
group = rootProject.group
|
||||
version = rootProject.version
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
url = uri("https://maven.airgame.net/maven-public/")
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// https://mvnrepository.com/artifact/org.jetbrains/annotations
|
||||
compileOnly("org.jetbrains:annotations:23.0.0")
|
||||
// https://mvnrepository.com/artifact/org.projectlombok/lombok
|
||||
compileOnly("org.projectlombok:lombok:1.18.28")
|
||||
annotationProcessor("org.projectlombok:lombok:1.18.28")
|
||||
}
|
||||
|
||||
java {
|
||||
sourceCompatibility = JavaVersion.VERSION_1_8
|
||||
targetCompatibility = JavaVersion.VERSION_1_8
|
||||
withJavadocJar()
|
||||
withSourcesJar()
|
||||
}
|
||||
|
||||
tasks {
|
||||
withType<JavaCompile>().configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
withType<Jar>().configureEach {
|
||||
from(rootProject.file("LICENSE"))
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
}
|
||||
jar {
|
||||
archiveClassifier = "dev"
|
||||
}
|
||||
javadoc {
|
||||
options.jFlags("-Dfile.encoding=utf8")
|
||||
options.encoding = "UTF-8"
|
||||
options.quiet()
|
||||
val o: StandardJavadocDocletOptions = options as StandardJavadocDocletOptions
|
||||
o.addStringOption("Xdoclint:none", "-quiet")
|
||||
o.links(
|
||||
"https://javadoc.io/doc/org.jetbrains/annotations/23.0.0",
|
||||
"https://javadoc.io/doc/com.google.code.gson/gson/2.8.0",
|
||||
"http://milkbowl.github.io/VaultAPI",
|
||||
"https://bukkit.windit.net/javadoc"
|
||||
)
|
||||
|
||||
}
|
||||
shadowJar {
|
||||
archiveClassifier = ""
|
||||
relocate("net.kyori", "cn.hamster3.mc.plugin.core.lib.net.kyori")
|
||||
relocate("com.zaxxer.hikari", "cn.hamster3.mc.plugin.core.lib.com.zaxxer.hikari")
|
||||
relocate("de.tr7zw.changeme.nbtapi", "cn.hamster3.mc.plugin.core.lib.de.tr7zw.nbtapi")
|
||||
relocate("de.tr7zw.annotations", "cn.hamster3.mc.plugin.core.lib.de.tr7zw.nbtapi.annotations")
|
||||
destinationDirectory = rootProject.buildDir
|
||||
}
|
||||
build {
|
||||
dependsOn(shadowJar)
|
||||
}
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
create<MavenPublication>("mavenJava") {
|
||||
from(components["java"])
|
||||
}
|
||||
}
|
||||
repositories {
|
||||
maven {
|
||||
val releasesRepoUrl = uri("https://maven.airgame.net/maven-releases/")
|
||||
val snapshotsRepoUrl = uri("https://maven.airgame.net/maven-snapshots/")
|
||||
|
||||
url = if (version.toString().endsWith("SNAPSHOT")) snapshotsRepoUrl else releasesRepoUrl
|
||||
|
||||
credentials {
|
||||
username = rootProject.properties.getOrDefault("maven_username", "").toString()
|
||||
password = rootProject.properties.getOrDefault("maven_password", "").toString()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user