-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhelpers.gradle
87 lines (78 loc) · 2.52 KB
/
helpers.gradle
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import java.awt.Desktop
task("linkJs") {
dependsOn "compileKotlinJs"
doLast {
def main = kotlin.targets.js.compilations.main
main.runtimeDependencyFiles.filter {
it.name.endsWith(".jar")
}.each { File file ->
copy {
includeEmptyDirs = false
from(zipTree(file.absolutePath))
into main.output.classesDir.absolutePath + "/lib"
include { fileTreeElement ->
def path = fileTreeElement.path
def isJsFile = path.endsWith(".js")
def isResource = path.startsWith("META-INF/resources/")
def isMeta = path.startsWith("META-INF/")
isJsFile && (isResource || !isMeta)
}
}
}
}
}
task("linkTestJs") {
dependsOn "compileTestKotlinJs"
doLast {
def test = kotlin.targets.js.compilations.test
test.runtimeDependencyFiles.filter {
it.name.endsWith(".jar")
}.each { File file ->
copy {
includeEmptyDirs = false
from(zipTree(file.absolutePath))
into test.output.classesDir.absolutePath + "/lib"
include { fileTreeElement ->
def path = fileTreeElement.path
def isJsFile = path.endsWith(".js")
def isResource = path.startsWith("META-INF/resources/")
def isMeta = path.startsWith("META-INF/")
isJsFile && (isResource || !isMeta)
}
}
}
}
}
jsMainClasses.dependsOn("linkJs")
jsTestClasses.dependsOn("linkTestJs")
jsTest.doLast {
Desktop.getDesktop().open(new File("src/jsTest/test.html"))
}
task("runJs") {
dependsOn "jsMainClasses"
doLast {
Desktop.getDesktop().open(new File("src/jsMain/index.html"))
}
}
task("runJvm") {
dependsOn "jvmMainClasses"
doLast { javaexec {
standardInput = System.in
def jvmMain = kotlin.targets.jvm.compilations.main
classpath = jvmMain.output.classesDirs
jvmMain.runtimeDependencyFiles.filter {
it.name.endsWith(".jar")
}.each {
classpath += files(it)
}
main = 'coinche.MainKt'
} }
}
task("runMacos") {
dependsOn "linkReleaseExecutableMacos"
doLast { exec {
standardInput = System.in
def binary = kotlin.targets.macos.compilations.main.getBinary('EXECUTABLE', 'RELEASE')
commandLine binary
} }
}