-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
43 lines (36 loc) · 1.19 KB
/
build.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
import kotlin.io.path.exists
plugins {
`java-library`
}
tasks {
register<Copy>("copyMods") {
dependsOn("build")
from(project.projectDir)
gradle.includedBuilds.forEach { build ->
var path = build.projectDir.toPath()
if (path.resolve("forge").exists()) {
path = path.resolve("forge")
}
if (path.resolve("Forge").exists()) {
path = path.resolve("Forge")
}
val libs = path.resolve("build").resolve("libs").toFile()
val files = libs.listFiles() ?: return@forEach
var hasShadow = false
files.filter {
val name = it.name
hasShadow = hasShadow || name.contains("shadow") || name.contains("all")
name.endsWith("jar") && !name.contains("source")
}.filter {
!hasShadow || it.name.contains("shadow")
}.forEach { jar ->
print(jar.path)
include(jar.path)
}
}
into("../mods")
}
named("build") {
dependsOn(*gradle.includedBuilds.map { build -> build.task(":build") }.toTypedArray())
}
}