diff --git a/build.gradle b/build.gradle index ca06d130d6..246ca59163 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import net.serenitybdd.builds.ProjectVersionCounter + buildscript { repositories { jcenter() @@ -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' } } @@ -19,17 +20,9 @@ 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() @@ -37,6 +30,8 @@ allprojects { } ext { + versionCounter = new ProjectVersionCounter(project.hasProperty("releaseBuild")) + bintrayBaseUrl = 'https://api.bintray.com/maven' bintrayRepository = 'maven' bintrayPackage = 'serenity-core' @@ -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' } @@ -146,6 +158,12 @@ allprojects { labels = ['serenity','bdd'] } } + + task release() { + dependsOn bintrayUpload,publishNewVersionTag + } + + publishNewVersionTag.mustRunAfter bintrayUpload } subprojects { @@ -163,7 +181,6 @@ subprojects { archives sourcesJar, javadocJar } - publishing { publications { mavenJava(MavenPublication) { @@ -223,4 +240,4 @@ subprojects { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:-options" } -} \ No newline at end of file +} diff --git a/buildSrc/src/main/groovy/net/serenitybdd/builds/ProjectVersionCounter.groovy b/buildSrc/src/main/groovy/net/serenitybdd/builds/ProjectVersionCounter.groovy new file mode 100644 index 0000000000..b6421893d0 --- /dev/null +++ b/buildSrc/src/main/groovy/net/serenitybdd/builds/ProjectVersionCounter.groovy @@ -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" + } +}