From 7ba010e395fa006f45a3efe60265fcc92ebfc97b Mon Sep 17 00:00:00 2001 From: Blundell Date: Sun, 4 Feb 2018 19:52:19 +0000 Subject: [PATCH] give quicker feedback when setup incorrect --- .../gradle/release/ReleasePlugin.groovy | 30 ++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/core/src/main/groovy/com/novoda/gradle/release/ReleasePlugin.groovy b/core/src/main/groovy/com/novoda/gradle/release/ReleasePlugin.groovy index 3c1af88..d562be9 100644 --- a/core/src/main/groovy/com/novoda/gradle/release/ReleasePlugin.groovy +++ b/core/src/main/groovy/com/novoda/gradle/release/ReleasePlugin.groovy @@ -4,13 +4,14 @@ import com.jfrog.bintray.gradle.BintrayPlugin import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.publish.maven.MavenPublication -import org.gradle.util.GradleVersion class ReleasePlugin implements Plugin { + @Override void apply(Project project) { PublishExtension extension = project.extensions.create('publish', PublishExtension) project.afterEvaluate { + checkClosureSetup(extension) project.apply([plugin: 'maven-publish']) attachArtifacts(extension, project) new BintrayPlugin().apply(project) @@ -18,6 +19,33 @@ class ReleasePlugin implements Plugin { } } + /** + * Give the user quicker and more obvious feedback when they + * haven't set their project up correctly + */ + private static void checkClosureSetup(PublishExtension extension) { + String extensionError = ""; + if (extension.userOrg == null) { + extensionError += "Missing userOrg. " + } + if (extension.groupId == null) { + extensionError += "Missing groupId. " + } + if (extension.artifactId == null) { + extensionError += "Missing artifactId. " + } + if (extension.publishVersion == null) { + extensionError += "Missing publishVersion. " + } + if (extension.desc == null) { + extensionError += "Missing desc. " + } + if (extensionError) { + String prefix = "Have you created the publish closure? " + throw new IllegalStateException(prefix + extensionError) + } + } + void attachArtifacts(PublishExtension extension, Project project) { if (project.plugins.hasPlugin('com.android.library')) { project.android.libraryVariants.all { variant ->