Skip to content

Commit

Permalink
gradle 8
Browse files Browse the repository at this point in the history
  • Loading branch information
baev committed Jan 29, 2024
1 parent f97bb81 commit c42635f
Show file tree
Hide file tree
Showing 7 changed files with 224 additions and 130 deletions.
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
71 changes: 54 additions & 17 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,7 +148,7 @@ 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")
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
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 c42635f

Please sign in to comment.