-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
185 lines (159 loc) · 8.08 KB
/
build.gradle.kts
File metadata and controls
185 lines (159 loc) · 8.08 KB
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
import org.jetbrains.kotlin.incremental.createDirectory
import java.util.*
import kotlin.experimental.xor
plugins {
java
id("org.springframework.boot") version "3.4.4"
id("io.spring.dependency-management") version "1.1.7"
id("org.flywaydb.flyway") version "11.4.0"
id("gg.jte.gradle") version "3.1.16"
jacoco
}
group = "edu.kit.hci"
version = "0.0.1-SNAPSHOT"
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
configurations {
compileOnly {
extendsFrom(configurations.annotationProcessor.get())
}
}
val doctex by configurations.creating
val cdg by configurations.creating
// Used to un-salt the credentials for the GitHub package repository
// For some reason, GitHub does not allow anonymous access to public packages,
// so we have to embed the credentials.
// Salting them makes it harder to find the credentials and should prevent automatic discovery, but does not make them secure.
// As such, a restricted token of a service account is used.
private fun unsalt(data: String, salt: LongArray) = salt.map { Random(it shl 3 or 12) }.run { Base64.getDecoder().decode(data).mapIndexed { l, r -> ByteArray(5).let { get((l + 3 shr 5).mod(size - (l % 2))).nextBytes(it); it[l % 4] } xor r } }.toByteArray().let { dm -> dm.decodeToString(dm[11].toUByte().toInt() % 65, dm.size - dm[12].toUByte().toInt() % dm[11].toUByte().toInt(), false) }.replace('\uFFFD', '1')
repositories {
mavenCentral()
maven("https://maven.pkg.github.com/Solidarische-Raumnutzung/DocTeX") {
credentials {
username = ""
password = unsalt("MsUHMHvj/UIdFMSOMTkYborAekxPK52/EB4bp2Kxmd+cShtWiO6xXeMJp1NNIvBhAcNvH35gG2/uh9DRCs8+mf3YzyIIarY+1hTSOW6BAi3tkqOxDmNfU4bbKKj/M/JpmSKnafLJYcdMH1ASRvEWuCA=", longArrayOf(-1344705729828745711, 5230045263062089707, 3545512903530151910, 7538809493429025070, -2925924544857994240, -8595937774785329809, -4208388178093363894, 6992710797411217798, -6389370378960172826, 3591822878033896109, 8889865935792943001, -4262397429266853753, 2298705730591068518, 4714639302703995747, -7464986330344552584, -7518779346602212671, -7579240134292203452, 2373566333070360596, 6000643398013606382, 1307504402323163593, 3915882559778035436, -8081209879159995769, -9207588343828866839, -3787429060347275080, 6273897675385322987, 288272166847093320, 6835607591775321015, -6203230303138578259, -4541277508978494093, 2065286167320721702, -2261015450204600435, -9132305004876616378, -7041677951324361252, 5891454128313438131, 3367594326194710532, 7273550992031740203, 980246378010968093, -145285380090142264, 5638755824395442070, -4662549621614845308, -8319182660990689705, 4593349031178611454, 9188854271361800229, 3389677104980428669, -1826074559192361909, -991538057649777867, 6767921920810646389, 425275679354278601, -1129287175256942626, 3246752065518662417, -3173336438845015123, 324568664530661404))
}
}
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
runtimeOnly("org.postgresql:postgresql")
implementation("org.flywaydb:flyway-core:11.4.1") // TODO: remove explicit version when the Spring Boot version is updated
implementation("org.flywaydb:flyway-database-postgresql:11.4.1")
implementation("org.springframework.boot:spring-boot-starter-mail")
implementation("org.springframework.boot:spring-boot-starter-oauth2-client")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("gg.jte:jte:3.1.16")
implementation("org.springframework.boot:spring-boot-starter-security")
annotationProcessor("com.google.auto.service:auto-service:1.1.1")
testAnnotationProcessor(annotationProcessor("org.projectlombok:lombok")!!)
testCompileOnly(compileOnly("org.projectlombok:lombok")!!)
compileOnly("org.jetbrains:annotations:26.0.2")
doctex("edu.kit.hci.soli:doctex:1.0.1-SNAPSHOT")
cdg("edu.kit.hci.soli:cdg:1.0-SNAPSHOT")
// https://docs.spring.io/spring-boot/reference/features/dev-services.html#features.dev-services.docker-compose
testAndDevelopmentOnly("org.springframework.boot:spring-boot-docker-compose")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.springframework.security:spring-security-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}
jte {
generate()
binaryStaticContent = true
trimControlStructures = true
packageName = "edu.kit.hci.soli.view.jte"
}
tasks {
withType<Test> {
useJUnitPlatform()
}
val copyArtifact by creating(Copy::class) {
dependsOn(bootJar)
from(bootJar)
into(layout.buildDirectory.dir("libs"))
rename(".*\\.jar", "app.jar")
}
assemble {
dependsOn(copyArtifact)
}
val patchJteSources by creating {
// By default, JTE does not mark its generated classes as such, which is a problem for our coverage
fun String.markGenerated() = replace("""
@SuppressWarnings("unchecked")
public final class Jte
""".trimIndent().trim(), """
@SuppressWarnings("unchecked")
@edu.kit.hci.soli.config.Generated
public final class Jte
""".trimIndent().trim())
// This is necessary because JTE does not use lambdas here and inner classes cause performance issues and mess with our coverage
fun String.lambdafy(indent: String = "\t\t\t", jteOutput: String = "jteOutput"): String {
val head = "new gg.jte.html.HtmlContent() {\n${indent}public void writeTo(gg.jte.html.HtmlTemplateOutput $jteOutput) {"
val tail = "\n${indent}}"
val headIndex = indexOf(head)
if (headIndex == -1) return this
val tailIndex = indexOf(tail, headIndex)
if (tailIndex == -1) throw Exception("Could not find tail of lambda in JTE source")
val lowerJteOutput = "${jteOutput}_"
val loweredSection = (1..10).map { "\t".repeat(it) }.map { "$indent$it" } // Conditions may cause this to vary
.fold(substring(headIndex + head.length, tailIndex).replace(jteOutput, lowerJteOutput)) { l, i -> l.lambdafy(i, lowerJteOutput) }
val result = substring(0, headIndex) + "(gg.jte.html.HtmlContent) ${jteOutput}_ -> {" +
loweredSection +
substring(tailIndex + tail.length)
return result.lambdafy(indent, jteOutput) // Recurse to handle multiple lambdas
}
// Patch the generated JTE sources
doLast {
layout.buildDirectory.dir("generated-sources/jte").get()
.asFileTree
.filter { it.isFile && it.extension == "java" }
.forEach {
it.writeText(it.readText()
.markGenerated()
.lambdafy()
)
}
}
}
generateJte {
finalizedBy(patchJteSources)
}
compileJava {
dependsOn(patchJteSources)
}
jacocoTestReport {
dependsOn(test)
reports {
xml.required = true
}
classDirectories = files(classDirectories.files.map { fileTree(it) {
exclude("edu/kit/hci/soli/config/**")
} })
}
val doctex by creating(JavaExec::class) {
group = "documentation"
description = "Generate documentation from LaTeX sources"
mainClass = "de.mr_pine.doctex.CliKt"
classpath = doctex
args(
"--output=./docs/entwurfsheft/javadoc",
layout.projectDirectory.dir("src/main/java"),
"edu.kit.hci.soli"
)
}
val classDiagram by creating(JavaExec::class) {
group = "documentation"
description = "Generate a class diagram"
mainClass = "edu.kit.hci.soli.cdg.MainKt"
classpath = cdg
args(
layout.projectDirectory.dir("src/main/java"),
"edu.kit.hci.soli"
)
workingDir = layout.buildDirectory.dir("cdg").get().asFile
doFirst { workingDir.createDirectory() }
}
}