Drew
01/24/2019, 4:40 PMkotlin.js from a js mpp target?hallvard
01/25/2019, 9:22 AMkotlin {
targets {
fromPreset(presets.js, 'js') {
tasks.getByName(compilations.main.compileKotlinTaskName).kotlinOptions {
// verbose = true
sourceMap = true
sourceMapEmbedSources = "always"
suppressWarnings = true
metaInfo = true
outputFile = "$project.buildDir.path/js/${project.name}.js"
...Drew
01/25/2019, 3:43 PMoutput.js, or the Kotlin platform kotlin.js that needs to go with it? I think outputFile refers to output.jsDrew
01/25/2019, 3:44 PMkotlin.js as part of the build process, after searching this Slack:
task linkJs {
dependsOn "compileKotlinJs"
doLast {
def jsMain = kotlin.targets.js.compilations.main
jsMain.runtimeDependencyFiles.each { file ->
copy {
from(zipTree(file.absolutePath), {
includeEmptyDirs = false
include { fileTreeElement ->
def path = fileTreeElement.path
path.endsWith(".js") && (path.startsWith("META-INF/resources/") ||
!path.startsWith("META-INF/"))
}
})
into jsMain.output.classesDirs.getAsPath()
}
}
}
}
jsMainClasses.dependsOn("linkJs")hallvard
01/25/2019, 3:44 PMDrew
01/25/2019, 3:45 PMhallvard
01/25/2019, 6:47 PMAllison
01/30/2019, 2:56 PMDrew
01/30/2019, 7:06 PMDrew
01/31/2019, 4:37 PMDrew
01/31/2019, 4:38 PMAllison
01/31/2019, 5:31 PMDrew
01/31/2019, 6:48 PMtask linkJs {
dependsOn "compileKotlinJs"
doLast {
def jsMain = kotlin.targets.js.compilations.main
jsMain.runtimeDependencyFiles.each { file ->
copy {
from(zipTree(file.absolutePath), {
includeEmptyDirs = false
include { fileTreeElement ->
def path = fileTreeElement.path
path.endsWith(".js") && (path.startsWith("META-INF/resources/") ||
!path.startsWith("META-INF/"))
}
})
into jsMain.output.classesDirs.getAsPath()
}
}
// Append all JS into one file
// Very rudimentary, but you get the idea
List<File> jsFiles = new ArrayList<File>()
File kotlin = new File(jsMain.output.classesDirs.getAsPath() + "/kotlin.js")
File kotlinSerialization = new File(jsMain.output.classesDirs.getAsPath() + "/kotlinx-serialization-runtime-js.js")
File output = new File(jsMain.output.classesDirs.getAsPath() + "/output.js")
jsFiles.add(kotlin)
jsFiles.add(kotlinSerialization)
jsFiles.add(output)
File commonOutput = new File(jsMain.output.classesDirs.getAsPath() + "/common_output.js")
commonOutput.createNewFile()
commonOutput.write("")
for(File jsFile : jsFiles) {
commonOutput.append(jsFile.text + "\n")
}
}
}
jsMainClasses.dependsOn("linkJs")Allison
02/01/2019, 10:12 AM