-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
build.gradle.kts
168 lines (143 loc) · 4.81 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
import java.util.Properties
import java.io.FileInputStream
import java.util.Base64
plugins {
kotlin("multiplatform") version "1.9.20"
// Tests
jacoco
// Docs
id("org.jetbrains.dokka") version "1.9.10"
// Publishing
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("maven-publish")
id("signing")
}
group = "dev.kdrag0n"
version = "1.0.5"
repositories {
mavenCentral()
}
kotlin {
explicitApi()
jvm {
jvmToolchain(8)
withJava()
testRuns.named("test") {
executionTask.configure {
useJUnitPlatform()
}
}
}
js {
nodejs()
}
val hostOs = System.getProperty("os.name")
val isArm64 = System.getProperty("os.arch") == "aarch64"
val isMingwX64 = hostOs.startsWith("Windows")
val nativeTarget = when {
hostOs == "Mac OS X" && isArm64 -> macosArm64("native")
hostOs == "Mac OS X" && !isArm64 -> macosX64("native")
hostOs == "Linux" && isArm64 -> linuxArm64("native")
hostOs == "Linux" && !isArm64 -> linuxX64("native")
isMingwX64 -> mingwX64("native")
else -> throw GradleException("Host OS is not supported in Kotlin/Native.")
}
sourceSets {
val commonMain by getting
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val jvmMain by getting
val jvmTest by getting
val jsMain by getting
val jsTest by getting
val nativeMain by getting
val nativeTest by getting
}
}
jacoco {
toolVersion = "0.8.7"
}
val jacocoTestReport by tasks.creating(JacocoReport::class) {
val coverageSourceDirs = arrayOf(
"src/commonMain/kotlin", "src/jvmMain/kotlin"
)
val classFiles = layout.buildDirectory.dir("classes/kotlin/jvm/main")
classDirectories.setFrom(classFiles)
sourceDirectories.setFrom(files(coverageSourceDirs))
executionData.setFrom(layout.buildDirectory.files("jacoco/jvmTest.exec"))
reports {}
dependsOn("jvmTest")
}
val dokkaHtml by tasks.getting(org.jetbrains.dokka.gradle.DokkaTask::class)
val javadocJar: TaskProvider<Jar> by tasks.registering(Jar::class) {
dependsOn(dokkaHtml)
archiveClassifier.set("javadoc")
from(dokkaHtml.outputDirectory)
}
val secretPropsFile = project.rootProject.file("local.properties")
if (secretPropsFile.exists()) {
// Read local.properties file first if it exists
val p = Properties()
FileInputStream(secretPropsFile).use { ins -> p.load(ins) }
p.forEach { name, value -> ext[name as String] = value }
} else {
// Use system environment variables
ext["ossrhUsername"] = System.getenv("OSSRH_USERNAME")
ext["ossrhPassword"] = System.getenv("OSSRH_PASSWORD")
ext["sonatypeStagingProfileId"] = System.getenv("SONATYPE_STAGING_PROFILE_ID")
ext["signing.keyId"] = System.getenv("SIGNING_KEY_ID")
ext["signing.password"] = System.getenv("SIGNING_PASSWORD")
ext["signing.key"] = System.getenv("SIGNING_KEY")
}
nexusPublishing {
repositories {
sonatype {
stagingProfileId.set(rootProject.extra["sonatypeStagingProfileId"] as String?)
username.set(rootProject.extra["ossrhUsername"] as String?)
password.set(rootProject.extra["ossrhPassword"] as String?)
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
}
}
}
publishing {
publications.withType<MavenPublication> {
artifact(javadocJar)
pom {
val githubUrl = "https://github.com/kdrag0n/colorkt"
name.set("Color.kt")
description.set("Modern color science library for Kotlin Multiplatform and Java")
url.set(githubUrl)
licenses {
license {
name.set("MIT License")
url.set("https://opensource.org/licenses/mit-license.php")
}
}
developers {
developer {
id.set("kdrag0n")
name.set("Danny Lin")
// Avoid automated scraping
email.set(Base64.getDecoder().decode("bWF2ZW5Aa2RyYWcwbi5kZXY=").toString(Charsets.UTF_8))
}
}
scm {
connection.set("scm:git:$githubUrl.git")
developerConnection.set("scm:git:ssh://github.com/kdrag0n/colorkt.git")
url.set(githubUrl)
}
}
}
}
signing {
useInMemoryPgpKeys(
rootProject.extra["signing.keyId"] as String?,
rootProject.extra["signing.key"] as String?,
rootProject.extra["signing.password"] as String?
)
sign(publishing.publications)
}