11@file:Suppress(" PackageDirectoryMismatch" )
22
3- import extensions.propertyOrEnv
43import org.gradle.api.Project
54import org.gradle.api.publish.PublishingExtension
65import org.gradle.api.publish.maven.MavenPublication
@@ -15,7 +14,6 @@ object Publishing {
1514fun PublishingExtension.setupAllPublications (project : Project ) {
1615 val mavenPublications = publications.withType<MavenPublication >()
1716 mavenPublications.configureEach { setupPom() }
18- if (project.isSnapshot.not ()) setupDevPublishRepo(project)
1917 project.registerPublishingTask()
2018 project.tasks.named(" publishPlugins" ).configure {
2119 doFirst {
@@ -34,44 +32,23 @@ private fun Project.registerPublishingTask() {
3432
3533 val publishTaskName = when {
3634 isSnapshot -> " publishToMavenLocal"
37- else -> " publishAllPublicationsToBintrayRepository "
35+ else -> null // TODO: Replace with a dev repo making up for bintray?
3836 }
39- val publishTask = tasks.named(publishTaskName)
37+ val publishTask = publishTaskName?. let { tasks.named(it) }
4038
41- publishTask.configure { dependsOn(" validatePlugins" ) }
39+ publishTask? .configure { dependsOn(" validatePlugins" ) }
4240
4341 tasks.register(" publishToAppropriateRepo" ) {
4442 group = " publishing"
4543 description = " Publishes the Gradle plugin to the appropriate repository, depending on the version."
46- dependsOn(publishTask)
44+ publishTask?. let { dependsOn(it) }
4745 if (isSnapshot.not () && isDevVersion.not ()) dependsOn(" publishPlugins" )
4846 }
4947}
5048
5149private val Project .isDevVersion get() = version.let { it is String && it.contains(" -dev-" ) }
5250private val Project .isSnapshot get() = version.let { it is String && it.endsWith(" -SNAPSHOT" ) }
5351
54- private fun PublishingExtension.setupDevPublishRepo (project : Project ) {
55- repositories {
56- maven {
57- name = " bintray"
58- val bintrayUsername = " jmfayard"
59- val bintrayRepoName = " maven"
60- val bintrayPackageName = " de.fayard.refreshVersions"
61- setUrl(
62- " https://api.bintray.com/maven/" +
63- " $bintrayUsername /$bintrayRepoName /$bintrayPackageName /;" +
64- " publish=1;" +
65- " override=1"
66- )
67- credentials {
68- username = project.propertyOrEnv(" bintray_user" )
69- password = project.propertyOrEnv(" bintray_api_key" )
70- }
71- }
72- }
73- }
74-
7552@Suppress(" UnstableApiUsage" )
7653private fun MavenPublication.setupPom () = pom {
7754 name.set(" refreshVersions" )
0 commit comments