Skip to content

Commit 995df8b

Browse files
Merge pull request #15 from valueadd-poland/feature/add-simple-versioning-script
add: simple versioning script
2 parents 397d72b + b4edc38 commit 995df8b

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

mvi/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ apply plugin: 'com.android.library'
22
apply plugin: 'kotlin-android'
33
apply plugin: 'kotlin-kapt'
44
apply plugin: 'kotlin-android-extensions'
5+
apply from: "$rootDir/scripts/versioning.gradle"
56
apply from: "$rootDir/scripts/jfrog.gradle"
67

78

@@ -18,8 +19,8 @@ android {
1819
defaultConfig {
1920
minSdkVersion deps.build_version.min_sdk
2021
targetSdkVersion deps.build_version.target_sdk
21-
versionCode 1
22-
versionName "1.0"
22+
versionName libraryVersionName
23+
versionCode libraryVersionCode
2324
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
2425
consumerProguardFiles 'consumer-rules.pro'
2526
}

scripts/jfrog.gradle

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ ext {
1414
siteUrl = 'https://github.com/valueadd-poland/mvi-valueadd'
1515
gitUrl = 'https://github.com/valueadd-poland/mvi-valueadd.git'
1616

17-
libraryVersion = '0.2'
18-
1917
developerId = 'valueadd-poland'
2018
developerName = 'Valueadd'
2119
developerEmail = '[email protected]'
@@ -26,7 +24,7 @@ ext {
2624
}
2725

2826
group = publishedGroupId
29-
version = libraryVersion
27+
version = libraryVersionName
3028

3129
install {
3230
repositories.mavenInstaller {
@@ -61,8 +59,6 @@ install {
6159
}
6260
}
6361

64-
65-
6662
Properties properties = new Properties()
6763
properties.load(project.rootProject.file('local.properties').newDataInputStream())
6864

scripts/versioning.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// Library version variable
2+
def libraryVersionName = '1.0.0'
3+
4+
// Set project library version name
5+
rootProject.ext.libraryVersionName = libraryVersionName
6+
println "libraryVersionName = $libraryVersionName"
7+
8+
// Generate library version code
9+
def (major, minor, patch) = (libraryVersionName != null) ? libraryVersionName.tokenize('.') : [0, 0, 1]
10+
def libraryVersionCode = major.toInteger() * 1_000_000 + minor.toInteger() * 1_000 + patch.toInteger()
11+
12+
// Set project library version code
13+
rootProject.ext.libraryVersionCode = libraryVersionCode
14+
println "libraryVersionCode = $libraryVersionCode ($major.$minor.$patch)"

0 commit comments

Comments
 (0)