-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathbuild.gradle
More file actions
152 lines (132 loc) · 3.68 KB
/
build.gradle
File metadata and controls
152 lines (132 loc) · 3.68 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
plugins {
id 'java'
id 'checkstyle'
id 'jacoco'
id 'com.github.spotbugs' version '6.1.2'
id 'com.diffplug.spotless' version '7.0.2'
}
group = 'org.categoricaldata'
version = '1.0.0'
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDirs = ['src']
exclude 'test/**'
// OilExample.java has a text block exceeding JVM's 65535-byte constant pool limit.
// It compiles under Eclipse's ecj but not javac. Exclude until the string is split.
exclude '**/OilExample.java'
}
resources {
srcDirs = ['resources/open']
}
}
test {
java {
srcDirs = ['src/test/java']
}
}
}
dependencies {
// All existing JARs from lib/
implementation fileTree(dir: 'lib', include: ['*.jar'])
// Test dependencies
testImplementation 'org.junit.jupiter:junit-jupiter:5.11.4'
testImplementation 'org.mockito:mockito-core:5.14.2'
testImplementation 'org.mockito:mockito-junit-jupiter:5.14.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.compilerArgs += ['-Xlint:none']
}
// --- Testing ---
test {
useJUnitPlatform()
jvmArgs += ['--add-opens', 'java.base/java.lang=ALL-UNNAMED']
testLogging {
events 'passed', 'skipped', 'failed'
showStandardStreams = false
}
// Timeout for the full test suite (CQL examples can be slow)
timeout = java.time.Duration.ofMinutes(15)
}
// --- JaCoCo (Coverage) ---
jacoco {
toolVersion = '0.8.12'
}
jacocoTestReport {
dependsOn test
reports {
xml.required = true
html.required = true
csv.required = true
}
}
jacocoTestCoverageVerification {
dependsOn jacocoTestReport
violationRules {
rule {
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
minimum = 0.27
}
}
}
}
// --- Spotless (formatting) ---
spotless {
// Only check files that changed vs HEAD — won't flag existing unformatted code
ratchetFrom 'HEAD'
java {
target 'src/**/*.java'
targetExclude 'src/test/**', '**/easik/**', '**/com/**', '**/OilExample.java'
googleJavaFormat()
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
}
// Git pre-commit hook: runs spotlessCheck before each commit
tasks.register('installGitHook', Copy) {
from 'config/hooks/pre-commit'
into '.git/hooks'
filePermissions {
unix('rwxr-xr-x')
}
}
tasks.named('compileJava') {
dependsOn 'installGitHook'
}
// --- Checkstyle ---
checkstyle {
toolVersion = '10.21.1'
configFile = file('config/checkstyle/checkstyle.xml')
// Don't fail the build initially — just report
ignoreFailures = true
// Only check main sources, not tests
sourceSets = [project.sourceSets.main]
}
tasks.withType(Checkstyle).configureEach {
maxHeapSize = '1g'
}
// --- SpotBugs ---
spotbugs {
ignoreFailures = true
effort = com.github.spotbugs.snom.Effort.valueOf('MIN')
reportLevel = com.github.spotbugs.snom.Confidence.valueOf('HIGH')
excludeFilter = file('config/spotbugs/exclude.xml')
}
tasks.withType(com.github.spotbugs.snom.SpotBugsTask).configureEach {
reports {
html.required = true
xml.required = true
}
}