-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle.kts
198 lines (170 loc) · 5.33 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
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.jetbrains.kotlin.gradle.targets.jvm.KotlinJvmTarget
import java.util.*
plugins {
`maven-publish`
signing
kotlin("multiplatform")
kotlin("plugin.serialization")
id("com.github.johnrengelman.shadow")
}
group = "io.github.misterassm"
version = "0.3.2"
ext["signing.keyId"] = null
ext["signing.password"] = null
ext["signing.secretKeyRingFile"] = null
ext["ossrhUsername"] = null
ext["ossrhPassword"] = null
with(project.rootProject.file("local.properties")) {
if (exists()) {
reader().use {
Properties().apply { load(it) }
}.onEach { (name, value) ->
ext[name.toString()] = value
}
}
}
fun getExtraString(name: String) = ext[name]?.toString()
repositories {
mavenCentral()
}
kotlin {
jvm {
withJava()
compilations.all {
kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs = listOf(
"-opt-in=kotlin.RequiresOptIn",
"-Xjsr305=strict"
)
}
testRuns["test"].executionTask.configure {
useJUnitPlatform()
}
}
js(IR) {
nodejs()
compilations.all {
compileKotlinTask.kotlinOptions.freeCompilerArgs += listOf("-Xerror-tolerance-policy=SEMANTIC")
}
}
val hostOs = System.getProperty("os.name")
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" -> macosX64("native")
hostOs == "Linux" -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
sourceSets {
val commonMain by getting {
dependencies {
implementation(KotlinX.serialization.json)
implementation(KotlinX.datetime)
compileOnly(Ktor.client.core)
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting {
dependencies {
implementation(Ktor.client.okHttp)
}
}
val jvmTest by getting
val jsMain by getting {
dependencies {
implementation(npm("aes-js", "3.1.2"))
implementation(npm("md5", "2.3.0"))
}
}
val jsTest by getting {
dependencies {
implementation(kotlin("test-js"))
}
}
val nativeMain by getting
val nativeTest by getting
}
val publicationsFromMainHost = listOf(jvm(), js()).map { it.name } + "kotlinMultiplatform"
publishing {
publications {
matching { it.name in publicationsFromMainHost }.all {
val targetPublication = this@all
tasks.withType<AbstractPublishToMaven>()
.matching { it.publication == targetPublication }
.configureEach { onlyIf { findProperty("isMainHost") == "true" } }
}
}
}
}
fun registerShadowJar(targetName: String) {
kotlin.targets.named<KotlinJvmTarget>(targetName) {
compilations.named("main") {
tasks {
val shadowJar = register<ShadowJar>("${targetName}ShadowJar") {
group = "build"
from(output)
configurations = listOf(runtimeDependencyFiles)
archiveAppendix.set(targetName)
archiveClassifier.set("all")
mergeServiceFiles()
}
getByName("${targetName}Jar") {
finalizedBy(shadowJar)
}
}
}
}
}
registerShadowJar("jvm")
val javadocJar by tasks.registering(Jar::class) {
archiveClassifier.set("javadoc")
}
val jvmShadowJar by tasks.named("jvmShadowJar")
publishing {
// Configure maven central repository
repositories {
maven {
name = "sonatype"
setUrl("https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = getExtraString("ossrhUsername")
password = getExtraString("ossrhPassword")
}
}
}
// Configure all publications
publications.withType<MavenPublication> {
artifact(jvmShadowJar)
artifact(javadocJar.get())
// Provide artifacts information requited by Maven Central
pom {
name.set("Kronote")
description.set("Library to easily retrieve information from a Pronote server (Index-Education) for JVM/JS/Native")
url.set("https://github.com/MisterAssm/pronote-api")
licenses {
license {
name.set("MIT")
url.set("https://opensource.org/licenses/MIT")
}
}
developers {
developer {
id.set("MisterAssm")
name.set("Assim ZEMOUCHI")
email.set("assim.zpr@gmail.com")
}
}
scm {
url.set("https://github.com/MisterAssm/pronote-api")
}
}
}
}
signing {
sign(publishing.publications)
}