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 #29 from novoda/27/handle_version_2
Browse files Browse the repository at this point in the history
27/Re-add support for publish.version
  • Loading branch information
blundell committed Apr 8, 2015
2 parents 51c0f8f + d1eec71 commit 7ca772a
Showing 1 changed file with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,12 @@ class ReleasePlugin implements Plugin<Project> {

void attachArtifacts(Project project) {
Artifacts artifacts = project.plugins.hasPlugin('com.android.library') ? new AndroidArtifacts() : new JavaArtifacts()
String projectVersion = getString(project, 'version', project.publish.version)
project.publishing {
publications {
maven(MavenPublication) {
groupId project.publish.groupId
artifactId project.publish.artifactId
version projectVersion
version getProjectProperty(project, 'version', project.publish.version)

artifacts.all(project).each {
delegate.artifact it
Expand All @@ -43,8 +42,16 @@ class ReleasePlugin implements Plugin<Project> {
}
}

private String getString(Project project, String propertyName, String defaultValue) {
project.hasProperty(propertyName) ? project.getProperty(propertyName) : defaultValue
private String getProjectProperty(Project project, String propertyName, String defaultValue) {
if (isPropertySet(project, propertyName)) {
return project.getProperty(propertyName)
} else {
return defaultValue
}
}

private boolean isPropertySet(Project project, String propertyName) {
project.hasProperty(propertyName) && project.getProperty(propertyName) != 'unspecified'
}

}

0 comments on commit 7ca772a

Please sign in to comment.