how to convert ```task buildZip(type: Zip) { f...
# gradle
i
how to convert
Copy code
task buildZip(type: Zip) {
    from compileJava
    from processResources              
    into('lib') {
        from configurations.runtime
    }
}
into kotlin? There are many examples related to file copying but I have trouble finding info on how to refer to
compileJava
and
processResources
in kts
this is what I have currently ...
Copy code
tasks.register<Zip>("buildZip") {
//    from(compileJava)
//    from(processResources)

    from(sourceSets.main.get().output)

    into("lib") {
        from(configurations.runtimeClasspath)
    }
}
j
That’s
tasks.compileJava
In Groovy DSL you can reference tasks directly by just using a task name and Gradle will magically discover it. Which seems like a good idea for simplicity when it was invented, but nowadays it is only confusing.
I did a quite similar example here if you are interested in more details: https://github.com/jjohannes/understanding-gradle/blob/main/06_Configuring_Task_In[…]gic/java-plugins/src/main/kotlin/my-java-application.gradle.kts (see Readme/video in the repo)
456 Views