GarouDan
03/04/2019, 8:09 PMbuild.gradle.kts
format.
Does someone knows how to do that?
task jsinterop(type: Exec) {
workingDir projectDir
def ext = MPPTools.isWindows() ? '.bat' : ''
def distributionPath = project.properties['org.jetbrains.kotlin.native.home'] as String
if (distributionPath != null) {
def jsinteropCommand = Paths.get(file(distributionPath).path, 'bin', "jsinterop$ext").toString()
inputs.property('jsinteropCommand', jsinteropCommand)
inputs.property('jsinteropPackageName', packageName)
outputs.file(jsinteropKlibFileName)
commandLine jsinteropCommand,
'-pkg', packageName,
'-o', jsinteropKlibFileName,
'-target', 'wasm32'
} else {
doFirst {
// Abort build execution if the distribution path isn't specified.
throw new GradleException("""\
|Kotlin/Native distribution path must be specified to build the JavaScript interop.
|Use 'org.jetbrains.kotlin.native.home' project property to specify it.
""".stripMargin())
}
}
}
tasks.withType(KotlinNativeCompile).all {
dependsOn jsinterop
}
Where I’m using this kotlin project as a basis:
https://github.com/JetBrains/kotlin-native/blob/master/samples/html5Canvas/build.gradleGarouDan
03/05/2019, 1:12 AMval jsinterop = tasks.create("jsinterop", Exec::class.java) {
workingDir = projectDir
val os = org.gradle.internal.os.OperatingSystem.current()!!
val ext = if (os.isWindows) ".bat" else ""
val distributionPath = project.properties["konanHome"] as String
val jsinteropCommand = Paths.get(file(distributionPath).path, "bin", "jsinterop$ext").toString()
inputs.property("jsinteropCommand", jsinteropCommand)
inputs.property("jsinteropPackageName", packageName)
outputs.file(jsinteropKlibFileName)
commandLine(
jsinteropCommand,
"-pkg",
packageName,
"-o",
jsinteropKlibFileName,
"-target",
"wasm32"
)
}
tasks.withType(KotlinNativeCompile::class.java).all {
dependsOn(jsinterop)
}