Repository navigation
Expand file tree
/
Copy pathbuild.gradle
More file actions
156 lines (147 loc) · 5.48 KB
/
Copy pathbuild.gradle
File metadata and controls
156 lines (147 loc) · 5.48 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
import java.util.regex.Pattern
buildscript {
final Properties localProp = new Properties()
def localPropFile = (new File(rootDir, "local.properties"))
if (localPropFile.exists()) {
localPropFile.withInputStream { localProp.load(it) }
}
def findPropertyOrEnvironment = { String key ->
findProperty(key) ?: localProp.getProperty(key) ?: System.getenv(key)
}
// This file must be the text version (--armor)
String signingFilename = findPropertyOrEnvironment("GPG_SIGNING_KEY_FILE")
File signingFile = null
if (signingFilename != null) {
signingFile = file(signingFilename)
if (!signingFile.exists()) {
signingFile = new File(rootDir, signingFilename)
if (!signingFile.exists()) {
signingFile = null
}
}
}
ext.isAndroidEnabled = !(new File(rootDir, "disable-android.gradle")).exists()
ext.deploy = [
"central": [
"enabled" : findPropertyOrEnvironment("MVN_CENTRAL_USERNAME") != null,
"username": findPropertyOrEnvironment("MVN_CENTRAL_USERNAME"),
"password": findPropertyOrEnvironment("MVN_CENTRAL_PASSWORD"),
],
"signing": [
"enabled" : signingFile != null && findPropertyOrEnvironment("GPG_SIGNING_KEY_ID") != null && findPropertyOrEnvironment("GPG_SIGNING_PASSWORD") != null,
"secret" : signingFile?.getText("UTF-8"),
"key_id" : findPropertyOrEnvironment("GPG_SIGNING_KEY_ID"),
"password": findPropertyOrEnvironment("GPG_SIGNING_PASSWORD"),
]
]
ext.versions = [
"java" : JavaVersion.VERSION_1_8,
"logger" : [
"major": "1",
"minor": "3",
"pkg" : "",
],
"android": [
"minimum": 21,
"compile": 33,
"target" : 33,
],
"kotlin" : "1.8.10",
"junit" : "5.8.2",
"mockito": "4.4.0",
]
ext.versions.logger.pkg = "${ext.versions.logger.major}.${ext.versions.logger.minor}."
ext.lib = [
"annotations": "org.jetbrains:annotations:20.1.0",
"jna" : [
"core" : "net.java.dev.jna:jna:5.10.0",
"platform": "net.java.dev.jna:jna-platform:5.10.0",
],
"test" : [
"junit" : "org.junit.jupiter:junit-jupiter:${versions.junit}",
"mockito": [
"bom" : "org.mockito:mockito-bom:${versions.mockito}",
"junit": "org.mockito:mockito-junit-jupiter",
],
]
]
allprojects {
repositories {
mavenCentral()
google()
}
}
}
plugins {
id "org.jetbrains.kotlin.jvm" version "1.8.10" apply false
id "org.jetbrains.kotlin.android" version "1.8.10" apply false
id "com.android.application" version "7.3.1" apply false
id "com.google.gms.google-services" version "4.3.13" apply false
id "com.google.firebase.crashlytics" version "2.9.2" apply false
id "de.mannodermaus.android-junit5" version "1.8.2.0" apply false
}
Pattern regex = Pattern.compile("'([a-zA-Z0-9\\-_:]+)'")
task deploy_ToLocal {
group = "deploy local"
allprojects { pj ->
for (tsk in ["deployJavaToLocal", "deployAndroidToLocal", "deployKotlinToLocal", "deployAndroidKotlinToLocal"]) {
if (pj.getTasksByName(tsk, false).isEmpty()) {
continue
}
def match = regex.matcher(pj.displayName)
match.find()
def name = match.group()
dependsOn "${name.substring(1, name.length() - 1)}:$tsk"
}
}
doLast {
println("")
println("All projects were uploaded to local")
println("-----------------------------------")
}
}
task generateAllJavaJars {
group = "build"
allprojects { pj ->
for (tsk in ["deployJavaToLocal"]) {
if (pj.getTasksByName(tsk, false).isEmpty()) {
continue
}
def match = regex.matcher(pj.displayName)
match.find()
def name = match.group()
dependsOn "${name.substring(1, name.length() - 1)}:jar"
}
}
}
allprojects {
task checkMavenCentral {
doLast {
if (!deploy.central.enabled || !deploy.signing.enabled) {
if (!deploy.central.enabled)
throw new RuntimeException("Maven central is not configured")
throw new RuntimeException("Signing is not configured")
}
}
}
}
task deploy_ToMavenCentral {
group = "deploy central"
dependsOn "checkMavenCentral"
allprojects { pj ->
for (tsk in ["deployJavaToMavenCentral", "deployAndroidToMavenCentral", "deployKotlinToMavenCentral", "deployAndroidKotlinToMavenCentral"]) {
if (pj.getTasksByName(tsk, false).isEmpty()) {
continue
}
def match = regex.matcher(pj.displayName)
match.find()
def name = match.group()
dependsOn "${name.substring(1, name.length() - 1)}:$tsk"
}
}
doLast {
println("===========================================")
println("All projects were uploaded to Maven Central")
println("===========================================")
}
}