-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.gradle
191 lines (155 loc) · 3.88 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
186
187
188
189
190
191
/*
* This file was generated by the Gradle 'init' task.
*
* This is a general purpose Gradle build.
* Learn more about Gradle by exploring our samples at https://docs.gradle.org/7.4/samples
* This project uses @Incubating APIs which are subject to change.
*/
/********
* PLUGINS
*********/
plugins {
id "java"
id "jacoco"
id "checkstyle"
id "com.github.spotbugs" version "5.0.4"
id "com.github.kt3k.coveralls" version "2.12.0"
id "application"
id "eclipse"
id 'idea'
}
/********************************
* APP PROPERTIES AND DEPENDENCIES
*********************************/
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
dependencies {
// JUnit 5
testImplementation(platform('org.junit:junit-bom:5.8.2'))
testImplementation('org.junit.jupiter:junit-jupiter')
compileOnly("com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}")
}
/**************
* PLUGINS SETUP
***************/
/*
* Checkstyle
*/
checkstyle {
// Whether to allow the build to continue if there are warnings.
// (default: ignoreFailures = false)
ignoreFailures = true
toolVersion "10.1"
}
/*
* Spotbugs
*/
spotbugs {
ignoreFailures = true
toolVersion = "4.5.3"
reportsDir = file("$buildDir/reports/spotbugs")
}
/*
* JaCoCo
*/
jacocoTestReport {
// Show code coverage results
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
executionData(fileTree(project.rootDir.absolutePath).include("**/${buildDir}/jacoco/*.exec"))
reports {
xml.required = true
csv.required = false
xml.outputLocation = file("${buildDir}/reports/jacoco/test/jacocoTestReport.xml")
html.outputLocation = file("${buildDir}/reports/jacoco/test/jacocoTestReport_html/")
}
}
/*
* Coveralls
*/
coveralls {
jacocoReportPath 'build/reports/jacoco/test/jacocoTestReport.xml'
}
/*
* Eclispe
*/
eclipse {
project {
name = 'wordle'
}
}
/***********
* TASK SETUP
************/
checkstyleMain {
source = 'src/main/java'
}
checkstyleTest {
source ='src/test/java'
}
spotbugsMain {
reports {
html.required = true
text.required = true
}
}
spotbugsTest {
reports {
html.required = true
text.required = true
}
}
run {
standardInput = System.in
}
// To run the program via Gradle, invoke the `run` task as follows.
// ./gradlew run -q --console=plain
test {
// Use JUnit 5
useJUnitPlatform()
// Always run tests, even when nothing changed.
dependsOn 'cleanTest'
// Show test results.
testLogging {
events "passed", "skipped", "failed"
}
finalizedBy jacocoTestReport
}
// Print spotbugs report (for the `main` sourceset) to the console
task spotbugsMainReport {
doLast {
if(file("$buildDir/reports/spotbugs/main.txt").exists()) {
file("$buildDir/reports/spotbugs/main.txt").readLines().forEach {
println( it )
}
}
}
}
tasks.getByName('spotbugsMain').finalizedBy('spotbugsMainReport')
// Print spotbugs report (for the `test` sourceset) to the console
task spotbugsTestReport {
doLast {
if(file("$buildDir/reports/spotbugs/test.txt").exists()){
file("$buildDir/reports/spotbugs/test.txt").readLines().forEach {
println( it )
}
}
}
}
tasks.getByName('spotbugsTest').finalizedBy('spotbugsTestReport')
// Generate the executable Jar (to be included in the Docker container)
task fatJar(type: Jar) {
manifest {
attributes 'Main-Class': 'it.uniba.app/App'
}
archiveBaseName = project.name + '-all'
from { configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) } }
with jar
}
project.tasks.getByName('build').dependsOn fatJar
/***********************
* MAIN CLASS DECLARATION
************************/
mainClassName = 'it.uniba.app/App'