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

give quicker feedback when setup incorrect #181

Merged
merged 2 commits into from
Feb 5, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are they all mandatory? I was thinking the description can be optional.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}
}

void attachArtifacts(PublishExtension extension, Project project) {
if (project.plugins.hasPlugin('com.android.library')) {
project.android.libraryVariants.all { variant ->
Expand Down