Hi im trying to translate something groovy/gradle ...
# gradle
j
Hi im trying to translate something groovy/gradle to kotlin gradle. In the original groovy it would be done like so:
Copy code
reobfJar {
    shadowJar
}
I can't figure out how to do this in kotlin. reobfJar is a task. I want the reobfJar task to also be run on the shadowJar too. (not sure quite how this works unfortunately) The closest i've got i think is:
Copy code
tasks.all {
    println("Task $this, path ${this.path}")
    if (this.path == ":reobfJar") {
        println("I AM REOBFJAR!")
        this.configure<net.minecraftforge.gradle.patcher.tasks.ReobfuscateJar> {
            tasks.getByName("shadowJar")
        }
    }
}
I can't figure out how to get the reobfjar task without iterating, .getByPath doesn't seem to work. But also this.configure seems to want an Extension instead of a task? No clue what im supposed to do here.
v
Are you sure
Copy code
reobfJar {
    shadowJar
}
does what you expect it does? To me it looks as you just set up that during the configuration phase of
reobfJar
the
shadowJar
task is realized. But nothing "is run on something else" or configured or connected. From a quick look at the sources of that plugin I'd say they are not really Kotlin DSL friendly and what you want to achieve is probably
Copy code
(extensions["reobf"] as NamedDomainObjectContainer<*>).create("shadowJar")