Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Gradle publish depending on custom task using Kotlin dsl

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) {
            ...
        }
    }
}
like image 969
Pavel Avatar asked Apr 25 '19 11:04

Pavel


1 Answers

Can do it like this

tasks.withType<PublishToMavenRepository> {
  dependsOn("doSomething")
}
like image 187
Strelok Avatar answered Oct 14 '22 12:10

Strelok