Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
76 lines (68 loc) · 2.11 KB
/
Copy pathbuild.gradle
File metadata and controls
76 lines (68 loc) · 2.11 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
//https://developer.android.com/jetpack/androidx/releases/compose-kotlin
ext.kotlin_version = '1.8.10'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
def getVersionCode = { ->
try {
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', '--first-parent', '--count', 'HEAD'
standardOutput = stdout
}
return Integer.parseInt(stdout.toString().trim())
} catch (ignored) {
return -1;
}
}
def getVersionName = { ->
String versionName = project.findProperty('versionName') ?: getVersionNameFromGit() ?: "VersionNameError"
versionName = increaseVersionForPreRelease(versionName)
return versionName.replaceFirst("^v", "")
}
private static String increaseVersionForPreRelease(String versionName) {
if (isPreReleaseVersion(versionName)) {
return versionName.replaceFirst("(\\d+\\.\\d+\\.)(\\d+)", {
return it[1] + (it[2].toInteger() + 1)
})
}
return versionName
}
private static boolean isPreReleaseVersion(String versionName) {
versionName.contains('-')
}
private String getVersionNameFromGit() {
try {
def stdout = new ByteArrayOutputStream()
exec {
// v0.3.10-187-gef4be8c9-dirty
commandLine 'git', 'describe', '--tags', '--dirty', '--exclude', 'v*-*'
standardOutput = stdout
}
return stdout.toString().trim()
} catch (ignored) {
return null
}
}
ext {
gitVersionCode = getVersionCode()
gitVersionName = getVersionName()
APPLICATION_ID = "com.nihility.mipush"
COMPILE_SDK = 34
MIN_SDK = 26
TARGET_SDK = 34
}