Skip to content

Commit

Permalink
[A.0.0.0.2-fixed] 编码修复 脚本依赖完善
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFloodDragon committed Jul 12, 2023
1 parent 64e7c73 commit 89a0d2d
Show file tree
Hide file tree
Showing 13 changed files with 69 additions and 42 deletions.
15 changes: 11 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,20 @@ subprojects {
dependencies {
compileOnly(kotlin("stdlib"))

//项目一般依赖
if (parent?.name == "project") {
compileCore(11903)
compileTabooLib()
//MiniMessage: https://docs.adventure.kyori.net/minimessage/api.html
adventure()
}

//Runtime实现的模块依赖
//模块一般依赖——所有
if (parent?.name == "script") {
compileAll()
}

//Runtime实现的模块依赖
if (name.contains("runtime"))
parent!!.childProjects.forEach {
if (it.value.name.contains("module"))
Expand All @@ -46,8 +52,8 @@ subprojects {
}

tasks {
withType<JavaCompile> { options.encoding = "UTF-8" }
//一般配置
withType<JavaCompile> { options.encoding = "UTF-8" } //UTF-8 编码
//一般配置
withType<ShadowJar> {
// Options
archiveAppendix.set("")
Expand All @@ -57,7 +63,7 @@ subprojects {
// Exclude
exclude("META-INF/**")
exclude("com/**", "org/**")
// Adventure (不需要,因为是动态加载)
// Adventure (不需要,因为是动态加载)
//relocate("net.kyori", "$rootGroup.common.adventure")
// Taboolib
relocate("taboolib", "$rootGroup.taboolib")
Expand All @@ -73,4 +79,5 @@ subprojects {

buildDirClean()

//工件输出
output()
4 changes: 1 addition & 3 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@ plugins {

repositories {
mavenCentral()
}

gradle.buildFinished { buildDir.deleteRecursively() }
}
44 changes: 37 additions & 7 deletions buildSrc/src/main/kotlin/Dependencies.kt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import org.gradle.api.Project
import org.gradle.api.artifacts.dsl.DependencyHandler
import org.gradle.api.artifacts.dsl.RepositoryHandler
Expand All @@ -14,21 +13,30 @@ fun PluginAware.applyPlugins() {
}

fun Project.buildDirClean() {
@Suppress("DEPRECATION")
gradle.buildFinished { buildDir.deleteRecursively() }
@Suppress("DEPRECATION") gradle.buildFinished { buildDir.deleteRecursively() }
}

/**
* 项目通用储存库
*/
fun RepositoryHandler.projectRepositories() {
maven(repoTabooProject) {
isAllowInsecureProtocol = true
}
mavenCentral()
}

/**
* NMS依赖
*/
fun DependencyHandler.compileNMS() {
add("compileOnly", "ink.ptms:nms-all:1.0.0")
}

/**
* 核心依赖
* @param version 核心版本号
*/
fun DependencyHandler.compileCore(
version: Int,
minimize: Boolean = true,
Expand All @@ -40,17 +48,24 @@ fun DependencyHandler.compileCore(
add("compileOnly", notation)
}


/**
* Adventure依赖
*/
fun DependencyHandler.adventure() {
adventureModules.forEach {
add("compileOnly", it)
}
adventureModules.forEach { add("compileOnly", it) }
}

/**
* Taboolib通用依赖
*/
fun DependencyHandler.compileTabooLib() {
taboolibModules.forEach { installTaboo(it) }
}

/**
* 依赖项目——仅编译时
* @param name 项目名称
*/
fun DependencyHandler.compileModule(name: String) {
add("compileOnly", project(":project:$name"))
}
Expand All @@ -59,10 +74,25 @@ fun DependencyHandler.installModule(name: String) {
add("implementation", project(":project:$name"))
}

/**
* 依赖所有项目——仅编译时
*/
fun DependencyHandler.compileAll() {
project(":project").dependencyProject.childProjects.forEach { add("compileOnly", it.value) }
}

/**
* 依赖Taboolib模块——仅编译时
* @param module Taboolib模块名称
* @param version Taboolib模块版本,默认为Taboolib班恩
*/
fun DependencyHandler.installTaboo(vararg module: String, version: String = taboolibVersion) = module.forEach {
add("compileOnly", "io.izzel.taboolib:$it:$version")
}

/**
* 依赖Taboolib模块
*/
fun DependencyHandler.shadowTaboo(vararg module: String, version: String = taboolibVersion) = module.forEach {
add("implementation", "io.izzel.taboolib:$it:$version")
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import java.io.File
object WorkSpaceLoader {

/**
* 获取工作空间
* @param paths 工作空间路径的字符串表现
* 获取工作空间
* @param paths 工作空间路径的字符串表现
*/
fun getWorkSpaces(paths: Iterable<String>): List<WorkSpace> {
return paths.map { WorkSpace(File(it)) }
Expand Down
2 changes: 1 addition & 1 deletion project/module-common/src/main/resources/lang/en_US.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Language file - Translated by Youdao Translator
# Last updated: 2023/6/18 ÔÝÍ£¸üÐÂ
# Last updated: 2023/6/18 暂停更新

# Due to force majeure,Bukkit and Bungee have the same configuration file

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import java.io.File

class WorkSpace(
/**
* 工作空间路径
* 工作空间路径
*/
val path: File
) {

/**
* 获取工作空间中的文件
* 获取工作空间中的文件
*/
fun getFiles(): Iterator<File> {
return path.listFilesDeep()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package cn.fd.utilities.util
import java.io.File

/**
* Éî¶ÈÎļþ»ñÈ¡
* 深度文件获取
*/
fun File.listFilesDeep(): Iterator<File> {
return this.walk().filter { it.isFile }.iterator()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ package cn.fd.utilities.script
abstract class ScriptF {

/**
* 脚本标识符(名称)
* 脚本标识符(名称)
*/
val name: String = this.javaClass.name

/**
* 脚本被加载时触发
* 脚本被加载时触发
*/
abstract fun init()

/**
* 脚本启用时触发
* 脚本启用时触发
*/
abstract fun enable()

/**
* 脚本禁用时触发
* 脚本禁用时触发
*/
abstract fun disable()

Expand Down
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
package cn.fd.utilities.script.api

/**
* 运行库加载器
* 运行库加载器
*
* @author 坏黑
* @author 坏黑
* @since 2022/5/16 01:01
*/
interface RuntimeClassLoader {

/**
* 获取所有已加载的类
* 获取所有已加载的类
*/
fun runningClasses(): Map<String, Class<*>>

/**
* 获取类
* 获取类
*/
fun findClass(name: String): Class<*>
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import java.io.File
interface ScriptMeta {

/**
* 脚本名称
* 脚本名称
*/
fun name(): String

/**
* 脚本源文件
* 脚本源文件
*/
fun source(file: File)

/**
* 脚本编译后的缓存文件
* 脚本编译后的缓存文件
*/
fun compiled(file: File)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import taboolib.common.platform.command.subCommand

@PlatformSide([Platform.BUKKIT])
@CommandHeader(name = "fdutilities")
object MainCommand {
object TestCommand {

/**
* ÖØÔزå¼þµÄÃüÁî
*/
@CommandBody
val main = mainCommand {
execute<ProxyCommandSender> { sender, _, _ ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import cn.fd.utilities.env.CommonEnv
import taboolib.common.env.RuntimeEnv
import taboolib.common.platform.Awake

//感觉有点小题大做
//感觉有点小题大做
object DependenciesLoader {

/**
* 加载依赖项
* 加载依赖项
*/
@Awake
fun loadDependency() {
Expand Down
5 changes: 0 additions & 5 deletions script/test01/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,2 @@
dependencies {
rootProject.allprojects.forEach {
if (it.parent?.name == "project" || it.parent?.name == "plugin") {
implementation(it)
}
}
}

0 comments on commit 89a0d2d

Please sign in to comment.