Skip to content

Instantly share code, notes, and snippets.

@fleficher
Created January 26, 2020 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fleficher/72dd54b849de6a1735e3416d32632b38 to your computer and use it in GitHub Desktop.
Save fleficher/72dd54b849de6a1735e3416d32632b38 to your computer and use it in GitHub Desktop.
custom task with KTS
// Our custom task inside buildSrc folder
open class PingUrlTask : DefaultTask() {
@Input
lateinit var url: String
@TaskAction
fun updateTranslations() {
println("Begin task")
val request = Request.Builder()
.url(url)
.build()
val client = OkHttpClient()
val response = client.newCall(request).execute()
if (response.isSuccessful) {
println("🚀 Ping SUCCEED ✅︎")
} else {
println("🚀 Ping Failed !")
}
}
}
// inside your main: build.gradle.kts :
task<tasks.PingUrlTask>("pingUrl") {
url = "https://www.google.com"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment