https://kotlinlang.org logo
Title
g

GarouDan

02/11/2019, 11:09 PM
Guys, I’m trying to translate this excerpt
jsJar.dependsOn(populateWebFolder)
from a
build.gradle
file to a
build.gradle.kts
. How can I do this? This is part of:
def 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 = []
}
I think I have what I need:
val 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")
}
h

hudsonb

02/12/2019, 10:29 AM
#gradle