10

I'm switching from groovy to Kotlin dsl (build.gradle.kts) for Gradle builds. My publish artifact depends on my custom task. And I do not understand how to make this dependency in Kotlin dsl.

Original groovy code that I like to migrate to Kotlin dsl:

publish.dependsOn doSomething

Tasks that I am trying to chain:

val doSomething by tasks.creating(ShellExec::class) {
    command = "./do-something"
}

publishing {
    repositories {
        maven {
            ...
        }
    }

    publications {
        register("mavenJava", MavenPublication::class) {
            ...
        }
    }
}
Pavel
  • 653
  • 2
  • 11
  • 31

1 Answers1

25

Can do it like this

tasks.withType<PublishToMavenRepository> {
  dependsOn("doSomething")
}
Strelok
  • 50,229
  • 9
  • 102
  • 115