Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #181 from novoda/error-handling
Browse files Browse the repository at this point in the history
give quicker feedback when setup incorrect
  • Loading branch information
mr-archano authored Feb 5, 2018
2 parents a18eed0 + 978d6a7 commit 2fef259
Showing 1 changed file with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,48 @@ 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<Project> {

@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)
new BintrayConfiguration(extension).configure(project)
}
}

/**
* 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 ->
Expand Down

0 comments on commit 2fef259

Please sign in to comment.