Skip to content

Commit eb7e541

Browse files
committed
Add Gradle versioning tasks
1 parent 5eb81e4 commit eb7e541

File tree

3 files changed

+79
-8
lines changed

3 files changed

+79
-8
lines changed

build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ plugins {
1818
id 'io.codearte.nexus-staging' version '0.22.0' //can only be applied to root project
1919
}
2020

21+
apply from: 'versionTasks.gradle'
22+
2123
nexusStaging {
2224
username = "$System.env.SONATYPE_NEXUS_USERNAME"
2325
password = "$System.env.SONATYPE_NEXUS_PASSWORD"

gradle.properties

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1+
#Tue, 15 Dec 2020 00:22:46 +0100
12
kotlin.code.style=official
23
kotlin.incremental=false
34

45
GROUP=com.github.tschuchortdev
5-
VERSION_NAME=1.3.1
6+
VERSION_NAME=1.3.2-SNAPSHOT
67
POM_DESCRIPTION=A library that enables testing of Kotlin annotation processors, compiler plugins and code generation.
78
POM_INCEPTION_YEAR=2019
8-
POM_URL=https://github.com/tschuchortdev/kotlin-compile-testing
9-
POM_SCM_URL=https://github.com/tschuchortdev/kotlin-compile-testing
10-
POM_SCM_CONNECTION=scm:git:https://github.com/tschuchortdev/kotlin-compile-testing
11-
POM_SCM_DEV_CONNECTION=scm:git:https://github.com/tschuchortdev/kotlin-compile-testing
9+
POM_URL=https\://github.com/tschuchortdev/kotlin-compile-testing
10+
POM_SCM_URL=https\://github.com/tschuchortdev/kotlin-compile-testing
11+
POM_SCM_CONNECTION=scm\:git\:https\://github.com/tschuchortdev/kotlin-compile-testing
12+
POM_SCM_DEV_CONNECTION=scm\:git\:https\://github.com/tschuchortdev/kotlin-compile-testing
1213
POM_LICENCE_NAME=Mozilla Public License 2.0
13-
POM_LICENCE_URL=https://www.mozilla.org/en-US/MPL/2.0/
14+
POM_LICENCE_URL=https\://www.mozilla.org/en-US/MPL/2.0/
1415
POM_LICENCE_DIST=repo
1516
POM_DEVELOPER_ID=tschuchortdev
1617
POM_DEVELOPER_NAME=Thilo Schuchort
1718
POM_NAME=kotlin-compile-testing
1819
POM_PACKAGING=jar
19-
RELEASE_REPOSITORY=https://oss.sonatype.org/service/local/staging/deploy/maven2/
20-
SNAPSHOT_REPOSITORY=https://oss.sonatype.org/content/repositories/snapshots/
20+
RELEASE_REPOSITORY=https\://oss.sonatype.org/service/local/staging/deploy/maven2/
21+
SNAPSHOT_REPOSITORY=https\://oss.sonatype.org/content/repositories/snapshots/
22+
signing.keyId=523052D4

versionTasks.gradle

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
private def setVersionName(newVersionName) {
2+
ant.propertyfile(file: 'gradle.properties') {
3+
entry(key: "VERSION_NAME", value: newVersionName)
4+
}
5+
}
6+
7+
task incrementPatchVersion {
8+
group 'publishing'
9+
10+
doLast {
11+
def (_,majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ /^(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)[0]
12+
def newVersionName = majorStr + "." + minorStr + "." + (Integer.parseInt(patchStr) + 1) +
13+
((snapshotStr != null) ? snapshotStr : "")
14+
setVersionName(newVersionName)
15+
}
16+
}
17+
18+
task incrementMinorVersion {
19+
group 'publishing'
20+
21+
doLast {
22+
def (_, majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ /^(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)[0]
23+
def newVersionName = majorStr + "." + (Integer.parseInt(minorStr) + 1) + "." + patchStr +
24+
((snapshotStr != null) ? snapshotStr : "")
25+
setVersionName(newVersionName)
26+
}
27+
}
28+
29+
task incrementMajorVersion {
30+
group 'publishing'
31+
32+
doLast {
33+
def (_, majorStr, minorStr, patchStr, snapshotStr) = (VERSION_NAME =~ /^(\d+)\.(\d+)\.(\d+)(-SNAPSHOT)?/)[0]
34+
def newVersionName = (Integer.parseInt(majorStr) + 1) + "." + minorStr + "." + patchStr +
35+
((snapshotStr != null) ? snapshotStr : "")
36+
setVersionName(newVersionName)
37+
}
38+
}
39+
40+
task setSnapshotVersionSuffix {
41+
group 'publishing'
42+
43+
doLast {
44+
def (_, versionPrefix, snapshotStr) = (VERSION_NAME =~ /^(\d+\.\d+\.\d+)(-SNAPSHOT)?/)[0]
45+
if (snapshotStr == null) {
46+
setVersionName(versionPrefix + "-SNAPSHOT")
47+
}
48+
}
49+
}
50+
51+
task removeSnapshotVersionSuffix {
52+
group 'publishing'
53+
54+
doLast {
55+
def (_, versionPrefix, snapshotStr) = (VERSION_NAME =~ /^(\d+\.\d+\.\d+)(-SNAPSHOT)?/)[0]
56+
if (snapshotStr != null) {
57+
setVersionName(versionPrefix)
58+
}
59+
}
60+
}
61+
62+
task printVersionName {
63+
group 'publishing'
64+
doLast {
65+
println VERSION_NAME
66+
}
67+
}

0 commit comments

Comments
 (0)