forked from tursodatabase/turso
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle.kts
More file actions
158 lines (137 loc) · 4.87 KB
/
build.gradle.kts
File metadata and controls
158 lines (137 loc) · 4.87 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
import net.ltgt.gradle.errorprone.CheckSeverity
import net.ltgt.gradle.errorprone.errorprone
import org.gradle.api.tasks.testing.logging.TestExceptionFormat
import org.gradle.api.tasks.testing.logging.TestLogEvent
plugins {
java
application
`java-library`
`maven-publish`
signing
id("net.ltgt.errorprone") version "3.1.0"
// If you're stuck on JRE 8, use id 'com.diffplug.spotless' version '6.13.0' or older.
id("com.diffplug.spotless") version "6.13.0"
}
// Apply publishing configuration
apply(from = "gradle/publish.gradle.kts")
// Helper function to read properties with defaults
fun prop(key: String, default: String? = null): String? =
findProperty(key)?.toString() ?: default
group = prop("projectGroup") ?: error("projectGroup must be set in gradle.properties")
version = prop("projectVersion") ?: error("projectVersion must be set in gradle.properties")
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
withJavadocJar()
withSourcesJar()
}
// TODO: Add javadoc to required class and methods. After that, let's remove this settings
tasks.withType<Javadoc> {
options {
(this as StandardJavadocDocletOptions).apply {
addStringOption("Xdoclint:none", "-quiet")
}
}
}
repositories {
mavenCentral()
}
dependencies {
compileOnly("org.slf4j:slf4j-api:1.7.32")
errorprone("com.uber.nullaway:nullaway:0.10.26") // maximum version which supports java 8
errorprone("com.google.errorprone:error_prone_core:2.10.0") // maximum version which supports java 8
testImplementation(platform("org.junit:junit-bom:5.10.0"))
testImplementation("org.junit.jupiter:junit-jupiter")
testImplementation("org.assertj:assertj-core:3.27.0")
}
application {
val tursoSystemLibraryPath = System.getenv("TURSO_LIBRARY_PATH")
if (tursoSystemLibraryPath != null) {
applicationDefaultJvmArgs = listOf(
"-Djava.library.path=${System.getProperty("java.library.path")}:$tursoSystemLibraryPath"
)
}
}
tasks.jar {
from("libs") {
into("libs")
}
}
sourceSets {
test {
resources {
file("src/main/resource/turso-jdbc.properties")
}
}
}
tasks.test {
useJUnitPlatform()
// In order to find rust built file under resources, we need to set it as system path
systemProperty(
"java.library.path",
"${System.getProperty("java.library.path")}:$projectDir/src/test/resources/turso/debug"
)
// For our fancy test logging
testLogging {
// set options for log level LIFECYCLE
events(
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_OUT
)
exceptionFormat = TestExceptionFormat.FULL
showExceptions = true
showCauses = true
showStackTraces = true
// set options for log level DEBUG and INFO
debug {
events(
TestLogEvent.STARTED,
TestLogEvent.FAILED,
TestLogEvent.PASSED,
TestLogEvent.SKIPPED,
TestLogEvent.STANDARD_ERROR,
TestLogEvent.STANDARD_OUT
)
exceptionFormat = TestExceptionFormat.FULL
}
info.events = debug.events
info.exceptionFormat = debug.exceptionFormat
afterSuite(KotlinClosure2<TestDescriptor, TestResult, Unit>({ desc, result ->
if (desc.parent == null) { // will match the outermost suite
val output = "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} passed, ${result.failedTestCount} failed, ${result.skippedTestCount} skipped)"
val startItem = "| "
val endItem = " |"
val repeatLength = startItem.length + output.length + endItem.length
println("\n" + "-".repeat(repeatLength) + "\n" + startItem + output + endItem + "\n" + "-".repeat(repeatLength))
}
}))
}
}
tasks.withType<JavaCompile> {
options.errorprone {
// Let's select which checks to perform. NullAway is enough for now.
disableAllChecks = true
check("NullAway", CheckSeverity.ERROR)
option("NullAway:AnnotatedPackages", "tech.turso")
option(
"NullAway:CustomNullableAnnotations",
"tech.turso.annotations.Nullable,tech.turso.annotations.SkipNullableCheck"
)
}
if (name.lowercase().contains("test")) {
options.errorprone {
disable("NullAway")
}
}
}
spotless {
java {
target("**/*.java")
targetExclude(layout.buildDirectory.dir("**/*.java").get().asFile)
targetExclude("example/**/*.java")
removeUnusedImports()
googleJavaFormat("1.7") // or use eclipse().configFile("path/to/eclipse-format.xml")
}
}