generated from EraTiem-Network/Kotlin-Plugin-Template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings.gradle.kts
57 lines (46 loc) · 1.7 KB
/
settings.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
rootProject.name = "ServerAccessManager"
/**
* Activate or deactivate modules.
*
* Deactivate with caution as it will remove the corresponding directory!!!
*/
val modules: Map<String, Boolean> = mapOf(
"tools" to true,
"spigot" to false,
"paper" to false,
"folia" to false,
"bungeecord" to true,
"waterfall" to false,
"velocity" to true
)
val modulesWithPluginYAML: List<String> = listOf(
"spigot", "paper", "folia", "bungeecord", "waterfall"
)
val moduleResources =
File("${rootProject.projectDir.absolutePath}${File.separator}gradle${File.separator}module-resources")
val basePluginYAML = File("${moduleResources.path}${File.separator}plugin.yml")
modules.forEach { (moduleName, active) ->
val moduleDir = File("${rootProject.projectDir.absolutePath}${File.separator}$moduleName")
if (active) {
if (!moduleDir.exists())
createModuleFolder(moduleName, moduleDir)
include(moduleName)
} else {
if (moduleDir.exists())
moduleDir.deleteRecursively()
}
}
fun createModuleFolder(moduleName: String, moduleDir: File) {
val baseModuleBuildScript = File("${moduleResources.path}${File.separator}$moduleName.kts")
val moduleBuildScript = File("${moduleDir.path}${File.separator}build.gradle.kts")
val moduleMainKotlinDir = File("${moduleDir.path}${File.separator}src${File.separator}main${File.separator}kotlin")
moduleDir.mkdirs()
moduleMainKotlinDir.mkdirs()
baseModuleBuildScript.copyTo(moduleBuildScript)
if (moduleName in modulesWithPluginYAML) {
val modulePluginYAML =
File("${moduleMainKotlinDir.parentFile.path}${File.separator}resources${File.separator}plugin.yml")
modulePluginYAML.parentFile.mkdirs()
basePluginYAML.copyTo(modulePluginYAML)
}
}