GarouDan
02/11/2019, 11:09 PMjsJar.dependsOn(populateWebFolder)build.gradlebuild.gradle.ktsdef webFolder = new File(project.buildDir, "../src/jsMain/web")
def jsCompilations = kotlin.targets.js.compilations
task populateWebFolder(dependsOn: [jsMainClasses]) {
    doLast {
        copy {
            from jsCompilations.main.output
            from kotlin.sourceSets.jsMain.resources.srcDirs
            jsCompilations.test.runtimeDependencyFiles.each {
                if (it.exists() && !it.isDirectory()) {
                    from zipTree(it.absolutePath).matching { include '*.js' }
                }
            }
            into webFolder
        }
    }
}
jsJar.dependsOn(populateWebFolder)
task run(type: JavaExec, dependsOn: [jvmMainClasses, jsJar]) {
    main = "sample.SampleJvmKt"
    classpath { [
            kotlin.targets.jvm.compilations.main.output.allOutputs.files,
            configurations.jvmRuntimeClasspath,
    ] }
    args = []
}GarouDan
02/11/2019, 11:13 PMval webFolder = File(project.buildDir, "../src/main/web")
val jsCompilations = kotlin.targets["js"].compilations
task("populateWebFolder"){
	dependsOn("jsMainClasses")
	doLast {
		copy {
			from(jsCompilations["main"].output)
				from(kotlin.sourceSets["jsMain"].resources.srcDirs)
			(jsCompilations["test"]as KotlinJsCompilation).runtimeDependencyFiles.forEach {
					if (it.exists() && !it.isDirectory()) {
						from(zipTree(it.absolutePath).matching { include("*.js") })
					}
				}
			into(webFolder)
		}
	}
}
tasks.getByName("jsJar") {
	dependsOn("populateWebFolder")
}hudsonb
02/12/2019, 10:29 AM