-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogMob.gradle.kts
130 lines (112 loc) · 4.03 KB
/
LogMob.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
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
/*
* Copyright (c) 2020 Mustafa Ozhan. All rights reserved.
*/
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import java.io.IOException
import java.util.Properties
plugins {
`maven-publish`
libs.plugins.apply {
alias(kotlinMultiplatform).apply(false)
alias(androidLibrary).apply(false)
}
}
allprojects {
Library.apply {
group = GROUP
version = ProjectSettings.getVersionName(project)
repositories {
google()
mavenCentral()
}
val emptyJavadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}
afterEvaluate {
extensions.findByType<PublishingExtension>()?.apply {
repositories {
maven {
url = uri(if (isReleaseBuild) RELEASE_URL else SNAPSHOT_URL)
credentials {
username = getSecret("MAVEN_USERNAME")
password = getSecret("MAVEN_PASSWORD")
}
}
}
publications.withType<MavenPublication>().configureEach {
artifact(emptyJavadocJar.get())
pom {
name.set(NAME)
description.set(DESCRIPTION)
url.set(URL)
licenses {
license {
name.set(LICENSE_NAME)
url.set(LICENSE_URL)
distribution.set(LICENSE_DISTRIBUTION)
}
}
developers {
developer {
id.set(DEVELOPER_ID)
name.set(DEVELOPER_NAME)
email.set(DEVELOPER_EMAIL)
}
}
scm { url.set(URL) }
}
}
}
extensions.findByType<PublishingExtension>()?.let { publishing ->
val key = getSecret("GPG_KEY").replace("\\n", "\n")
val password = getSecret("GPG_PASSWORD")
extensions.findByType<SigningExtension>()?.apply {
useInMemoryPgpKeys(key, password)
sign(publishing.publications)
}
}
tasks.withType<Sign>().configureEach {
onlyIf { isReleaseBuild }
}
}
}
tasks.withType<KotlinCompile> {
compilerOptions {
// todo remove when not needed anymore
freeCompilerArgs.add("-Xexpect-actual-classes")
allWarningsAsErrors = true
}
}
}
val isReleaseBuild: Boolean
get() = System.getenv("GPG_KEY") != null
fun getSecret(
key: String,
default: String = "secret" // these values can not be public
): String = System.getenv(key).let {
if (it.isNullOrEmpty()) {
getSecretProperties()?.get(key)?.toString() ?: default
} else {
it
}
}
fun getSecretProperties() = try {
Properties().apply { load(file("key.properties").inputStream()) }
} catch (e: IOException) {
logger.debug(e.message, e)
null
}
object Library {
const val GROUP = "com.github.submob"
const val URL = "https://github.com/SubMob/LogMob"
const val NAME = "LogMob"
const val DESCRIPTION = "Multiplatform logging library"
const val DEVELOPER_NAME = "Mustafa Ozhan"
const val DEVELOPER_ID = "mustafaozhan"
const val DEVELOPER_EMAIL = "[email protected]"
const val LICENSE_NAME = "The Apache Software License, Version 2.0"
const val LICENSE_URL = "http://www.apache.org/licenses/LICENSE-2.0.txt"
const val LICENSE_DISTRIBUTION = "repo"
const val RELEASE_URL = "https://s01.oss.sonatype.org/service/local/staging/deploy/maven2"
const val SNAPSHOT_URL = "https://s01.oss.sonatype.org/content/repositories/snapshots"
}