-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.gradle.kts
147 lines (118 loc) · 4.49 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
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
application
kotlin("jvm")
kotlin("plugin.serialization") // setup kotlinx-serialization https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serialization-guide.md
// https://www.apollographql.com/docs/kotlin/
id("com.apollographql.apollo3")
}
group = "de.fayard"
version = "1.0-SNAPSHOT"
repositories {
mavenCentral()
maven("https://jitpack.io") {
content {
includeGroupByRegex("com.github.*")
}
}
}
dependencies {
testImplementation(Testing.junit.jupiter)
testImplementation(Kotlin.test.junit5)
testImplementation(Testing.kotest.runner.junit5)
testImplementation(Testing.kotest.assertions.json)
testImplementation(Testing.kotest.framework.datatest)
implementation(Square.okHttp3)
// https://github.com/codeniko/JsonPathKt
implementation("com.nfeld.jsonpathkt:jsonpathkt:_")
implementation(Kotlin.stdlib.jdk8)
implementation(KotlinX.datetime)
implementation(KotlinX.collections.immutableJvmOnly)
implementation(KotlinX.coroutines.core)
implementation(KotlinX.coroutines.jdk8)
implementation(KotlinX.serialization.core)
implementation(KotlinX.serialization.json)
implementation(KotlinX.serialization.properties)
implementation("com.charleskorn.kaml:kaml:_")
implementation("de.brudaswen.kotlinx.serialization:kotlinx-serialization-csv:_")
implementation("org.hibernate.validator:hibernate-validator:_")
implementation(Ktor.client.core)
implementation(Ktor.client.json)
implementation(Ktor.client.serialization)
implementation(Ktor.client.okHttp)
implementation(Ktor.client.logging)
implementation("io.ktor:ktor-client-content-negotiation:_")
implementation("io.ktor:ktor-serialization-kotlinx-json:_")
implementation(Square.okHttp3.loggingInterceptor)
implementation(Square.kotlinPoet)
implementation(Square.sqlDelight.drivers.jdbc)
implementation("com.github.kotlin-inquirer:kotlin-inquirer:_")
implementation("com.github.ajalt.clikt:clikt:_")
implementation("com.github.ajalt.mordant:mordant-jvm:_")
implementation("org.hibernate.validator:hibernate-validator:_")
implementation("io.arrow-kt:arrow-core:_") // optional
implementation("com.apollographql.apollo3:apollo-runtime:")
}
tasks.test {
useJUnitPlatform()
}
// Java version is set once for all in the file "system.properties"
val javaVersion = "17"
java {
sourceCompatibility = JavaVersion.toVersion(javaVersion)
targetCompatibility = JavaVersion.toVersion(javaVersion)
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = javaVersion
}
application {
mainClass.set("MainKt")
}
tasks.register("fixScripts") {
group = "application"
description = "Fix Kotlin Scripts (permissions, bash wrapper)"
fun bashWrapper(name: String): String = """
#!/usr/bin/env bash
which kotlin >/dev/null || {
echo "Install Kotlin compiler from https://kotlinlang.org/docs/command-line.html"
exit 1
}
kotlin $name.main.kts
""".trimIndent()
doFirst {
fun List<File>.log(message: String) =
println("$message: ${joinToString { it.name }}")
val kotlinScripts = file("scripts")
.listFiles { file -> file.extension == "kts" }
.toList()
.also { it.log("kotlinScripts") }
val notExecutable = kotlinScripts
.filterNot { it.canExecute() }
if (notExecutable.isEmpty()) {
println("OK: all Kotlin scripts are executables")
} else {
println("FIX permissions for: " + notExecutable.joinToString { it.name })
notExecutable.forEach { file ->
file.setExecutable(true)
}
}
val missingBashWrappers = kotlinScripts
.mapNotNull { file ->
file.resolveSibling(file.name.removeSuffix(".main.kts"))
.takeIf { it.canRead().not() }
}
if (missingBashWrappers.isEmpty()) {
println("OK: all Kotlin scripts have a Bash wrapper")
} else {
missingBashWrappers.forEach { file ->
println("FIX: creating Bash wrapper at ${file.canonicalPath}")
file.writeText(bashWrapper(file.canonicalPath))
file.setExecutable(true)
}
}
}
}
apollo {
packageName.set("github.graphql")
schemaFile.set(file("src/test/resources/github/schema.graphql"))
}