-
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbuild.gradle
More file actions
161 lines (135 loc) · 4.19 KB
/
Copy pathbuild.gradle
File metadata and controls
161 lines (135 loc) · 4.19 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
159
160
161
/*
* This file was generated by the Gradle 'init' task.
*
* This generated file contains a sample Java application project to get you started.
* For more details take a look at the 'Building Java & JVM projects' chapter in the Gradle
* User Manual available at https://docs.gradle.org/8.0.2/userguide/building_java_projects.html
*/
plugins {
// Apply the application plugin to add support for building a CLI application in Java.
id 'application'
id 'checkstyle'
id 'org.openrewrite.rewrite' version '7.39.0'
id 'jacoco'
id 'org.barfuin.gradle.jacocolog' version '4.0.2'
id 'com.adarshr.test-logger' version '4.0.0'
id "org.sonarqube" version "7.5.0.8588"
id "com.github.ben-manes.versions" version "0.62.0"
id "com.diffplug.spotless" version "8.10.2"
}
import org.gradle.api.tasks.testing.TestListener
import org.gradle.api.tasks.testing.TestDescriptor
repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
}
dependencies {
// Use JUnit Jupiter for testing.
testImplementation 'org.junit.jupiter:junit-jupiter:6.1.3'
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
// This dependency is used by the application.
implementation 'com.google.guava:guava:33.7.1-jre'
//
implementation 'com.fasterxml.jackson.core:jackson-core:2.22.2'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.22'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.22.2'
rewrite 'org.openrewrite.recipe:rewrite-static-analysis:latest.release'
}
application {
// Define the main class for the application.
mainClass = 'projecteuler.java.App'
}
tasks.named('test') {
// Use JUnit Platform for unit tests.
useJUnitPlatform()
}
checkstyle {
toolVersion = '14.1.0'
configFile = file("${rootDir}/checkstyle.xml")
maxErrors = 0
maxWarnings = 0
showViolations = true
}
spotless {
java {
target 'src/*/java/**/*.java'
googleJavaFormat('1.33.0')
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
}
// Reference: https://docs.openrewrite.org/running-recipes/popular-recipe-guides/automatically-fix-checkstyle-violations
rewrite {
activeRecipe 'org.openrewrite.staticanalysis.CodeCleanup'
checkstyleConfigFile = file("checkstyle.xml")
}
configurations.checkstyle {
resolutionStrategy.capabilitiesResolution.withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:33.7.1-jre")
}
}
def jacocoExclusions = [
'**/*App.class',
'**/util/*'
];
test {
maxHeapSize = "1024m"
finalizedBy jacocoTestReport // report is always generated after tests run
// Reference: https://discuss.gradle.org/t/unable-to-configure-java-util-logging-with-gradle-test-task/2034
systemProperty 'java.util.logging.config.file', 'build/resources/test/logging.properties'
// Reference: https://stackoverflow.com/a/43289870/6366150
testLogging {
showStandardStreams = true
events "passed", "skipped", "failed"
}
addTestListener(new TestListener() {
void beforeTest(TestDescriptor descriptor) {
logger.lifecycle("Running test: ${descriptor}")
}
})
}
jacoco {
toolVersion = "0.8.15"
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
html.required = true
xml {
required = true
outputLocation = file("$buildDir/jacoco.xml")
}
}
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: jacocoExclusions
)
}))
}
}
jacocoTestCoverageVerification {
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it,
exclude: jacocoExclusions
)
}))
}
violationRules {
rule {
excludes = jacocoExclusions
limit {
minimum = 0.90
}
}
}
}
sonar {
properties {
property "sonar.projectKey", "sir-gon_algorithm-exercises-java"
property "sonar.organization", "sir-gon"
property "sonar.host.url", "https://sonarcloud.io"
}
}