-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathversioning.gradle
50 lines (45 loc) · 2.06 KB
/
versioning.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
def buildVersionCode() {
// Increments the versionName
def (String major, String minor, String patch) = materialfieldsVersionName.toLowerCase().replaceAll('-', '').tokenize('.')
Integer patch_int = patch.toInteger() + 1
materialfieldsVersionName = major + "." + minor + "." + patch_int
// Increments the versionCode
materialfieldsVersionCode = (materialfieldsVersionCode.toInteger() + 1).toString()
// Write settings
def versionPropsFile = file("./gradle.properties")
Properties versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
versionProps["materialfieldsVersionName"] = materialfieldsVersionName
versionProps["materialfieldsVersionCode"] = materialfieldsVersionCode
versionProps.store(versionPropsFile.newWriter(), null)
}
/*
* Materialfields
* Copyright (c) 2020 by gabrielepmattia, All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3.0 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library.
*/
task updateVersion {
doLast {
println '\n################## Version Update ##################'
println '# From version:\t ' + materialfieldsVersionName + ' (' + materialfieldsVersionCode + ')'
buildVersionCode()
println '# To version:\t ' + materialfieldsVersionName + ' (' + materialfieldsVersionCode + ')'
println '####################################################'
}
}
configure(updateVersion) {
group = 'versioning'
description = 'Manage your project version'
}