-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathsmithy-java.java-conventions.gradle.kts
More file actions
128 lines (111 loc) · 3.28 KB
/
smithy-java.java-conventions.gradle.kts
File metadata and controls
128 lines (111 loc) · 3.28 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
import com.github.spotbugs.snom.Effort
import org.gradle.accessors.dm.LibrariesForLibs
plugins {
`java-library`
id("com.adarshr.test-logger")
id("com.github.spotbugs")
id("com.diffplug.spotless")
id("com.autonomousapps.dependency-analysis")
id("smithy-java.utilities")
}
// Workaround per: https://github.com/gradle/gradle/issues/15383
val Project.libs get() = the<LibrariesForLibs>()
tasks.withType<JavaCompile>() {
options.encoding = "UTF-8"
options.release.set(21)
}
tasks.withType<Javadoc>() {
options.encoding = "UTF-8"
}
tasks.withType<AbstractArchiveTask> {
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}
/*
* Common test configuration
* ===============================
*/
dependencies {
testImplementation(platform(libs.junit.bom))
testImplementation(libs.junit.jupiter.api)
testRuntimeOnly(libs.junit.jupiter.engine)
testImplementation(libs.junit.jupiter.params)
testImplementation(libs.junit.platform.launcher)
testImplementation(libs.hamcrest)
testImplementation(libs.assertj.core)
compileOnly("com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}")
testCompileOnly("com.github.spotbugs:spotbugs-annotations:${spotbugs.toolVersion.get()}")
}
tasks.withType<Test> {
useJUnitPlatform()
}
testlogger {
showExceptions = true
showStackTraces = true
showFullStackTraces = false
showCauses = true
showSummary = false
showPassed = false
showSkipped = false
showFailed = true
showOnlySlow = false
showStandardStreams = true
showPassedStandardStreams = false
showSkippedStandardStreams = false
showFailedStandardStreams = true
logLevel = LogLevel.WARN
}
/*
* Formatting
* ==================
* see: https://github.com/diffplug/spotless/blob/main/plugin-gradle/README.md#java
*/
spotless {
java {
// Enforce a common license header on all files
licenseHeaderFile("${project.rootDir}/config/spotless/license-header.txt")
.onlyIfContentMatches("^((?!SKIPLICENSECHECK)[\\s\\S])*\$")
leadingTabsToSpaces()
endWithNewline()
eclipse().configFile("${project.rootDir}/config/spotless/formatting.xml")
// Static first, then everything else alphabetically
removeUnusedImports()
importOrder("\\#", "")
// Ignore generated generated code for formatter check
targetExclude("**/build/**/*.java", "**/build/generated-src*/*.*")
}
// Formatting for build.gradle.kts files
kotlinGradle {
ktlint()
leadingTabsToSpaces()
trimTrailingWhitespace()
endWithNewline()
}
}
/*
* Spotbugs
* ====================================================
*
* Run spotbugs against source files and configure suppressions.
*/
// Configure the spotbugs extension.
spotbugs {
effort = Effort.MAX
excludeFilter = file("${project.rootDir}/config/spotbugs/filter.xml")
}
// Disable spotbugs tasks to avoid build failures with incompatible JDK versions.
tasks.withType<com.github.spotbugs.snom.SpotBugsTask>().configureEach {
enabled = false
}
// We don't need to lint tests.
tasks.named("spotbugsTest") {
enabled = false
}
/*
* Repositories
* ================================
*/
repositories {
mavenLocal()
mavenCentral()
}