2024-10-09 10:37:29 +08:00
|
|
|
import groovy.xml.XmlParser
|
|
|
|
import groovy.xml.XmlUtil
|
2024-10-08 18:13:18 +08:00
|
|
|
|
|
|
|
plugins {
|
|
|
|
id("java")
|
|
|
|
id("com.github.johnrengelman.shadow") version "8.1.1"
|
2024-10-09 10:37:29 +08:00
|
|
|
id("maven-publish")
|
|
|
|
id("signing")
|
|
|
|
id("io.github.jeadyx.sonatype-uploader") version "1.0"
|
2024-10-08 18:13:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
group = "cn.lunadeer"
|
2024-10-12 15:22:35 +08:00
|
|
|
version = "2.0.7"
|
2024-10-08 18:13:18 +08:00
|
|
|
|
|
|
|
java {
|
|
|
|
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
2024-10-09 10:37:29 +08:00
|
|
|
withJavadocJar()
|
|
|
|
withSourcesJar()
|
2024-10-08 18:13:18 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// utf-8
|
|
|
|
tasks.withType<JavaCompile> {
|
|
|
|
options.encoding = "UTF-8"
|
|
|
|
}
|
|
|
|
|
|
|
|
allprojects {
|
|
|
|
apply(plugin = "java")
|
|
|
|
apply(plugin = "com.github.johnrengelman.shadow")
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenLocal()
|
|
|
|
mavenCentral()
|
|
|
|
maven("https://oss.sonatype.org/content/groups/public")
|
|
|
|
maven("https://repo.papermc.io/repository/maven-public/")
|
|
|
|
maven("https://jitpack.io")
|
|
|
|
maven("https://repo.codemc.org/repository/maven-public")
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation("org.postgresql:postgresql:42.7.2")
|
|
|
|
implementation("mysql:mysql-connector-java:8.0.33")
|
|
|
|
implementation("com.alibaba:fastjson:2.0.31")
|
2024-10-08 21:27:19 +08:00
|
|
|
implementation("net.kyori:adventure-platform-bukkit:4.3.3")
|
2024-10-08 18:13:18 +08:00
|
|
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7")
|
|
|
|
compileOnly("net.milkbowl.vault:VaultUnlockedAPI:2.2")
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.shadowJar {
|
|
|
|
archiveClassifier.set("")
|
|
|
|
archiveVersion.set(project.version.toString())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation(project(":core"))
|
|
|
|
implementation(project(":v1_20_1"))
|
|
|
|
implementation(project(":v1_21"))
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.shadowJar {
|
|
|
|
archiveClassifier.set("")
|
|
|
|
archiveVersion.set(project.version.toString())
|
|
|
|
}
|
|
|
|
|
2024-10-09 10:37:29 +08:00
|
|
|
publishing { // 配置发布信息,改成适合自己的
|
|
|
|
publications {
|
|
|
|
create<MavenPublication>("mavenJava") {
|
|
|
|
artifactId = project.name
|
|
|
|
from(components["java"])
|
|
|
|
|
|
|
|
pom {
|
|
|
|
name = project.name
|
|
|
|
description = "lunadeer-minecraft-develop-utils"
|
|
|
|
url = "https://ssl.lunadeer.cn:14446/zhangyuheng/MinecraftPluginUtils"
|
|
|
|
licenses {
|
|
|
|
license {
|
|
|
|
name = "MIT"
|
|
|
|
url = "https://opensource.org/license/mit"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
developers {
|
|
|
|
developer {
|
|
|
|
id = "zhangyuheng"
|
|
|
|
name = "zhangyuheng"
|
|
|
|
email = "zhangyuheng@lunadeer.cn"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
scm {
|
|
|
|
connection = "https://ssl.lunadeer.cn:14446/zhangyuheng/MinecraftPluginUtils.git"
|
|
|
|
developerConnection = "scm:git:ssh://git@ssl.lunadeer.cn:14446/zhangyuheng/MinecraftPluginUtils.git"
|
|
|
|
url = "https://ssl.lunadeer.cn:14446/zhangyuheng/MinecraftPluginUtils"
|
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
repositories {
|
|
|
|
maven {
|
|
|
|
name = "project"
|
|
|
|
url = uri(layout.buildDirectory.dir("repo")) // 将要发布的文件夹生成到这个目录
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
signing { // 文件签名
|
|
|
|
sign(publishing.publications["mavenJava"])
|
|
|
|
}
|
|
|
|
|
|
|
|
// remove subproject dependencies from pom file
|
|
|
|
tasks.named("generatePomFileForMavenJavaPublication") {
|
|
|
|
finalizedBy("removePomDependenciesWithGroupIdMinecraftPluginUtils")
|
|
|
|
}
|
|
|
|
// remove subproject dependencies from pom file
|
|
|
|
tasks.register("removePomDependenciesWithGroupIdMinecraftPluginUtils") {
|
|
|
|
doLast {
|
|
|
|
val pomFile =
|
|
|
|
layout.buildDirectory.file("publications/mavenJava/pom-default.xml")
|
|
|
|
.get().asFile
|
|
|
|
val pom = XmlParser().parse(pomFile)
|
|
|
|
val nodes = pom.children()
|
|
|
|
nodes.forEach { n ->
|
|
|
|
val node = n as groovy.util.Node
|
|
|
|
val name = node.name().toString().substringAfter("{http://maven.apache.org/POM/4.0.0}")
|
|
|
|
if (name == "dependencies") {
|
|
|
|
val depsToRemove = mutableListOf<groovy.util.Node>()
|
|
|
|
node.children().forEach {
|
|
|
|
val dependency = it as groovy.util.Node
|
|
|
|
if (dependency.text().contains("MinecraftPluginUtils")) {
|
|
|
|
depsToRemove.add(dependency)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
depsToRemove.forEach {
|
|
|
|
node.children().remove(it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pomFile.writeText(XmlUtil.serialize(pom))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sonatypeUploader {
|
|
|
|
dir = layout.buildDirectory.dir("repo/cn").get().asFile.path
|
|
|
|
tokenName = project.findProperty("centralUsername")?.toString()
|
|
|
|
tokenPasswd = project.findProperty("centralPassword")?.toString()
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.register("uploadToCentral") { // <<<<<<<<< 上传到 Maven 中央仓库
|
|
|
|
// 1. clean
|
|
|
|
dependsOn("clean")
|
|
|
|
// 2. publishMavenJavaPublicationToProjectRepository
|
2024-10-09 14:17:19 +08:00
|
|
|
dependsOn("publishMavenJavaPublicationToProjectRepository")
|
2024-10-09 10:37:29 +08:00
|
|
|
// 3. upload
|
|
|
|
dependsOn("1.upload deployment dir")
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.register("uploadToLocal") { // <<<<<<<<< 上传到本地仓库
|
|
|
|
// 1. clean
|
|
|
|
dependsOn("clean")
|
|
|
|
// 2. publishMavenJavaPublicationToProjectRepository
|
|
|
|
dependsOn("publishMavenJavaPublicationToMavenLocal")
|
|
|
|
}
|