-
Notifications
You must be signed in to change notification settings - Fork 6
/
build.gradle.kts
231 lines (200 loc) · 7.41 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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpack
plugins {
`maven-publish`
signing
id("io.github.gradle-nexus.publish-plugin") version "1.3.0"
id("org.jetbrains.dokka") version "1.9.10"
kotlin("multiplatform") version "1.9.22"
kotlin("plugin.serialization") version "1.9.22"
}
group = "com.jeffpdavidson.kotwords"
version = "1.4.3-SNAPSHOT"
repositories {
mavenCentral()
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlin {
jvm {
withJava()
compilations.all {
kotlinOptions {
jvmTarget = "1.8"
}
}
}
js(IR) {
browser {}
binaries.executable()
}
mingwX64()
linuxX64()
macosX64()
targets.all {
if (this is KotlinNativeTarget) {
binaries.executable {
entryPoint = "com.jeffpdavidson.kotwords.cli.main"
}
}
}
applyDefaultHierarchyTemplate()
sourceSets {
all {
languageSettings {
optIn("kotlin.RequiresOptIn")
optIn("kotlin.js.ExperimentalJsExport")
optIn("com.jeffpdavidson.kotwords.KotwordsInternal")
}
}
val commonMain by getting {
dependencies {
implementation("com.squareup.okio:okio:3.7.0")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-core:1.6.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.2")
implementation("net.mamoe.yamlkt:yamlkt:0.13.0")
implementation("io.github.pdvrieze.xmlutil:serialization:0.86.3")
implementation("com.github.ajalt.colormath:colormath:3.3.3")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.0")
// TODO: Migrate to kotlinx-datetime when it can be done without breaking ksoup.
// Ensure any size hit to the JS bundle is acceptable.
implementation("com.soywiz.korlibs.klock:klock:4.0.10")
}
}
val commonTest by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-annotations-common")
implementation("org.jetbrains.kotlin:kotlin-test-common")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.0")
implementation("io.github.pdvrieze.xmlutil:testutil:0.86.3")
}
languageSettings {
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
}
}
val jvmMain by getting {
dependencies {
implementation("org.apache.pdfbox:pdfbox:3.0.1")
implementation("org.jsoup:jsoup:1.17.1")
}
}
val jvmTest by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-junit")
}
languageSettings {
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
}
}
val jsMain by getting {
dependencies {
implementation(npm("jszip", "3.10.1"))
implementation(npm("pdf-lib", "1.17.1"))
implementation(npm("@pdf-lib/fontkit", "1.1.1"))
implementation("org.jetbrains.kotlinx:kotlinx-html-js:0.10.1")
}
}
val jsTest by getting {
dependencies {
implementation("org.jetbrains.kotlin:kotlin-test-js")
// TODO: Find out how to use newer versions - 4.x seems to use ES6 modules which are not handled
// smoothly. Note also that PdfJs.kt and ImageComparator.kt will need updates.
implementation(npm("pdfjs-dist", "3.11.174"))
}
languageSettings {
optIn("kotlinx.coroutines.ExperimentalCoroutinesApi")
}
}
val nativeMain by getting {
dependencies {
implementation("com.soywiz.korlibs.korio:korio:4.0.10")
implementation("com.fleeksoft.ksoup:ksoup:0.1.2")
implementation("net.thauvin.erik.urlencoder:urlencoder-lib:1.4.0")
implementation("com.github.ajalt.clikt:clikt:4.2.2")
}
}
}
@OptIn(ExperimentalKotlinGradlePluginApi::class)
compilerOptions {
freeCompilerArgs.add("-Xexpect-actual-classes")
}
}
tasks.withType<Test> {
maxHeapSize = "2G"
}
tasks {
// Omit .web and .cli package from documentation
dokkaHtml.configure {
dokkaSourceSets {
configureEach {
perPackageOption {
matchingRegex.set("""com.jeffpdavidson\.kotwords\.(?:web|cli).*""")
suppress.set(true)
}
}
}
}
val browserProductionWebpackTask = getByName("jsBrowserProductionWebpack", KotlinWebpack::class)
val browserDistributionZip by creating(Zip::class) {
dependsOn(browserProductionWebpackTask)
from (browserProductionWebpackTask.outputDirectory)
destinationDirectory.set(layout.buildDirectory.dir("zip").get().getAsFile())
archiveAppendix.set("browser-distribution")
}
assemble {
dependsOn(browserDistributionZip)
}
}
publishing {
publications.withType<MavenPublication> {
val dokkaJar by tasks.register<Jar>("${name}DokkaJar") {
group = JavaBasePlugin.DOCUMENTATION_GROUP
// TODO: Determine from https://github.com/gradle/gradle/issues/26091 whether this will always be needed
archiveBaseName.set("${archiveBaseName.get()}-${name}")
archiveClassifier.set("javadoc")
from(tasks.dokkaHtml)
}
artifact(dokkaJar)
pom {
name.set("Kotwords")
description.set("Collection of crossword puzzle file format converters and other utilities, written in Kotlin.")
url.set("https://jpd236.github.io/kotwords")
developers {
developer {
id.set("jpd236")
name.set("Jeff Davidson")
}
}
licenses {
license {
name.set("The Apache License, Version 2.0")
url.set("http://www.apache.org/licenses/LICENSE-2.0.txt")
}
}
scm {
connection.set("scm:git:git://github.com/jpd236/kotwords.git")
developerConnection.set("scm:git:ssh://git@github.com/jpd236/kotwords.git")
url.set("https://github.com/jpd236/kotwords")
}
}
}
}
if (System.getenv("PGP_KEY_ID") != null) {
signing {
useInMemoryPgpKeys(System.getenv("PGP_KEY_ID"), System.getenv("PGP_KEY"), System.getenv("PGP_PASSPHRASE"))
sign(publishing.publications)
}
}
nexusPublishing {
repositories {
sonatype {
nexusUrl.set(uri("https://s01.oss.sonatype.org/service/local/"))
snapshotRepositoryUrl.set(uri("https://s01.oss.sonatype.org/content/repositories/snapshots/"))
username.set(System.getenv("OSSRH_DEPLOY_USERNAME"))
password.set(System.getenv("OSSRH_DEPLOY_PASSWORD"))
}
}
}