-
Notifications
You must be signed in to change notification settings - Fork 467
/
build.gradle
156 lines (132 loc) · 5 KB
/
build.gradle
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
plugins {
alias(libs.plugins.benmanes.versions) apply false
alias(libs.plugins.gradle.coverage.report.aggregator)
alias(libs.plugins.gradle.checker.processor) apply false
}
allprojects {
group 'software.coley'
version '4.0.0-SNAPSHOT'
}
subprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'maven-publish'
apply plugin: 'com.github.ben-manes.versions'
repositories {
mavenLocal()
mavenCentral()
google()
maven { url 'https://maven.quiltmc.org/repository/release/' }
maven { url 'https://jitpack.io' }
}
// ======================= DEPENDENCIES ========================
dependencies {
// to enforce it everywhere as standard
implementation(libs.jakarta.annotation)
}
configurations.configureEach {
// Annoying annotations that replace desired tab completions.
exclude group: 'org.checkerframework'
// Other annotations we don't use which are transitive deps of deps
exclude group: 'com.google.code.findbugs'
exclude group: 'com.google.errorprone'
exclude group: 'com.google.j2objc'
exclude group: 'org.jetbrains', module: 'annotations'
// Used by ANTLR runtime, has a lot of IL8N related files which we don't use.
// Removing this dependency doesn't inhibit the behavior of libraries using the
// runtime in practice though.
exclude group: 'com.ibm.icu'
}
// ========================== COMPILE ==========================
// https://docs.gradle.org/current/userguide/toolchains.html
// gradlew -q javaToolchains - see the list of detected toolchains.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(22)
}
}
// Append options for unchecked/deprecation
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << '-Xlint:unchecked' << '-Xlint:deprecation' << '-g' << '-parameters'
options.encoding = 'UTF-8'
options.incremental = true
}
// Enable automatic generation of null checks on annotated methods
afterEvaluate { Project p ->
p.plugins.apply('gov.tak.gradle.plugins.checker-processor')
}
// ========================== TESTING ==========================
// All modules should have the same test framework setup.
test {
useJUnitPlatform()
// Required for Mockito in newer JDK's which disable useful features by default for 'integrity' reasons.
jvmArgs '-XX:+EnableDynamicAgentLoading'
systemProperty 'junit.jupiter.execution.parallel.enabled', true
systemProperty 'junit.jupiter.execution.parallel.mode.default', 'concurrent'
testLogging {
showStandardStreams = true
events "passed", "skipped", "failed"
}
}
// All modules with Java components should share the same test dependencies.
plugins.withType(JavaPlugin).configureEach {
dependencies {
testImplementation(libs.junit.api)
testImplementation(libs.junit.params)
testImplementation(libs.mockito)
testRuntimeOnly(libs.junit.engine)
}
}
// Need to tell any test-fixture-plugin to include dependencies
// in its own configuration. Otherwise it can get confused.
plugins.withType(JavaTestFixturesPlugin).configureEach {
dependencies {
testFixturesApi(libs.junit.api)
testFixturesApi(libs.junit.params)
testFixturesApi(libs.mockito)
}
}
// Configure report outputs, and jacoco packages to target.
tasks.withType(Test).configureEach {
reports.html.required = false
reports.junitXml.required = true
// We want to cover all recaf classes, but not the test classes themselves.
// The exclusion list is applied after the inclusion list, so this ends up working out.
jacoco {
includes = ['software/coley/recaf/**']
excludes = ['software/coley/recaf/**Test']
}
}
// Setup artifact publishing to maven local
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
repositories {
mavenLocal()
}
}
}
// Always emit HTML & XML aggregate reports
jacocoAggregation {
outputHtml = true
outputXml = true
}
// Build aggregate report for test coverage when subproject 'test' tasks complete.
// But only do so when the 'test' tasks have executed.
// You can skip tests by specifying '-x test' in your gradle task arguments.
tasks.register('test') {
dependsOn(subprojects.test)
doLast {
if (subprojects.test.stream().anyMatch(Task::getDidWork))
buildJacocoAggregate.execute()
}
}
tasks.register('build') {
// Build will run tests, unless skipped by '-x test'.
// Even if skipped, this will still lead to the subproject build tasks being executed, such as:
// - recaf-ui:shadowJar
dependsOn(tasks.named('test'))
}