-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
185 lines (157 loc) · 5.38 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
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
plugins {
id 'java'
id 'jacoco'
id 'pmd'
id 'com.github.spotbugs' version '6.0.26'
id 'com.adarshr.test-logger' version '4.0.0'
id 'com.diffplug.spotless' version '6.25.0'
id 'com.github.ben-manes.versions' version '0.51.0'
}
static def path(String... args) {
return String.join(File.separator, args)
}
// Tunables
String appName = 'minimization-algorithms-library'
String version = '0.1.0'
String appDescription = 'A collection of minimization algorithms.'
String author = 'Filippo Barbari'
String authorMail = '[email protected]'
ext.junitVersion = '5.11.3'
allprojects {
apply plugin: 'java'
apply plugin: 'jacoco'
apply plugin: 'pmd'
apply plugin: 'com.github.spotbugs'
apply plugin: 'com.adarshr.test-logger'
apply plugin: 'com.github.ben-manes.versions'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
repositories {
mavenCentral()
}
dependencies {
testImplementation "org.junit.jupiter:junit-jupiter-api:$junitVersion"
testImplementation "org.junit.jupiter:junit-jupiter-params:$junitVersion" // parameterized tests
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:$junitVersion"
}
tasks.withType(JavaCompile).configureEach {
options.compilerArgs << '-Xdiags:verbose'
options.compilerArgs << '-Xlint:all'
options.compilerArgs << '-Werror'
options.deprecation = true
options.encoding = 'UTF-8'
}
javadoc {
failOnError = true
title "mal-v${version}-doc"
options.encoding = 'UTF-8'
options.addBooleanOption('Werror', true)
}
test {
useJUnitPlatform()
// failFast true
finalizedBy jacocoTestReport
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.required = true
csv.required = true
html.required = true
html.outputLocation = layout.buildDirectory.dir('jacoco')
}
}
jacoco {
toolVersion = "0.8.12"
reportsDirectory = layout.buildDirectory.dir('jacoco')
}
testlogger {
theme 'standard'
showExceptions true
showStackTraces true
showFullStackTraces false
showCauses true
slowThreshold 2000
showSummary true
showSimpleNames false
showPassed true
showSkipped true
showFailed true
showOnlySlow false
showStandardStreams true
showPassedStandardStreams true
showSkippedStandardStreams true
showFailedStandardStreams true
logLevel 'lifecycle'
}
pmd {
consoleOutput = true
toolVersion = "7.2.0"
rulesMinimumPriority = 5
threads = 1
incrementalAnalysis = true
ruleSetConfig = resources.text.fromFile(path("${project.rootDir}", "ruleset.xml"))
}
spotbugs {
toolVersion = '4.8.6'
ignoreFailures = false
showStackTraces = true
showProgress = false // too verbose for parallel output
}
// cleanup tasks
clean.dependsOn('cleanBin')
// remove default VSCode build directory
tasks.register('cleanBin', Delete) {
delete "${project.projectDir}/bin"
}
}
spotless {
format 'misc', {
target '*.md', '.gitignore', '.gitattributes'
trimTrailingWhitespace()
indentWithTabs()
endWithNewline()
setEncoding('utf-8')
}
java {
target fileTree('.') {
include path('**', '*.java')
exclude path('**', 'build', '**'), path('**', 'build-*', '**'), path('**', 'bin', '**')
}
setEncoding('utf-8')
removeUnusedImports()
palantirJavaFormat('2.50.0').formatJavadoc(true)
indentWithTabs()
formatAnnotations()
trimTrailingWhitespace()
endWithNewline()
// check https://javadoc.io/doc/com.diffplug.spotless/spotless-plugin-gradle/latest/com/diffplug/gradle/spotless/JavaExtension.html
importOrder('java', 'javax', 'javafx', 'org.junit', 'com', 'com.ledmington', 'org', group as String)
licenseHeader String.join("\n",
"/*",
"* ${appName} - ${appDescription}",
"* Copyright (C) 2023-${new Date().format('yyyy')} ${author} <${authorMail}>",
"*",
"* This program is free software: you can redistribute it and/or modify",
"* it under the terms of the GNU General Public License as published by",
"* the Free Software Foundation, either version 3 of the License, or",
"* (at your option) any later version.",
"*",
"* This program is distributed in the hope that it will be useful,",
"* but WITHOUT ANY WARRANTY; without even the implied warranty of",
"* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the",
"* GNU General Public License for more details.",
"*",
"* You should have received a copy of the GNU General Public License",
"* along with this program. If not, see <http://www.gnu.org/licenses/>.",
"*/",
)
}
}
allprojects.each {
it.tasks.compileJava.dependsOn(spotlessApply)
it.tasks.build.dependsOn(it.tasks.javadoc)
}