-
-
Notifications
You must be signed in to change notification settings - Fork 67
Expand file tree
/
Copy pathbuild.gradle
More file actions
214 lines (180 loc) · 7.76 KB
/
build.gradle
File metadata and controls
214 lines (180 loc) · 7.76 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath 'io.github.flyjingfish:androidaop-plugin:'+TestVersion
classpath 'org.jetbrains.kotlin:kotlin-serialization:1.5.0'
// classpath 'io.github.flyjingfish:easyregister:1.1.0'
}
}
plugins {
id 'com.android.application' version '8.2.2' apply false
id 'com.android.library' version '8.2.2' apply false
id 'org.jetbrains.kotlin.android' version '1.9.23' apply false
id 'org.jetbrains.kotlin.jvm' version '1.9.23' apply false
//https://github.com/vanniktech/gradle-maven-publish-plugin
id "com.vanniktech.maven.publish" version "0.33.0" apply false
id 'com.google.devtools.ksp' version '1.9.23-1.0.20' apply false
id 'io.github.flyjingfish.easyregister' version '1.1.0' apply false
id 'com.gradle.plugin-publish' version '1.2.1' apply false
alias(libs.plugins.android.dynamic.feature) apply false
// id "kotlinx-serialization" version "1.5.0"
// id "io.github.FlyJingFish.AndroidAop.android-aop" version "1.7.2" apply true
}
apply plugin: "android.aop"
//apply plugin: "android.aop.clean"
ext {
sdkVersion = 31
minSdkVersion = 21
}
def synchronized getVersionProperty(propName, defValue) {
def file = file("version.properties")
def ret = defValue
if (file.exists() && file.canRead()) {
FileInputStream input = new FileInputStream(file)
Properties props = new Properties()
props.load(input)
ret = props.get(propName);
input.close()
}
return ret
}
def getAppVersionName() {
String versionName = getVersionProperty("PROJ_VERSION", "1.0.0")
return versionName
}
def getAppVersionCode() {
String versionName = getAppVersionName()
def versions = versionName.split("\\.")
def updateVersionString = ""
for (int i = 0; i < versions.size(); i++) {
def subString = versions[i]
if (i == 0) {
updateVersionString += subString
continue
} else if (i >= 3) {
break
}
def subNumber = Integer.parseInt(subString)
updateVersionString += String.format("%01d", subNumber)
}
return Integer.parseInt(updateVersionString)
}
task aaBumpVersion() {
doLast {
def versionName = getAppVersionCode() + 1
def str = versionName.toString()
def length = str.length()
def newVersionName = ""
for (int i = 0; i < length; i++) {
newVersionName += str.charAt(i)
if (i < 2) {
newVersionName += "."
}
}
def versionPropsFile = file('version.properties')
def versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def oldVersionName = versionProps['PROJ_VERSION']
versionProps['PROJ_VERSION'] = newVersionName
versionProps.store(versionPropsFile.newWriter(), null)
updateREADME("README.md",oldVersionName,newVersionName)
updateREADME("README-zh.md",oldVersionName,newVersionName)
updateREADME("docs/getting_started.md",oldVersionName,newVersionName)
updateREADME("docs/android_aop_extra.md",oldVersionName,newVersionName)
updateREADME("docs/zh/getting_started.md",oldVersionName,newVersionName)
updateREADME("docs/zh/android_aop_extra.md",oldVersionName,newVersionName)
// version = newVersionName
// rootProject.subprojects { subproject ->
// subproject.version = newVersionName
// }
exec {
workingDir projectDir
commandLine './gradlew', 'publishMavenPublicationToMavenLocal'
}
File gradleFile = new File("gradle.properties")
String gradleText = gradleFile.text
String text2 = gradleText.replace("TestVersion = "+oldVersionName,"TestVersion = "+newVersionName)
gradleFile.write(text2)
println("升级版本号完成,versionName = "+newVersionName)
}
}
task aaBumpVersion1() {
doLast {
def versionName = getAppVersionCode() + 1
def str = versionName.toString()
def length = str.length()
def newVersionName = ""
for (int i = 0; i < length; i++) {
newVersionName += str.charAt(i)
if (i < 2) {
newVersionName += "."
}
}
def versionPropsFile = file('version.properties')
def versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def oldVersionName = versionProps['PROJ_VERSION']
versionProps['PROJ_VERSION'] = newVersionName
versionProps.store(versionPropsFile.newWriter(), null)
updateREADME("README.md",oldVersionName,newVersionName)
updateREADME("README-zh.md",oldVersionName,newVersionName)
updateREADME("docs/getting_started.md",oldVersionName,newVersionName)
updateREADME("docs/android_aop_extra.md",oldVersionName,newVersionName)
updateREADME("docs/zh/getting_started.md",oldVersionName,newVersionName)
updateREADME("docs/zh/android_aop_extra.md",oldVersionName,newVersionName)
}
}
task aaBumpVersion2() {
doLast {
def versionPropsFile = file('gradle.properties')
def versionProps = new Properties()
versionProps.load(new FileInputStream(versionPropsFile))
def oldVersionName = versionProps['TestVersion']
def newVersionName = getAppVersionName()
File gradleFile = new File("gradle.properties")
String gradleText = gradleFile.text
String text2 = gradleText.replace("TestVersion = "+oldVersionName,"TestVersion = "+newVersionName)
gradleFile.write(text2)
println("升级版本号完成,versionName = "+newVersionName)
}
}
//subprojects { subproject ->
// subproject.afterEvaluate {
// def list = new ArrayList<String>()
// subproject.tasks.forEach { task ->
// if (task.name.contains("publish")){
// println("task.name="+task.name)
// }
//
// if ("publishAllPublicationsToMavenCentralRepository" == task.name){
// list.add("${subproject.path}:publishMavenPublicationToMavenLocal")
// }
// }
// aaBumpVersion.finalizedBy(list.toArray())
// }
//}
def updateREADME(readme,oldVersionName,newVersionName) {
File configFile = new File(readme)
String exportText = configFile.text
String text = exportText.replace("io.github.flyjingfish:androidaop-plugin:"+oldVersionName,"io.github.flyjingfish:androidaop-plugin:"+newVersionName)
text = text.replace("io.github.flyjingfish:androidaop-core:"+oldVersionName,"io.github.flyjingfish:androidaop-core:"+newVersionName)
text = text.replace("io.github.flyjingfish:androidaop-annotation:"+oldVersionName,"io.github.flyjingfish:androidaop-annotation:"+newVersionName)
text = text.replace("io.github.flyjingfish:androidaop-extra:"+oldVersionName,"io.github.flyjingfish:androidaop-extra:"+newVersionName)
text = text.replace("io.github.flyjingfish:androidaop-apt:"+oldVersionName,"io.github.flyjingfish:androidaop-apt:"+newVersionName)
text = text.replace("id \"io.github.flyjingfish.androidaop\" version \""+oldVersionName+"\"","id \"io.github.flyjingfish.androidaop\" version \""+newVersionName+"\"")
text = text.replace("id(\"io.github.flyjingfish.androidaop\") version \""+oldVersionName+"\"","id(\"io.github.flyjingfish.androidaop\") version \""+newVersionName+"\"")
configFile.write(text)
}
def appVersionName = getAppVersionName()
group = PROJ_GROUP
version = appVersionName
task runPublishScript(type: Exec) {
group = "publishing"
description = "Runs the publish.sh shell script"
workingDir = projectDir
commandLine './publish.sh'
}
/**
chmod +x publish.sh
./publish.sh
*/