forked from FlyJingFish/OpenImage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
136 lines (122 loc) · 4.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
126
127
128
129
130
131
132
133
134
135
136
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.8.0'
ext.maven_nexus_name = '1254'
repositories {
google()
// if (TestType == "0"){
// mavenLocal()
// }else
if (TestType == "1"){
maven { url "https://s01.oss.sonatype.org/content/repositories/iogithubflyjingfish-"+SonatypeTestCode }
}
mavenCentral()
maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
maven { url 'https://jitpack.io' }
maven { url "https://s01.oss.sonatype.org/content/repositories/iogithubflyjingfish-$maven_nexus_name" }
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:7.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "io.github.gradle-nexus:publish-plugin:2.0.0-rc-1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
// if (TestType == "0"){
// mavenLocal()
// }else
if (TestType == "1"){
maven { url "https://s01.oss.sonatype.org/content/repositories/iogithubflyjingfish-"+SonatypeTestCode }
}
mavenCentral()
maven { url "https://maven.aliyun.com/nexus/content/groups/public" }
maven { url 'https://jitpack.io' }
maven { url "https://s01.oss.sonatype.org/content/repositories/iogithubflyjingfish-$maven_nexus_name" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
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 bumpVersion() {
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)
File configFile = new File("README.md")
String exportText = configFile.text
String text = exportText.replaceAll("Lib:"+oldVersionName,"Lib:"+newVersionName)
configFile.write(text)
println("升级版本号完成,versionName = "+newVersionName)
}
}
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"]
}
}
}