| 1 |
import org.gradle.configurationcache.extensions.capitalized |
| 2 |
|
| 3 |
val tempRepoName by extra("temp") |
| 4 |
val tempRepoDir by extra { |
| 5 |
layout.buildDirectory.dir("repo").get().asFile |
| 6 |
} |
| 7 |
|
| 8 |
val clearTempRepoDir by tasks.registering { |
| 9 |
val dir = tempRepoDir |
| 10 |
doFirst { |
| 11 |
dir.deleteRecursively() |
| 12 |
} |
| 13 |
} |
| 14 |
|
| 15 |
subprojects { |
| 16 |
pluginManager.withPlugin("maven-publish") { |
| 17 |
configure<PublishingExtension> { |
| 18 |
repositories { |
| 19 |
maven { |
| 20 |
name = tempRepoName |
| 21 |
url = uri(tempRepoDir) |
| 22 |
} |
| 23 |
} |
| 24 |
} |
| 25 |
tasks.withType<PublishToMavenRepository>().configureEach { |
| 26 |
if (name.endsWith("To${tempRepoName.capitalized()}Repository")) { |
| 27 |
dependsOn(clearTempRepoDir) |
| 28 |
} |
| 29 |
} |
| 30 |
} |
| 31 |
} |