Hello,
I have tasks like this
val downloadFigletFonts by registering(de.undercouch.gradle.tasks.download.Download::class) {
src("....")
dest("$buildDir/assets/...")
onlyIfModified(true)
useETag("all") // Use the ETag on GH
}
I rewritten those as custom task so now I can use
val download1 by registering(MyDownload::class) {
sourceUrl.set("...")
}
However I experimented with a custom registering
extension method, the original code is
fun <T : Any, C : PolymorphicDomainObjectContainer<T>, U : T> C.registering(
type: KClass<U>,
action: U.() -> Unit
): RegisteringDomainObjectDelegateProviderWithTypeAndAction<out C, U> =
RegisteringDomainObjectDelegateProviderWithTypeAndAction.of(this, type, action)
So I tried to write
fun <C : PolymorphicDomainObjectContainer<Task>> C.registeringDownload(
src: String,
): RegisteringDomainObjectDelegateProviderWithTypeAndAction<out C, Download> =
RegisteringDomainObjectDelegateProviderWithTypeAndAction.of(this, Download::class) {
src(src)
dest("${buildDir}/gangshit-figlet-fonts-master.zip")
onlyIfModified(true)
useETag("all") // Use the ETag on GH
}
And declared this way
val download1 by registeringDownload("...")
My question is do you think it’s a good approach?