forked from mattttvaughn/chronicle
-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
65 lines (58 loc) · 2.72 KB
/
Copy pathbuild.gradle.kts
File metadata and controls
65 lines (58 loc) · 2.72 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
plugins {
alias(libs.plugins.android.application) apply false
alias(libs.plugins.kotlin.android) apply false
alias(libs.plugins.ksp) apply false
alias(libs.plugins.play.publisher) apply false
alias(libs.plugins.ktlint)
}
allprojects {
apply(plugin = "org.jlleitschuh.gradle.ktlint")
// KAPT configuration for Kotlin 2.x (needed for data binding which doesn't fully support KSP)
tasks.matching { it.javaClass.name == "org.jetbrains.kotlin.gradle.tasks.KaptTask" }
.configureEach {
try {
val kaptArgsMethod = this.javaClass.methods.firstOrNull { m -> m.name == "kaptArgs" }
if (kaptArgsMethod != null) {
val kaptArgs = kaptArgsMethod.invoke(this)
val argMethod = kaptArgs.javaClass.methods.firstOrNull { m -> m.name == "arg" && m.parameterTypes.size == 2 }
if (argMethod != null) {
val addOpens =
listOf(
"jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
"jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
)
addOpens.forEach { value ->
argMethod.invoke(kaptArgs, "--add-opens", value)
}
}
}
} catch (e: Exception) {
logger.debug("Failed to configure kaptArgs via reflection: ${e.message}")
}
}
}
buildscript {
dependencies {
classpath(libs.oss.plugin)
}
}
ktlint {
android.set(true)
}
tasks.register<Copy>("installGitHook") {
from(rootProject.file("pre-commit"))
into(rootProject.file(".git/hooks"))
}
// Ensure the app preBuild depends on the git hook installer. Use matching/configureEach to avoid
// deprecated fileCollection/spec usage that can appear with getByPath on newer Gradle.
tasks.matching { it.path == ":app:preBuild" }.configureEach {
dependsOn(rootProject.tasks.named("installGitHook"))
}