Skip to content

Commit 2ba9ee9

Browse files
authored
gradle 8 (via #996)
1 parent f97bb81 commit 2ba9ee9

File tree

12 files changed

+234
-138
lines changed

12 files changed

+234
-138
lines changed

allure-java-commons/src/main/java/io/qameta/allure/internal/AllureThreadContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public void clear() {
7979
/**
8080
* Thread local context that stores information about not finished tests and steps.
8181
*/
82-
private static class Context extends InheritableThreadLocal<LinkedList<String>> {
82+
private static final class Context extends InheritableThreadLocal<LinkedList<String>> {
8383

8484
@Override
8585
public LinkedList<String> initialValue() {

allure-jooq/src/main/java/io/qameta/allure/jooq/AllureJooq.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
/**
3535
* @author charlie (Dmitry Baev).
3636
*/
37+
@SuppressWarnings("PMD.NonSerializableClass")
3738
public class AllureJooq implements ExecuteListener {
3839

3940
private static final String STEP_UUID

allure-junit-platform/src/main/java/io/qameta/allure/junitplatform/AllureJunitPlatform.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ private String getOrCreateTest(final TestIdentifier testIdentifier) {
730730
return tests.get().getOrCreate(testIdentifier);
731731
}
732732

733-
private static class Uuids {
733+
private static final class Uuids {
734734

735735
private final Map<TestIdentifier, String> storage = new ConcurrentHashMap<>();
736736
private final ReadWriteLock lock = new ReentrantReadWriteLock();

allure-scalatest/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ if (hasProperty("scalaVersion")) {
2222
}
2323

2424
val baseScalaVersion = selectedScalaVersion.substring(0, selectedScalaVersion.lastIndexOf("."))
25-
project.base.archivesBaseName = "allure-scalatest_$baseScalaVersion"
25+
project.base.archivesName.set("allure-scalatest_$baseScalaVersion")
2626

2727
for (sv in availableScalaVersions) {
2828
val taskSuffix = sv.replace('.', '_')

allure-spock2/src/main/java/io/qameta/allure/spock2/compiler/AllureStatementsLabelsToStepsTransformation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void visit(final ASTNode[] nodes, final SourceUnit sourceUnit) {
5959
/**
6060
* Use of nested class defers linking until after groovy version check.
6161
*/
62-
private static class Impl {
62+
private static final class Impl {
6363
private static final AstNodeCache NODE_CACHE = new AstNodeCache();
6464

6565
private void visit(final SourceUnit sourceUnit) {
@@ -100,7 +100,7 @@ private void processSpec(final SourceUnit sourceUnit,
100100
/**
101101
* Adds Allure steps for statements with labels.
102102
*/
103-
private static class MethodVisitor implements GroovyClassVisitor {
103+
private static final class MethodVisitor implements GroovyClassVisitor {
104104

105105
private static final ClassNode ALLURE = ClassHelper.makeWithoutCaching(Allure.class);
106106

build.gradle.kts

Lines changed: 56 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
1+
import com.github.spotbugs.snom.SpotBugsTask
2+
13
val gradleScriptDir by extra("${rootProject.projectDir}/gradle")
24
val qualityConfigsDir by extra("$gradleScriptDir/quality-configs")
35
val spotlessDtr by extra("$qualityConfigsDir/spotless")
46

57
val libs = subprojects.filterNot { it.name in "allure-bom" }
68

79
tasks.withType(Wrapper::class) {
8-
gradleVersion = "7.5.1"
10+
gradleVersion = "8.5"
911
}
1012

1113
plugins {
1214
java
1315
`java-library`
1416
`maven-publish`
1517
signing
18+
checkstyle
19+
pmd
20+
id("com.github.spotbugs")
1621
id("com.diffplug.spotless")
1722
id("io.github.gradle-nexus.publish-plugin")
1823
id("io.qameta.allure-adapter") apply false
1924
id("io.qameta.allure-report")
2025
id("io.spring.dependency-management")
21-
id("ru.vyarus.quality")
2226
}
2327

2428
java {
@@ -125,13 +129,15 @@ configure(subprojects) {
125129

126130
configure(libs) {
127131
val project = this
132+
apply(plugin = "checkstyle")
133+
apply(plugin = "pmd")
134+
apply(plugin = "com.github.spotbugs")
128135
apply(plugin = "com.diffplug.spotless")
129136
apply(plugin = "io.qameta.allure-report")
130137
apply(plugin = "io.qameta.allure-adapter")
131138
apply(plugin = "io.spring.dependency-management")
132139
apply(plugin = "java")
133140
apply(plugin = "java-library")
134-
apply(plugin = "ru.vyarus.quality")
135141

136142
val orgSlf4jVersion = "1.7.36"
137143
val assertJVersion = "1.9.9.1"
@@ -142,17 +148,17 @@ configure(libs) {
142148
mavenBom("org.junit:junit-bom:5.9.2")
143149
}
144150
dependencies {
145-
dependency("com.github.spotbugs:spotbugs:4.7.3")
151+
dependency("com.github.spotbugs:spotbugs:4.8.3")
146152
dependency("com.github.tomakehurst:wiremock:2.27.2")
147153
dependency("com.google.inject:guice:5.1.0")
148154
dependency("com.google.testing.compile:compile-testing:0.19")
149-
dependency("com.puppycrawl.tools:checkstyle:9.3")
155+
dependency("com.puppycrawl.tools:checkstyle:10.13.0")
150156
dependency("com.squareup.retrofit2:retrofit:2.9.0")
151157
dependency("commons-io:commons-io:2.11.0")
152158
dependency("io.github.benas:random-beans:3.9.0")
153159
dependency("io.github.glytching:junit-extensions:2.6.0")
154160
dependency("javax.annotation:javax.annotation-api:1.3.2")
155-
dependency("net.sourceforge.pmd:pmd-java:6.46.0")
161+
dependency("net.sourceforge.pmd:pmd-java:6.55.0")
156162
dependency("org.apache.commons:commons-lang3:3.12.0")
157163
dependency("org.apache.httpcomponents:httpclient:4.5.13")
158164
dependency("org.apache.httpcomponents.client5:httpclient5:5.2.1")
@@ -260,16 +266,24 @@ configure(libs) {
260266
}
261267
}
262268

263-
quality {
264-
configDir = qualityConfigsDir
265-
checkstyleVersion = dependencyManagement.managedVersions["com.puppycrawl.tools:checkstyle"]
266-
pmdVersion = dependencyManagement.managedVersions["net.sourceforge.pmd:pmd-java"]
267-
spotbugsVersion = dependencyManagement.managedVersions["com.github.spotbugs:spotbugs"]
268-
spotbugs = true
269-
pmd = true
270-
checkstyle = true
271-
htmlReports = false
272-
enabled = !project.hasProperty("disableQuality")
269+
val enableQuality = true
270+
fun excludeGeneratedSources(source: FileTree): FileTree = (source - fileTree("build/generated-sources")).asFileTree
271+
272+
checkstyle {
273+
toolVersion = dependencyManagement.managedVersions["com.puppycrawl.tools:checkstyle"]!!
274+
configDirectory = rootProject.layout.projectDirectory.dir("gradle/quality-configs/checkstyle")
275+
}
276+
277+
pmd {
278+
toolVersion = dependencyManagement.managedVersions["net.sourceforge.pmd:pmd-java"]!!
279+
ruleSets = listOf()
280+
ruleSetFiles = rootProject.files("gradle/quality-configs/pmd/pmd.xml")
281+
}
282+
283+
spotbugs {
284+
toolVersion = dependencyManagement.managedVersions["com.github.spotbugs:spotbugs"]!!
285+
excludeFilter = rootProject.file("gradle/quality-configs/spotbugs/exclude.xml")
286+
273287
afterEvaluate {
274288
val spotbugs = configurations.findByName("spotbugs")
275289
if (spotbugs != null) {
@@ -281,27 +295,50 @@ configure(libs) {
281295
}
282296
}
283297

298+
tasks.withType(Checkstyle::class) {
299+
source = excludeGeneratedSources(source)
300+
enabled = enableQuality
301+
}
302+
303+
tasks.withType(Pmd::class) {
304+
source = excludeGeneratedSources(source)
305+
enabled = enableQuality
306+
}
307+
308+
tasks.withType(SpotBugsTask::class) {
309+
enabled = enableQuality
310+
}
311+
312+
tasks.checkstyleTest {
313+
enabled = false
314+
}
315+
316+
tasks.pmdTest {
317+
enabled = false
318+
}
319+
320+
tasks.spotbugsTest {
321+
enabled = false
322+
}
323+
284324
spotless {
285325
java {
286326
target("src/**/*.java")
287327
removeUnusedImports()
288-
@Suppress("INACCESSIBLE_TYPE")
289328
licenseHeaderFile("$spotlessDtr/header.java", "(package|import|open|module|//startfile)")
290329
endWithNewline()
291330
replaceRegex("one blank line after package line", "(package .+;)\n+import", "$1\n\nimport")
292331
replaceRegex("one blank line after import lists", "(import .+;\n\n)\n+", "$1")
293332
}
294333
scala {
295334
target("src/**/*.scala")
296-
@Suppress("INACCESSIBLE_TYPE")
297335
licenseHeaderFile("$spotlessDtr/header.java", "(package|//startfile)")
298336
endWithNewline()
299337
replaceRegex("one blank line after package line", "(package .+;)\n+import", "$1\n\nimport")
300338
replaceRegex("one blank line after import lists", "(import .+;\n\n)\n+", "$1")
301339
}
302340
groovy {
303341
target("src/**/*.groovy")
304-
@Suppress("INACCESSIBLE_TYPE")
305342
licenseHeaderFile("$spotlessDtr/header.java", "(package|//startfile) ")
306343
endWithNewline()
307344
replaceRegex("one blank line after package line", "(package .+;)\n+import", "$1\n\nimport")

gradle/quality-configs/pmd/pmd.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@
111111
<rule ref="category/java/errorprone.xml">
112112
<exclude name="AvoidAccessibilityAlteration"/> <!-- earlier j2ee group-->
113113
<exclude name="AvoidCatchingThrowable"/>
114-
<exclude name="BeanMembersShouldSerialize"/>
114+
<exclude name="AvoidFieldNameMatchingMethodName"/>
115115
<exclude name="DataflowAnomalyAnalysis"/>
116116
<exclude name="EmptyFinalizer"/>
117117
<exclude name="FinalizeDoesNotCallSuperFinalize"/>
@@ -123,6 +123,7 @@
123123
<exclude name="NullAssignment"/> <!-- disabled due to false positive for initialization with ternary operator -->
124124
<exclude name="OverrideBothEqualsAndHashcode"/> <!-- duplicated by EqualsHashCode rule in Checkstyle -->
125125
<exclude name="StaticEJBFieldShouldBeFinal"/> <!-- earlier j2ee group-->
126+
<exclude name="TestClassWithoutTestCases"/>
126127
<exclude name="UseCorrectExceptionLogging"/>
127128
<exclude name="UseLocaleWithCaseConversions"/>
128129
<exclude name="UseProperClassLoader"/> <!-- earlier j2ee group-->
@@ -134,7 +135,7 @@
134135
</rule>
135136
<rule ref="category/java/errorprone.xml/CloseResource">
136137
<properties>
137-
<property name="types" value="java.sql.Connection,java.sql.Statement,java.sql.ResultSet" />
138+
<property name="types" value="java.sql.Connection,java.sql.Statement,java.sql.ResultSet"/>
138139
</properties>
139140
</rule>
140141

gradle/wrapper/gradle-wrapper.jar

1.19 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)