build: 优化构建脚本
This commit is contained in:
44
build.gradle
44
build.gradle
@@ -1,5 +1,7 @@
|
|||||||
|
//file:noinspection GrDeprecatedAPIUsage
|
||||||
plugins {
|
plugins {
|
||||||
id 'java'
|
id 'java'
|
||||||
|
id 'com.github.johnrengelman.shadow' version '7+'
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'cn.hamster3.mc.plugin'
|
group 'cn.hamster3.mc.plugin'
|
||||||
@@ -8,6 +10,7 @@ version '1.0.0-SNAPSHOT'
|
|||||||
subprojects {
|
subprojects {
|
||||||
apply plugin: 'java-library'
|
apply plugin: 'java-library'
|
||||||
apply plugin: 'maven-publish'
|
apply plugin: 'maven-publish'
|
||||||
|
apply plugin: 'com.github.johnrengelman.shadow'
|
||||||
|
|
||||||
group = rootProject.group
|
group = rootProject.group
|
||||||
version = rootProject.version
|
version = rootProject.version
|
||||||
@@ -18,10 +21,6 @@ subprojects {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
configurations {
|
|
||||||
shade
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
// 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'
|
||||||
@@ -46,6 +45,10 @@ subprojects {
|
|||||||
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
duplicatesStrategy(DuplicatesStrategy.EXCLUDE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jar {
|
||||||
|
classifier = 'dev'
|
||||||
|
}
|
||||||
|
|
||||||
javadoc {
|
javadoc {
|
||||||
options.quiet()
|
options.quiet()
|
||||||
options.setEncoding("UTF-8")
|
options.setEncoding("UTF-8")
|
||||||
@@ -58,4 +61,37 @@ subprojects {
|
|||||||
'https://bukkit.windit.net/javadoc'
|
'https://bukkit.windit.net/javadoc'
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
shadowJar {
|
||||||
|
classifier = ''
|
||||||
|
relocate 'org.slf4j', 'cn.hamster3.mc.plugin.core.lib.slf4j'
|
||||||
|
relocate 'net.kyori', 'cn.hamster3.mc.plugin.core.lib.kyori'
|
||||||
|
relocate 'com.zaxxer.hikari', 'cn.hamster3.mc.plugin.core.lib.hikari'
|
||||||
|
relocate 'de.tr7zw.changeme.nbtapi', 'cn.hamster3.mc.plugin.core.lib.nbtapi'
|
||||||
|
relocate 'de.tr7zw.annotations', 'cn.hamster3.mc.plugin.core.lib.nbtapi.annotations'
|
||||||
|
destinationDir(rootProject.buildDir)
|
||||||
|
}
|
||||||
|
tasks.build.dependsOn(shadowJar)
|
||||||
|
|
||||||
|
publishing {
|
||||||
|
publications {
|
||||||
|
mavenJava(MavenPublication) {
|
||||||
|
from project.components.java
|
||||||
|
}
|
||||||
|
}
|
||||||
|
repositories {
|
||||||
|
maven {
|
||||||
|
def releasesRepoUrl = 'https://maven.airgame.net/maven-releases/'
|
||||||
|
def snapshotsRepoUrl = 'https://maven.airgame.net/maven-snapshots/'
|
||||||
|
|
||||||
|
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
||||||
|
|
||||||
|
credentials {
|
||||||
|
username = rootProject.properties.getOrDefault("maven_username", "")
|
||||||
|
password = rootProject.properties.getOrDefault("maven_password", "")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -1,9 +1,3 @@
|
|||||||
//file:noinspection GroovyAssignabilityCheck
|
|
||||||
//file:noinspection VulnerableLibrariesLocal
|
|
||||||
//file:noinspection GrDeprecatedAPIUsage
|
|
||||||
plugins {
|
|
||||||
id 'com.github.johnrengelman.shadow' version '7+'
|
|
||||||
}
|
|
||||||
setArchivesBaseName("HamsterCore-Bukkit")
|
setArchivesBaseName("HamsterCore-Bukkit")
|
||||||
|
|
||||||
evaluationDependsOn(':core-common')
|
evaluationDependsOn(':core-common')
|
||||||
@@ -18,7 +12,7 @@ dependencies {
|
|||||||
implementation project(":core-common") transitive false
|
implementation project(":core-common") transitive false
|
||||||
//noinspection GradlePackageUpdate
|
//noinspection GradlePackageUpdate
|
||||||
implementation "com.zaxxer:HikariCP:${HikariCP_version}"
|
implementation "com.zaxxer:HikariCP:${HikariCP_version}"
|
||||||
//noinspection VulnerableLibrariesLocal
|
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-bukkit
|
||||||
implementation "net.kyori:adventure-platform-bukkit:${adventure_version}" exclude group: 'org.jetbrains' exclude group: 'com.google.code.gson'
|
implementation "net.kyori:adventure-platform-bukkit:${adventure_version}" exclude group: 'org.jetbrains' exclude group: 'com.google.code.gson'
|
||||||
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage
|
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage
|
||||||
implementation "net.kyori:adventure-text-minimessage:${adventure_serializer_version}" exclude group: 'org.jetbrains'
|
implementation "net.kyori:adventure-text-minimessage:${adventure_serializer_version}" exclude group: 'org.jetbrains'
|
||||||
@@ -35,47 +29,3 @@ processResources {
|
|||||||
expand "version": project.version
|
expand "version": project.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
classifier = 'dev'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.compileJava.dependsOn(":core-common:build")
|
|
||||||
shadowJar {
|
|
||||||
classifier = ''
|
|
||||||
dependencies {
|
|
||||||
exclude(dependency {
|
|
||||||
it.moduleGroup == 'com.google.code.gson'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
relocate 'org.slf4j', 'cn.hamster3.mc.plugin.core.lib.slf4j'
|
|
||||||
relocate 'net.kyori', 'cn.hamster3.mc.plugin.core.lib.kyori'
|
|
||||||
relocate 'com.zaxxer.hikari', 'cn.hamster3.mc.plugin.core.lib.hikari'
|
|
||||||
relocate 'de.tr7zw.changeme.nbtapi', 'cn.hamster3.mc.plugin.core.lib.nbtapi'
|
|
||||||
relocate 'de.tr7zw.annotations', 'cn.hamster3.mc.plugin.core.lib.nbtapi.annotations'
|
|
||||||
destinationDir(getRootProject().buildDir)
|
|
||||||
}
|
|
||||||
tasks.build.dependsOn(shadowJar)
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
shadow(MavenPublication) { publication ->
|
|
||||||
{
|
|
||||||
from components.java
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
def releasesRepoUrl = 'https://maven.airgame.net/maven-releases/'
|
|
||||||
def snapshotsRepoUrl = 'https://maven.airgame.net/maven-snapshots/'
|
|
||||||
|
|
||||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
username = rootProject.properties.getOrDefault("maven_username", "")
|
|
||||||
password = rootProject.properties.getOrDefault("maven_password", "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -55,7 +55,7 @@ public class HamsterCorePlugin extends JavaPlugin {
|
|||||||
.create();
|
.create();
|
||||||
CoreBukkitAPI.init();
|
CoreBukkitAPI.init();
|
||||||
logger.info("已初始化 CoreBukkitAPI.");
|
logger.info("已初始化 CoreBukkitAPI.");
|
||||||
CoreMessage.init(this);
|
CoreMessage.init(getLogger(), getConfig().getConfigurationSection("messages"));
|
||||||
logger.info("已初始化语言文本.");
|
logger.info("已初始化语言文本.");
|
||||||
long time = System.currentTimeMillis() - start;
|
long time = System.currentTimeMillis() - start;
|
||||||
logger.info("仓鼠核心初始化完成,总计耗时 " + time + " ms.");
|
logger.info("仓鼠核心初始化完成,总计耗时 " + time + " ms.");
|
||||||
|
@@ -7,8 +7,10 @@ import net.kyori.adventure.audience.Audience;
|
|||||||
import net.kyori.adventure.text.TextReplacementConfig;
|
import net.kyori.adventure.text.TextReplacementConfig;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
public enum CoreMessage {
|
public enum CoreMessage {
|
||||||
COMMAND_NOT_FOUND,
|
COMMAND_NOT_FOUND,
|
||||||
@@ -40,10 +42,9 @@ public enum CoreMessage {
|
|||||||
|
|
||||||
private DisplayMessage message;
|
private DisplayMessage message;
|
||||||
|
|
||||||
public static void init(@NotNull Plugin plugin) {
|
public static void init(@NotNull Logger logger, @Nullable ConfigurationSection config) {
|
||||||
ConfigurationSection config = plugin.getConfig().getConfigurationSection("messages");
|
|
||||||
if (config == null) {
|
if (config == null) {
|
||||||
plugin.getLogger().warning("加载消息失败: 配置文件中未找到 messages 节点!");
|
logger.warning("加载消息失败: 配置文件中未找到 messages 节点!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (CoreMessage value : values()) {
|
for (CoreMessage value : values()) {
|
||||||
@@ -54,13 +55,13 @@ public enum CoreMessage {
|
|||||||
try {
|
try {
|
||||||
value.message = CoreBukkitUtils.getDisplayMessage(section);
|
value.message = CoreBukkitUtils.getDisplayMessage(section);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plugin.getLogger().warning("加载消息设置 " + value.name() + " 时遇到了一个异常: ");
|
logger.warning("加载消息设置 " + value.name() + " 时遇到了一个异常: ");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show(CommandSender sender, TextReplacementConfig... replacement) {
|
public void show(@NotNull CommandSender sender, TextReplacementConfig... replacement) {
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
sender.sendMessage(name());
|
sender.sendMessage(name());
|
||||||
return;
|
return;
|
||||||
|
@@ -1,9 +1,3 @@
|
|||||||
//file:noinspection GroovyAssignabilityCheck
|
|
||||||
//file:noinspection VulnerableLibrariesLocal
|
|
||||||
//file:noinspection GrDeprecatedAPIUsage
|
|
||||||
plugins {
|
|
||||||
id 'com.github.johnrengelman.shadow' version '7+'
|
|
||||||
}
|
|
||||||
setArchivesBaseName("HamsterCore-BungeeCord")
|
setArchivesBaseName("HamsterCore-BungeeCord")
|
||||||
|
|
||||||
evaluationDependsOn(':core-common')
|
evaluationDependsOn(':core-common')
|
||||||
@@ -31,40 +25,3 @@ processResources {
|
|||||||
expand "version": project.version
|
expand "version": project.version
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
|
||||||
classifier = 'dev'
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.compileJava.dependsOn(":core-common:build")
|
|
||||||
shadowJar {
|
|
||||||
classifier = ''
|
|
||||||
relocate 'org.slf4j', 'cn.hamster3.mc.plugin.core.lib.slf4j'
|
|
||||||
relocate 'net.kyori', 'cn.hamster3.mc.plugin.core.lib.kyori'
|
|
||||||
relocate 'com.zaxxer.hikari', 'cn.hamster3.mc.plugin.core.lib.hikari'
|
|
||||||
destinationDir(getRootProject().buildDir)
|
|
||||||
}
|
|
||||||
tasks.build.dependsOn(shadowJar)
|
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
shadow(MavenPublication) { publication ->
|
|
||||||
{
|
|
||||||
from components.java
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
def releasesRepoUrl = 'https://maven.airgame.net/maven-releases/'
|
|
||||||
def snapshotsRepoUrl = 'https://maven.airgame.net/maven-snapshots/'
|
|
||||||
|
|
||||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
username = rootProject.properties.getOrDefault("maven_username", "")
|
|
||||||
password = rootProject.properties.getOrDefault("maven_password", "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
//file:noinspection GroovyAssignabilityCheck
|
|
||||||
setArchivesBaseName("HamsterCore-Common")
|
setArchivesBaseName("HamsterCore-Common")
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -7,42 +6,16 @@ dependencies {
|
|||||||
//noinspection VulnerableLibrariesLocal
|
//noinspection VulnerableLibrariesLocal
|
||||||
compileOnly 'com.google.code.gson:gson:2.8.0'
|
compileOnly 'com.google.code.gson:gson:2.8.0'
|
||||||
|
|
||||||
// https://mvnrepository.com/artifact/net.kyori/adventure-api
|
|
||||||
compileOnly "net.kyori:adventure-api:${adventure_version}"
|
|
||||||
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-api
|
// https://mvnrepository.com/artifact/net.kyori/adventure-platform-api
|
||||||
compileOnly "net.kyori:adventure-platform-api:${adventure_version}"
|
implementation "net.kyori:adventure-platform-api:${adventure_version}" exclude group: 'org.jetbrains'
|
||||||
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage
|
// https://mvnrepository.com/artifact/net.kyori/adventure-text-minimessage
|
||||||
compileOnly "net.kyori:adventure-text-minimessage:${adventure_serializer_version}"
|
implementation "net.kyori:adventure-text-minimessage:${adventure_serializer_version}" exclude group: 'org.jetbrains'
|
||||||
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson
|
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-gson
|
||||||
compileOnly "net.kyori:adventure-text-serializer-gson:${adventure_serializer_version}"
|
implementation "net.kyori:adventure-text-serializer-gson:${adventure_serializer_version}" exclude group: 'org.jetbrains' exclude group: 'com.google.code.gson'
|
||||||
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-legacy
|
// https://mvnrepository.com/artifact/net.kyori/adventure-text-serializer-legacy
|
||||||
compileOnly "net.kyori:adventure-text-serializer-legacy:${adventure_serializer_version}"
|
implementation "net.kyori:adventure-text-serializer-legacy:${adventure_serializer_version}" exclude group: 'org.jetbrains'
|
||||||
|
|
||||||
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
|
|
||||||
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.9.0'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
test {
|
test {
|
||||||
useJUnitPlatform()
|
useJUnitPlatform()
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
|
||||||
publications {
|
|
||||||
mavenJava(MavenPublication) {
|
|
||||||
from project.components.java
|
|
||||||
}
|
|
||||||
}
|
|
||||||
repositories {
|
|
||||||
maven {
|
|
||||||
def releasesRepoUrl = 'https://maven.airgame.net/maven-releases/'
|
|
||||||
def snapshotsRepoUrl = 'https://maven.airgame.net/maven-snapshots/'
|
|
||||||
|
|
||||||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl
|
|
||||||
|
|
||||||
credentials {
|
|
||||||
username = rootProject.properties.getOrDefault("maven_username", "")
|
|
||||||
password = rootProject.properties.getOrDefault("maven_password", "")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
org.gradle.jvmargs=-Xmx2G
|
org.gradle.jvmargs=-Xmx2G
|
||||||
adventure_version=4.3.0
|
adventure_version=4.3.0
|
||||||
adventure_serializer_version=4.13.0
|
adventure_serializer_version=4.14.0
|
||||||
HikariCP_version=4.0.3
|
HikariCP_version=4.0.3
|
Reference in New Issue
Block a user