Skip to content

Commit

Permalink
脚本编译目录输出 编码修复(漏掉了)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheFloodDragon committed Jul 12, 2023
1 parent 89a0d2d commit bbb758a
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 24 deletions.
33 changes: 18 additions & 15 deletions buildSrc/src/main/kotlin/CompiledOutputer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,35 @@ const val outputFolder = "outs"

//输出编译后的文件到./outs
fun Project.output() {
gradle.buildFinished {
@Suppress("DEPRECATION") gradle.buildFinished {
val outDir = File(rootDir, outputFolder)
rootProject
.childProjects["plugin"]!!.childProjects.values
.forEach {
val platformStr =
if (it.name.equals("all")) "" else "-${it.name.split('-')[1].capitalized()}"
it.outCopy(
File(outDir, "$rootName$platformStr-${it.version}.jar")
)
allprojects.forEach {
if (it.parent?.name.equals("plugin")) {
it.outCopy(File(outDir, nameOfPlugin(it)))
} else if (it.parent?.name.equals("script")) {
it.outCopy(File(outDir, nameOfScript(it)))
}
}
}
}

fun nameOfPlugin(p: Project): String {
return if (p.name.equals("all"))
"$rootName-${p.version}.jar"
else "$rootName-${p.name.split('-')[1].capitalized()}-${p.version}.jar"
}

// rootProject TODO do after 8000 years
// .childProjects["module"]!!.childProjects.values
// .forEach { copyByProject(it) }
fun nameOfScript(p: Project): String {
return "Script-${p.name.capitalized()}-${p.version}.jar"
}

/**
* 复制项目输出文件到指定目录
*/
fun Project.outCopy(
target: File,//输出目标
source: File? = this.catchOut()//
target: File,
source: File? = this.catchOut()
) {
//outDir.mkdirs().takeIf { !outDir.exists() } //先创建文件
//复制
source?.copyTo(target, true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@ import cn.fd.utilities.script.ScriptF
object TestScript : ScriptF() {

init {
println("static test")
println("static test-01")
}

override fun init() {
println("init")
println("init-01")
println(name)
}

override fun enable() {
println("enable")
println("enable-01")
}

override fun disable() {
println("disable")
println("disable-01")
}

}
2 changes: 2 additions & 0 deletions script/test02/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dependencies {
}
24 changes: 24 additions & 0 deletions script/test02/src/main/kotlin/cn/fd/utilities/test/TestScript.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cn.fd.utilities.test

import cn.fd.utilities.script.ScriptF

object TestScript : ScriptF() {

init {
println("static test-02")
}

override fun init() {
println("init-02")
println(name)
}

override fun enable() {
println("enable-02")
}

override fun disable() {
println("disable-02")
}

}
10 changes: 5 additions & 5 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
rootProject.name = "FDUtilities"

applyAll("project")
applyAll("script")
apply("project")
apply("script")

//Bukkit
include("plugin:platform-bukkit")
//全部聚合版
//全部聚合版
include("plugin:all")

//所有字项目的加载(懒得自己一个一个打)
fun applyAll(name: String) {
//所有字项目的加载(懒得自己一个一个打)
fun apply(name: String) {
File("${rootDir}\\$name").listFiles()?.filter { it.isDirectory }?.forEach {
include("$name:${it.name}")
}
Expand Down

0 comments on commit bbb758a

Please sign in to comment.