Skip to content

Commit

Permalink
Initial release version
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Nov 6, 2014
1 parent 4a119f5 commit 527387e
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 11 deletions.
39 changes: 28 additions & 11 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import net.serenitybdd.builds.ProjectVersionCounter

buildscript {
repositories {
jcenter()
Expand All @@ -7,7 +9,6 @@ buildscript {
}
dependencies {
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:0.6'
classpath 'nz.org.geonet:gradle-build-version-plugin:1.0.4'
}
}

Expand All @@ -19,24 +20,18 @@ allprojects {
apply plugin: 'maven'
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'build-version'


buildVersion {
releaseTagPattern = "^v(\\d+\\.\\d+\\.\\d+)"
}

sourceCompatibility = 1.7
targetCompatibility = 1.7
group = 'net.serenity-bdd'
version = buildVersion.version

repositories {
mavenLocal()
jcenter()
}

ext {
versionCounter = new ProjectVersionCounter(project.hasProperty("releaseBuild"))

bintrayBaseUrl = 'https://api.bintray.com/maven'
bintrayRepository = 'maven'
bintrayPackage = 'serenity-core'
Expand All @@ -49,6 +44,23 @@ allprojects {
}
}

group = 'net.serenity-bdd'
version = versionCounter.nextVersion

task createNewVersionTag(type: Exec) {
executable "sh"
args "-c", "git tag -f -a v$version -m'release tag'"
}

task publishNewVersionTag(type: Exec, dependsOn: 'createNewVersionTag') {
executable "sh"
args "-c", "git push -f origin v$version"
}

task tagNextVersion() {
dependsOn publishNewVersionTag
}

task wrapper(type: Wrapper) {
gradleVersion = '2.1'
}
Expand Down Expand Up @@ -146,6 +158,12 @@ allprojects {
labels = ['serenity','bdd']
}
}

task release() {
dependsOn bintrayUpload,publishNewVersionTag
}

publishNewVersionTag.mustRunAfter bintrayUpload
}

subprojects {
Expand All @@ -163,7 +181,6 @@ subprojects {
archives sourcesJar, javadocJar
}


publishing {
publications {
mavenJava(MavenPublication) {
Expand Down Expand Up @@ -223,4 +240,4 @@ subprojects {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:-options"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package net.serenitybdd.builds

class ProjectVersionCounter {
final Boolean isRelease;

ProjectVersionCounter(Boolean isRelease) {
this.isRelease = isRelease
}

def getNextVersion() {
def currentVersion = "git describe --tags".execute().text
if (currentVersion.isEmpty()) {
currentVersion = "v1.0.0"
}
def matcher = currentVersion =~ "\\d+"
def majorMinorNumbers = matcher[0] + "." + matcher[1]
def currentBuildNumber = Integer.valueOf(matcher[2])
def nextBuildNumber = currentBuildNumber + 1
return (isRelease) ?
majorMinorNumbers + "." + nextBuildNumber :
majorMinorNumbers + "." + nextBuildNumber + "-SNAPSHOT"
}
}

0 comments on commit 527387e

Please sign in to comment.