-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathbuild.gradle
More file actions
126 lines (107 loc) · 4.04 KB
/
build.gradle
File metadata and controls
126 lines (107 loc) · 4.04 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
import java.util.regex.Matcher
import java.util.regex.Pattern
plugins {
id 'com.android.library'
id 'maven-publish'
id 'org.jetbrains.kotlin.android'
}
android {
compileSdk 36
namespace "ai.elimu.analytics.utils"
defaultConfig {
minSdkVersion 29
targetSdkVersion 36
versionCode 4001030
versionName "4.1.30-SNAPSHOT"
}
buildTypes {
release {
minifyEnabled false
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
}
dependencies {
implementation libs.elimu.model // See https://jitpack.io/#ai.elimu/model
implementation libs.androidx.core.ktx
testImplementation libs.junit
}
publishing {
publications {
aar(MavenPublication) {
groupId = "ai.elimu"
artifactId = "analytics"
version = android.defaultConfig.versionName
artifact("${buildDir}/outputs/aar/utils-release.aar")
pom.withXml {
def dependenciesNode = asNode().appendNode('dependencies')
configurations.implementation.allDependencies.each {
def dependencyNode = dependenciesNode.appendNode('dependency')
dependencyNode.appendNode('groupId', it.group)
dependencyNode.appendNode('artifactId', it.name)
dependencyNode.appendNode('version', it.version)
}
}
}
}
}
tasks.named("publishAarPublicationToMavenLocal") {
mustRunAfter(":utils:bundleReleaseAar")
}
tasks.register('removeSnapshot') {
doLast {
println("removeSnapshot")
def file = file("build.gradle")
def originalFileContent = file.getText()
Pattern pattern = Pattern.compile("versionName \"\\d+\\.\\d+\\.\\d+-SNAPSHOT\"")
Matcher matcher = pattern.matcher(originalFileContent)
matcher.find()
println("match: ${matcher.group()}")
def newVersionName = matcher.group().replace("-SNAPSHOT", "")
println("newVersionName: ${newVersionName}")
def newFileContent = originalFileContent.replaceFirst("versionName \"\\d+\\.\\d+\\.\\d+-SNAPSHOT\"", newVersionName)
file.write(newFileContent)
}
}
tasks.register('getVersionName') {
doLast {
println android.defaultConfig.versionName
}
}
tasks.register('bumpVersion') {
doLast {
println("bumpVersion")
def currentVersionCode = android.defaultConfig.versionCode
println("currentVersionCode: ${currentVersionCode}")
def newVersionCode = currentVersionCode + 1
println("newVersionCode: ${newVersionCode}")
def newVersionName = newVersionCode.toString().substring(0, 1).toInteger() + "." + newVersionCode.toString().substring(1, 4).toInteger() + "." + newVersionCode.toString().substring(4, 7).toInteger()
println("newVersionName: ${newVersionName}")
def file = file("build.gradle")
def originalFileContent = file.getText()
def newFileContent = originalFileContent.replaceFirst("versionCode \\d+", "versionCode ${newVersionCode}")
newFileContent = newFileContent.replaceFirst("versionName \"\\d+\\.\\d+\\.\\d+\"", "versionName \"${newVersionName}\"")
file.write(newFileContent)
}
}
tasks.register('addSnapshot') {
doLast {
println("addSnapshot")
def file = file("build.gradle")
def originalFileContent = file.getText()
Pattern pattern = Pattern.compile("versionName \"\\d+\\.\\d+\\.\\d+\"")
Matcher matcher = pattern.matcher(originalFileContent)
matcher.find()
println("match: ${matcher.group()}")
def newVersionName = "${matcher.group().substring(12, matcher.group().length() - 1)}-SNAPSHOT\""
println("newVersionName: ${newVersionName}")
def newFileContent = originalFileContent.replaceFirst("versionName \"\\d+\\.\\d+\\.\\d+\"", "versionName ${newVersionName}")
file.write(newFileContent)
}
}