|
1 |
| -import io.gitlab.arturbosch.detekt.Detekt |
2 |
| -import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi |
3 |
| -import org.jetbrains.kotlin.gradle.plugin.KotlinTarget |
4 |
| -import org.jetbrains.kotlin.gradle.plugin.KotlinTargetWithTests |
5 |
| -import org.jlleitschuh.gradle.ktlint.reporter.ReporterType |
6 |
| -import java.util.Locale |
7 |
| - |
8 | 1 | plugins {
|
9 |
| - alias(libs.plugins.kotlin.mutliplatform) |
10 |
| - alias(libs.plugins.kotlin.serialization) |
11 |
| - alias(libs.plugins.kotest.multiplatform) |
12 |
| - alias(libs.plugins.kover) |
13 |
| - alias(libs.plugins.detekt) |
14 |
| - alias(libs.plugins.ktlint) |
| 2 | + alias(libs.plugins.kotlin.mutliplatform) apply false |
15 | 3 | alias(libs.plugins.kotlin.binaryCompatibility)
|
16 |
| - alias(libs.plugins.kotlin.dokka) |
17 | 4 | alias(libs.plugins.nexus.publish)
|
18 |
| - id("convention.publication") |
| 5 | + id("convention.properties") |
19 | 6 | }
|
20 | 7 |
|
21 |
| -repositories { |
22 |
| - mavenCentral() |
| 8 | +allprojects { |
| 9 | + repositories { |
| 10 | + mavenCentral() |
| 11 | + } |
23 | 12 | }
|
24 | 13 |
|
25 | 14 | apiValidation {
|
26 | 15 | ignoredProjects += listOf("benchmark", "test-suites", "generator")
|
27 | 16 | }
|
28 | 17 |
|
29 |
| -val generatedSourceDirectory: Provider<Directory> = layout.buildDirectory.dir("generated/source/unicode") |
30 |
| - |
31 |
| -//region Generation tasks block |
32 |
| -val generatorConfiguration: Configuration by configurations.creating |
33 |
| - |
34 |
| -dependencies { |
35 |
| - generatorConfiguration(project(":generator")) |
36 |
| -} |
37 |
| - |
38 |
| -val dumpDir: File = layout.projectDirectory.dir("unicode_dump").asFile |
39 |
| - |
40 |
| -val dumpCharacterData by tasks.register<JavaExec>("dumpCharacterData") { |
41 |
| - onlyIf { |
42 |
| - dumpDir.run { !exists() || listFiles().isNullOrEmpty() } |
43 |
| - } |
44 |
| - outputs.dir(dumpDir) |
45 |
| - classpath(generatorConfiguration) |
46 |
| - mainClass.set("io.github.optimumcode.unocode.generator.Main") |
47 |
| - args( |
48 |
| - "dump", |
49 |
| - "-o", |
50 |
| - dumpDir, |
51 |
| - ) |
52 |
| -} |
53 |
| - |
54 |
| -val generateCharacterDirectionData by tasks.register<JavaExec>("generateCharacterDirectionData") { |
55 |
| - inputs.dir(dumpDir) |
56 |
| - outputs.dir(generatedSourceDirectory) |
57 |
| - |
58 |
| - dependsOn(dumpCharacterData) |
59 |
| - |
60 |
| - classpath(generatorConfiguration) |
61 |
| - mainClass.set("io.github.optimumcode.unocode.generator.Main") |
62 |
| - args( |
63 |
| - "character-direction", |
64 |
| - "-p", |
65 |
| - "io.github.optimumcode.json.schema.internal.unicode", |
66 |
| - "-o", |
67 |
| - generatedSourceDirectory.get(), |
68 |
| - "-d", |
69 |
| - dumpDir, |
70 |
| - ) |
71 |
| -} |
72 |
| - |
73 |
| -val generateCharacterCategoryData by tasks.register<JavaExec>("generateCharacterCategoryData") { |
74 |
| - inputs.dir(dumpDir) |
75 |
| - outputs.dir(generatedSourceDirectory) |
76 |
| - |
77 |
| - dependsOn(dumpCharacterData) |
78 |
| - |
79 |
| - classpath(generatorConfiguration) |
80 |
| - mainClass.set("io.github.optimumcode.unocode.generator.Main") |
81 |
| - args( |
82 |
| - "character-category", |
83 |
| - "-p", |
84 |
| - "io.github.optimumcode.json.schema.internal.unicode", |
85 |
| - "-o", |
86 |
| - generatedSourceDirectory.get(), |
87 |
| - "-d", |
88 |
| - dumpDir, |
89 |
| - ) |
90 |
| -} |
91 |
| - |
92 |
| -val generateDerivedProperties by tasks.register<JavaExec>("generateDerivedProperties") { |
93 |
| - val dataFile = |
94 |
| - layout.projectDirectory |
95 |
| - .dir("generator") |
96 |
| - .dir("data") |
97 |
| - .file("rfc5895_appendix_b_1.txt") |
98 |
| - inputs.file(dataFile) |
99 |
| - outputs.dir(generatedSourceDirectory) |
100 |
| - |
101 |
| - classpath(generatorConfiguration) |
102 |
| - mainClass.set("io.github.optimumcode.unocode.generator.Main") |
103 |
| - args( |
104 |
| - "derived-properties", |
105 |
| - "-p", |
106 |
| - "io.github.optimumcode.json.schema.internal.unicode", |
107 |
| - "-o", |
108 |
| - generatedSourceDirectory.get(), |
109 |
| - "-d", |
110 |
| - dataFile, |
111 |
| - ) |
112 |
| -} |
113 |
| - |
114 |
| -val generateJoiningTypes by tasks.register<JavaExec>("generateJoiningTypes") { |
115 |
| - val dataFile = |
116 |
| - layout.projectDirectory |
117 |
| - .dir("generator") |
118 |
| - .dir("data") |
119 |
| - .file("DerivedJoiningType.txt") |
120 |
| - inputs.file(dataFile) |
121 |
| - outputs.dir(generatedSourceDirectory) |
122 |
| - |
123 |
| - classpath(generatorConfiguration) |
124 |
| - mainClass.set("io.github.optimumcode.unocode.generator.Main") |
125 |
| - args( |
126 |
| - "joining-types", |
127 |
| - "-p", |
128 |
| - "io.github.optimumcode.json.schema.internal.unicode", |
129 |
| - "-o", |
130 |
| - generatedSourceDirectory.get(), |
131 |
| - "-d", |
132 |
| - dataFile, |
133 |
| - ) |
134 |
| -} |
135 |
| -//endregion |
136 |
| - |
137 |
| -kotlin { |
138 |
| - explicitApi() |
139 |
| - |
140 |
| - @OptIn(ExperimentalKotlinGradlePluginApi::class) |
141 |
| - compilerOptions { |
142 |
| - freeCompilerArgs.add("-opt-in=io.github.optimumcode.json.schema.ExperimentalApi") |
143 |
| - } |
144 |
| - jvmToolchain(11) |
145 |
| - jvm { |
146 |
| - testRuns["test"].executionTask.configure { |
147 |
| - useJUnitPlatform() |
148 |
| - } |
149 |
| - } |
150 |
| - js(IR) { |
151 |
| - browser { |
152 |
| - commonWebpackConfig { |
153 |
| - cssSupport { |
154 |
| - enabled.set(true) |
155 |
| - } |
156 |
| - } |
157 |
| - } |
158 |
| - generateTypeScriptDefinitions() |
159 |
| - nodejs() |
160 |
| - } |
161 |
| - applyDefaultHierarchyTemplate() |
162 |
| - |
163 |
| - val macOsTargets = |
164 |
| - listOf<KotlinTarget>( |
165 |
| - macosX64(), |
166 |
| - macosArm64(), |
167 |
| - iosX64(), |
168 |
| - iosArm64(), |
169 |
| - iosSimulatorArm64(), |
170 |
| - ) |
171 |
| - |
172 |
| - val linuxTargets = |
173 |
| - listOf<KotlinTarget>( |
174 |
| - linuxX64(), |
175 |
| - linuxArm64(), |
176 |
| - ) |
177 |
| - |
178 |
| - val windowsTargets = |
179 |
| - listOf<KotlinTarget>( |
180 |
| - mingwX64(), |
181 |
| - ) |
182 |
| - |
183 |
| - sourceSets { |
184 |
| - commonMain { |
185 |
| - kotlin.srcDirs(generatedSourceDirectory) |
186 |
| - |
187 |
| - dependencies { |
188 |
| - api(libs.kotlin.serialization.json) |
189 |
| - api(libs.uri) |
190 |
| - // When using approach like above you won't be able to add because block |
191 |
| - implementation( |
192 |
| - libs.kotlin.codepoints |
193 |
| - .get() |
194 |
| - .toString(), |
195 |
| - ) { |
196 |
| - because("simplifies work with unicode codepoints") |
197 |
| - } |
198 |
| - implementation(libs.normalize.get().toString()) { |
199 |
| - because("provides normalization required by IDN-hostname format") |
200 |
| - } |
201 |
| - } |
202 |
| - } |
203 |
| - commonTest { |
204 |
| - dependencies { |
205 |
| - implementation(libs.kotest.assertions.core) |
206 |
| - implementation(libs.kotest.framework.engine) |
207 |
| - implementation(kotlin("test-common")) |
208 |
| - implementation(kotlin("test-annotations-common")) |
209 |
| - } |
210 |
| - } |
211 |
| - jvmTest { |
212 |
| - dependencies { |
213 |
| - implementation(libs.kotest.runner.junit5) |
214 |
| - } |
215 |
| - } |
216 |
| - } |
217 |
| - |
218 |
| - fun Task.addGeneratedTasks() { |
219 |
| - dependsOn( |
220 |
| - generateCharacterDirectionData, |
221 |
| - generateCharacterCategoryData, |
222 |
| - generateDerivedProperties, |
223 |
| - generateJoiningTypes, |
224 |
| - ) |
225 |
| - } |
226 |
| - |
227 |
| - targets.configureEach { |
228 |
| - val capitalizedTargetName = |
229 |
| - name.replaceFirstChar { if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString() } |
230 |
| - tasks.named("compileKotlin$capitalizedTargetName") { |
231 |
| - addGeneratedTasks() |
232 |
| - } |
233 |
| - } |
234 |
| - afterEvaluate { |
235 |
| - targets.configureEach { |
236 |
| - tasks.named("${name}SourcesJar") { |
237 |
| - addGeneratedTasks() |
238 |
| - } |
239 |
| - } |
240 |
| - tasks.named("sourcesJar") { |
241 |
| - addGeneratedTasks() |
242 |
| - } |
243 |
| - } |
244 |
| - |
245 |
| - afterEvaluate { |
246 |
| - fun Task.dependsOnTargetTests(targets: List<KotlinTarget>) { |
247 |
| - targets.forEach { |
248 |
| - if (it is KotlinTargetWithTests<*, *>) { |
249 |
| - dependsOn(tasks.getByName("${it.name}Test")) |
250 |
| - } |
251 |
| - } |
252 |
| - } |
253 |
| - tasks.register("macOsAllTest") { |
254 |
| - group = "verification" |
255 |
| - description = "runs all tests for MacOS and IOS targets" |
256 |
| - dependsOnTargetTests(macOsTargets) |
257 |
| - } |
258 |
| - tasks.register("windowsAllTest") { |
259 |
| - group = "verification" |
260 |
| - description = "runs all tests for Windows targets" |
261 |
| - dependsOnTargetTests(windowsTargets) |
262 |
| - } |
263 |
| - tasks.register("linuxAllTest") { |
264 |
| - group = "verification" |
265 |
| - description = "runs all tests for Linux targets" |
266 |
| - dependsOnTargetTests(linuxTargets) |
267 |
| - dependsOn(tasks.getByName("jvmTest")) |
268 |
| - dependsOn(tasks.getByName("jsTest")) |
269 |
| - } |
270 |
| - } |
271 |
| -} |
272 |
| - |
273 |
| -afterEvaluate { |
274 |
| - val taskNames = setOf("compile", "detekt", "runKtlint") |
275 |
| - tasks.configureEach { |
276 |
| - // There is something wrong with compileCommonMainKotlinMetadata task |
277 |
| - // Gradle cannot find it, but this task uses the generated source directory |
278 |
| - // and Gradle reports implicit dependency. |
279 |
| - // As a workaround I do this - seems like it is working. |
280 |
| - // However, I might be missing something. Need to revisit this later. |
281 |
| - |
282 |
| - if (taskNames.any { name.startsWith(it) }) { |
283 |
| - mustRunAfter( |
284 |
| - generateCharacterDirectionData, |
285 |
| - generateCharacterCategoryData, |
286 |
| - generateDerivedProperties, |
287 |
| - generateJoiningTypes, |
288 |
| - ) |
289 |
| - } |
290 |
| - } |
291 |
| -} |
292 |
| - |
293 |
| -kover { |
294 |
| - reports { |
295 |
| - filters { |
296 |
| - excludes { |
297 |
| - packages( |
298 |
| - "io.github.optimumcode.json.schema.internal.unicode.*", |
299 |
| - "io.github.optimumcode.json.schema.internal.unicode", |
300 |
| - ) |
301 |
| - } |
302 |
| - } |
303 |
| - } |
304 |
| -} |
305 |
| - |
306 |
| -ktlint { |
307 |
| - version.set(libs.versions.ktlint) |
308 |
| - reporters { |
309 |
| - reporter(ReporterType.HTML) |
310 |
| - } |
311 |
| - filter { |
312 |
| - exclude { el -> |
313 |
| - val absolutePath = el.file.absolutePath |
314 |
| - absolutePath.contains("generated").and(!el.isDirectory) |
315 |
| - } |
316 |
| - } |
317 |
| -} |
318 |
| - |
319 |
| -afterEvaluate { |
320 |
| - val detektAllTask by tasks.register("detektAll") { |
321 |
| - dependsOn(tasks.withType<Detekt>()) |
322 |
| - } |
323 |
| - |
324 |
| - tasks.named("check").configure { |
325 |
| - dependsOn(detektAllTask) |
326 |
| - } |
327 |
| -} |
328 |
| - |
329 | 18 | val ossrhUsername: String by project.ext
|
330 | 19 | val ossrhPassword: String by project.ext
|
331 | 20 |
|
|
0 commit comments