-
Notifications
You must be signed in to change notification settings - Fork 19
/
build.gradle.kts
105 lines (92 loc) · 3.31 KB
/
build.gradle.kts
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
import org.ajoberstar.grgit.Grgit
import java.util.Base64
plugins {
alias(libs.plugins.android.library) apply false
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin) apply false
alias(libs.plugins.kapt) apply false
alias(libs.plugins.androidx.navigation.safeargs) apply false
alias(libs.plugins.google.services) apply false
// alias(libs.plugins.huawei.agconnect) apply false
alias(libs.plugins.kotlin.allopen) apply false
alias(libs.plugins.kotlin.parcelize) apply false
alias(libs.plugins.grgit)
alias(libs.plugins.dotenv)
alias(libs.plugins.ben.manes.versions)
alias(libs.plugins.android.junit5) apply false
alias(libs.plugins.nexus.publish)
id("maven-publish")
id("signing")
}
versionData()
allprojects {
val sdkVersion: GitVersion by rootProject.extra
group = "com.emarsys"
version = sdkVersion.versionName
}
fun versionData() {
val git = Grgit.open(
mapOf("currentDir" to project.rootDir)
)
val v = try {
git.fetch()
if (git.describe() == null) {
throw RuntimeException("Couldn't get Version Name")
}
GitVersion(
versionName =
if (System.getenv("RELEASE_VERSION") == null) git.describe() else System.getenv(
"RELEASE_VERSION"
),
versionCode = ((System.currentTimeMillis() - 1602845230) / 10000).toInt(),
versionCodeTime = git.head().dateTime.toEpochSecond()
)
} catch (ignored: Exception) {
GitVersion(
versionName = "0.0.0",
versionCode = 1,
versionCodeTime = 0
)
}
val sdkVersion by extra(v)
ext["signing.keyId"] =
env.fetchOrNull("SONATYPE_SIGNING_KEY_ID") ?: System.getenv("SONATYPE_SIGNING_KEY_ID")
ext["signing.password"] =
env.fetchOrNull("SONATYPE_SIGNING_PASSWORD") ?: System.getenv("SONATYPE_SIGNING_PASSWORD")
ext["signing.secretKeyRingFile"] = "./secring.asc.gpg"
println("versionName: ${sdkVersion.versionName}")
println("versionCode: ${sdkVersion.versionCode}")
}
tasks {
register("base64EnvToFile") {
val propertyName = project.property("propertyName") as String?
?: throw IllegalArgumentException("Property 'propertyName' is not provided.")
val file = project.property("file") as String?
?: throw IllegalArgumentException("Property 'file' is not provided.")
doLast {
val base64String = env.fetch(propertyName)
val decoder = Base64.getDecoder()
val decodedBytes = decoder.decode(base64String)
file(file).apply {
writeBytes(decodedBytes)
}
}
}
}
allprojects {
// Exclude Kotlin files from Javadoc generation because Kotlin files are not supported by Dokka
tasks.withType(Javadoc::class).all {
enabled = false
}
}
nexusPublishing {
packageGroup = "com.emarsys"
repositories {
sonatype {
stagingProfileId = env.fetchOrNull("SONATYPE_STAGING_PROFILE_ID")
?: System.getenv("SONATYPE_STAGING_PROFILE_ID")
username = env.fetchOrNull("OSSRH_USERNAME") ?: System.getenv("OSSRH_USERNAME")
password = env.fetchOrNull("OSSRH_PASSWORD") ?: System.getenv("OSSRH_PASSWORD")
}
}
}