-
-
Notifications
You must be signed in to change notification settings - Fork 30
/
build.gradle
125 lines (111 loc) · 5.33 KB
/
build.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
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
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
dependencies {
classpath 'io.github.FlyJingFish.AndroidAop:android-aop-plugin:'+TestVersion
}
}
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.8.0' apply false
id 'org.jetbrains.kotlin.jvm' version '1.8.0' apply false
id 'io.github.gradle-nexus.publish-plugin' version "2.0.0-rc-1"
id 'com.google.devtools.ksp' version '1.8.0-1.0.9' apply false
// id "io.github.FlyJingFish.AndroidAop.android-aop" version "1.7.2" apply true
}
apply plugin: "android.aop"
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_EN.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)
File gradleFile = new File("gradle.properties")
String gradleText = gradleFile.text
String text2 = gradleText.replace("TestVersion = "+oldVersionName,"TestVersion = "+newVersionName)
gradleFile.write(text2)
println("升级版本号完成,versionName = "+newVersionName)
}
}
def updateREADME(readme,oldVersionName,newVersionName) {
File configFile = new File(readme)
String exportText = configFile.text
String text = exportText.replace("io.github.FlyJingFish.AndroidAop:android-aop-plugin:"+oldVersionName,"io.github.FlyJingFish.AndroidAop:android-aop-plugin:"+newVersionName)
text = text.replace("io.github.FlyJingFish.AndroidAop:android-aop-core:"+oldVersionName,"io.github.FlyJingFish.AndroidAop:android-aop-core:"+newVersionName)
text = text.replace("io.github.FlyJingFish.AndroidAop:android-aop-annotation:"+oldVersionName,"io.github.FlyJingFish.AndroidAop:android-aop-annotation:"+newVersionName)
text = text.replace("io.github.FlyJingFish.AndroidAop:android-aop-extra:"+oldVersionName,"io.github.FlyJingFish.AndroidAop:android-aop-extra:"+newVersionName)
text = text.replace("io.github.FlyJingFish.AndroidAop:android-aop-processor:"+oldVersionName,"io.github.FlyJingFish.AndroidAop:android-aop-processor:"+newVersionName)
text = text.replace("io.github.FlyJingFish.AndroidAop:android-aop-ksp:"+oldVersionName,"io.github.FlyJingFish.AndroidAop:android-aop-ksp:"+newVersionName)
text = text.replace("id \"io.github.FlyJingFish.AndroidAop.android-aop\" version \""+oldVersionName+"\"","id \"io.github.FlyJingFish.AndroidAop.android-aop\" version \""+newVersionName+"\"")
text = text.replace("id(\"io.github.FlyJingFish.AndroidAop.android-aop\") version \""+oldVersionName+"\"","id(\"io.github.FlyJingFish.AndroidAop.android-aop\") version \""+newVersionName+"\"")
configFile.write(text)
}
def appVersionName = getAppVersionName()
group = PROJ_GROUP
version = appVersionName
apply plugin: "io.github.gradle-nexus.publish-plugin"
nexusPublishing {
repositories {
Nexus {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username = ossrhUsername // defaults to project.properties["myNexusUsername"]
password = ossrhPassword // defaults to project.properties["myNexusPassword"]
}
}
}