Skip to content

Commit

Permalink
gradle 8 (via #996)
Browse files Browse the repository at this point in the history
  • Loading branch information
baev committed Jan 30, 2024
1 parent f97bb81 commit 2ba9ee9
Show file tree
Hide file tree
Showing 12 changed files with 234 additions and 138 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public void clear() {
/**
* Thread local context that stores information about not finished tests and steps.
*/
private static class Context extends InheritableThreadLocal<LinkedList<String>> {
private static final class Context extends InheritableThreadLocal<LinkedList<String>> {

@Override
public LinkedList<String> initialValue() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
/**
* @author charlie (Dmitry Baev).
*/
@SuppressWarnings("PMD.NonSerializableClass")
public class AllureJooq implements ExecuteListener {

private static final String STEP_UUID
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@ private String getOrCreateTest(final TestIdentifier testIdentifier) {
return tests.get().getOrCreate(testIdentifier);
}

private static class Uuids {
private static final class Uuids {

private final Map<TestIdentifier, String> storage = new ConcurrentHashMap<>();
private final ReadWriteLock lock = new ReentrantReadWriteLock();
Expand Down
2 changes: 1 addition & 1 deletion allure-scalatest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if (hasProperty("scalaVersion")) {
}

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

for (sv in availableScalaVersions) {
val taskSuffix = sv.replace('.', '_')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public void visit(final ASTNode[] nodes, final SourceUnit sourceUnit) {
/**
* Use of nested class defers linking until after groovy version check.
*/
private static class Impl {
private static final class Impl {
private static final AstNodeCache NODE_CACHE = new AstNodeCache();

private void visit(final SourceUnit sourceUnit) {
Expand Down Expand Up @@ -100,7 +100,7 @@ private void processSpec(final SourceUnit sourceUnit,
/**
* Adds Allure steps for statements with labels.
*/
private static class MethodVisitor implements GroovyClassVisitor {
private static final class MethodVisitor implements GroovyClassVisitor {

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

Expand Down
75 changes: 56 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
import com.github.spotbugs.snom.SpotBugsTask

val gradleScriptDir by extra("${rootProject.projectDir}/gradle")
val qualityConfigsDir by extra("$gradleScriptDir/quality-configs")
val spotlessDtr by extra("$qualityConfigsDir/spotless")

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

tasks.withType(Wrapper::class) {
gradleVersion = "7.5.1"
gradleVersion = "8.5"
}

plugins {
java
`java-library`
`maven-publish`
signing
checkstyle
pmd
id("com.github.spotbugs")
id("com.diffplug.spotless")
id("io.github.gradle-nexus.publish-plugin")
id("io.qameta.allure-adapter") apply false
id("io.qameta.allure-report")
id("io.spring.dependency-management")
id("ru.vyarus.quality")
}

java {
Expand Down Expand Up @@ -125,13 +129,15 @@ configure(subprojects) {

configure(libs) {
val project = this
apply(plugin = "checkstyle")
apply(plugin = "pmd")
apply(plugin = "com.github.spotbugs")
apply(plugin = "com.diffplug.spotless")
apply(plugin = "io.qameta.allure-report")
apply(plugin = "io.qameta.allure-adapter")
apply(plugin = "io.spring.dependency-management")
apply(plugin = "java")
apply(plugin = "java-library")
apply(plugin = "ru.vyarus.quality")

val orgSlf4jVersion = "1.7.36"
val assertJVersion = "1.9.9.1"
Expand All @@ -142,17 +148,17 @@ configure(libs) {
mavenBom("org.junit:junit-bom:5.9.2")
}
dependencies {
dependency("com.github.spotbugs:spotbugs:4.7.3")
dependency("com.github.spotbugs:spotbugs:4.8.3")
dependency("com.github.tomakehurst:wiremock:2.27.2")
dependency("com.google.inject:guice:5.1.0")
dependency("com.google.testing.compile:compile-testing:0.19")
dependency("com.puppycrawl.tools:checkstyle:9.3")
dependency("com.puppycrawl.tools:checkstyle:10.13.0")
dependency("com.squareup.retrofit2:retrofit:2.9.0")
dependency("commons-io:commons-io:2.11.0")
dependency("io.github.benas:random-beans:3.9.0")
dependency("io.github.glytching:junit-extensions:2.6.0")
dependency("javax.annotation:javax.annotation-api:1.3.2")
dependency("net.sourceforge.pmd:pmd-java:6.46.0")
dependency("net.sourceforge.pmd:pmd-java:6.55.0")
dependency("org.apache.commons:commons-lang3:3.12.0")
dependency("org.apache.httpcomponents:httpclient:4.5.13")
dependency("org.apache.httpcomponents.client5:httpclient5:5.2.1")
Expand Down Expand Up @@ -260,16 +266,24 @@ configure(libs) {
}
}

quality {
configDir = qualityConfigsDir
checkstyleVersion = dependencyManagement.managedVersions["com.puppycrawl.tools:checkstyle"]
pmdVersion = dependencyManagement.managedVersions["net.sourceforge.pmd:pmd-java"]
spotbugsVersion = dependencyManagement.managedVersions["com.github.spotbugs:spotbugs"]
spotbugs = true
pmd = true
checkstyle = true
htmlReports = false
enabled = !project.hasProperty("disableQuality")
val enableQuality = true
fun excludeGeneratedSources(source: FileTree): FileTree = (source - fileTree("build/generated-sources")).asFileTree

checkstyle {
toolVersion = dependencyManagement.managedVersions["com.puppycrawl.tools:checkstyle"]!!
configDirectory = rootProject.layout.projectDirectory.dir("gradle/quality-configs/checkstyle")
}

pmd {
toolVersion = dependencyManagement.managedVersions["net.sourceforge.pmd:pmd-java"]!!
ruleSets = listOf()
ruleSetFiles = rootProject.files("gradle/quality-configs/pmd/pmd.xml")
}

spotbugs {
toolVersion = dependencyManagement.managedVersions["com.github.spotbugs:spotbugs"]!!
excludeFilter = rootProject.file("gradle/quality-configs/spotbugs/exclude.xml")

afterEvaluate {
val spotbugs = configurations.findByName("spotbugs")
if (spotbugs != null) {
Expand All @@ -281,27 +295,50 @@ configure(libs) {
}
}

tasks.withType(Checkstyle::class) {
source = excludeGeneratedSources(source)
enabled = enableQuality
}

tasks.withType(Pmd::class) {
source = excludeGeneratedSources(source)
enabled = enableQuality
}

tasks.withType(SpotBugsTask::class) {
enabled = enableQuality
}

tasks.checkstyleTest {
enabled = false
}

tasks.pmdTest {
enabled = false
}

tasks.spotbugsTest {
enabled = false
}

spotless {
java {
target("src/**/*.java")
removeUnusedImports()
@Suppress("INACCESSIBLE_TYPE")
licenseHeaderFile("$spotlessDtr/header.java", "(package|import|open|module|//startfile)")
endWithNewline()
replaceRegex("one blank line after package line", "(package .+;)\n+import", "$1\n\nimport")
replaceRegex("one blank line after import lists", "(import .+;\n\n)\n+", "$1")
}
scala {
target("src/**/*.scala")
@Suppress("INACCESSIBLE_TYPE")
licenseHeaderFile("$spotlessDtr/header.java", "(package|//startfile)")
endWithNewline()
replaceRegex("one blank line after package line", "(package .+;)\n+import", "$1\n\nimport")
replaceRegex("one blank line after import lists", "(import .+;\n\n)\n+", "$1")
}
groovy {
target("src/**/*.groovy")
@Suppress("INACCESSIBLE_TYPE")
licenseHeaderFile("$spotlessDtr/header.java", "(package|//startfile) ")
endWithNewline()
replaceRegex("one blank line after package line", "(package .+;)\n+import", "$1\n\nimport")
Expand Down
5 changes: 3 additions & 2 deletions gradle/quality-configs/pmd/pmd.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
<rule ref="category/java/errorprone.xml">
<exclude name="AvoidAccessibilityAlteration"/> <!-- earlier j2ee group-->
<exclude name="AvoidCatchingThrowable"/>
<exclude name="BeanMembersShouldSerialize"/>
<exclude name="AvoidFieldNameMatchingMethodName"/>
<exclude name="DataflowAnomalyAnalysis"/>
<exclude name="EmptyFinalizer"/>
<exclude name="FinalizeDoesNotCallSuperFinalize"/>
Expand All @@ -123,6 +123,7 @@
<exclude name="NullAssignment"/> <!-- disabled due to false positive for initialization with ternary operator -->
<exclude name="OverrideBothEqualsAndHashcode"/> <!-- duplicated by EqualsHashCode rule in Checkstyle -->
<exclude name="StaticEJBFieldShouldBeFinal"/> <!-- earlier j2ee group-->
<exclude name="TestClassWithoutTestCases"/>
<exclude name="UseCorrectExceptionLogging"/>
<exclude name="UseLocaleWithCaseConversions"/>
<exclude name="UseProperClassLoader"/> <!-- earlier j2ee group-->
Expand All @@ -134,7 +135,7 @@
</rule>
<rule ref="category/java/errorprone.xml/CloseResource">
<properties>
<property name="types" value="java.sql.Connection,java.sql.Statement,java.sql.ResultSet" />
<property name="types" value="java.sql.Connection,java.sql.Statement,java.sql.ResultSet"/>
</properties>
</rule>

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 2ba9ee9

Please sign in to comment.