build: 优化构建脚本

This commit is contained in:
2022-10-29 04:17:27 +08:00
parent 3707875e2f
commit 1387c58fd4

View File

@@ -2,8 +2,8 @@ plugins {
id 'java' id 'java'
} }
group 'cn.hamster3.mc.plugin' group 'cn.hamster3.mc.plugin.ball'
version = '1.0.0-SNAPSHOT' version '1.0.0-SNAPSHOT'
subprojects { subprojects {
apply plugin: 'java-library' apply plugin: 'java-library'
@@ -25,22 +25,10 @@ subprojects {
} }
dependencies { dependencies {
// https://mvnrepository.com/artifact/org.projectlombok/lombok
compileOnly 'org.projectlombok:lombok:1.18.24'
annotationProcessor 'org.projectlombok:lombok:1.18.24'
// https://mvnrepository.com/artifact/org.jetbrains/annotations // https://mvnrepository.com/artifact/org.jetbrains/annotations
compileOnly 'org.jetbrains:annotations:23.0.0' compileOnly 'org.jetbrains:annotations:23.0.0'
} }
tasks.withType(JavaCompile) {
options.setEncoding("UTF-8")
}
tasks.withType(Jar) {
from([rootProject.file("LICENSE")])
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
@@ -48,10 +36,36 @@ subprojects {
withSourcesJar() withSourcesJar()
} }
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}
tasks.withType(Jar) {
from([rootProject.file("LICENSE")])
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
}
javadoc {
options.quiet()
options.encoding = 'UTF-8'
options.jFlags("-Dfile.encoding=utf8")
options.addStringOption('Xdoclint:none', '-quiet')
options.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'
]
}
publishing { publishing {
publications { publications {
mavenJava(MavenPublication) { mavenJava(MavenPublication) {
from getProject().getComponents().java var projectNameSplit = project.name.split('-')
artifactId = projectNameSplit[projectNameSplit.length - 1]
artifact jar
artifact sourcesJar
// artifact javadocJar
} }
} }
repositories { repositories {
@@ -62,10 +76,10 @@ subprojects {
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
credentials { credentials {
username rootProject.getProperties().getOrDefault("maven_username", "") username rootProject.properties.getOrDefault("maven_username", "")
password rootProject.getProperties().getOrDefault("maven_password", "") password rootProject.properties.getOrDefault("maven_password", "")
} }
} }
} }
} }
} }