Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
Adding BOM and buildSrc (#119)
Browse files Browse the repository at this point in the history
* Added BOM and buildSrc

* Upgraded Gradle to 8.4

* Added tests

* Added toml and other dependencies to the BOM

* Updated dependencies

* Updated pg-index-health version
  • Loading branch information
mfvanek committed Nov 18, 2023
1 parent 1255fa6 commit c76573f
Show file tree
Hide file tree
Showing 18 changed files with 413 additions and 226 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/.idea/
/.gradle/
**/.gradle/
**/build/
158 changes: 6 additions & 152 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,164 +1,25 @@
import com.github.benmanes.gradle.versions.updates.DependencyUpdatesTask
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
import net.ltgt.gradle.errorprone.errorprone
import org.sonarqube.gradle.SonarTask

plugins {
id("java")
id("jacoco")
id("com.github.spotbugs") version "5.2.1"
id("checkstyle")
id("pmd")
id("org.sonarqube") version "4.4.1.3373"
id("net.ltgt.errorprone") version "3.1.0"
id("com.github.ben-manes.versions") version "0.49.0"
id("org.sonarqube")
id("com.github.ben-manes.versions") version "0.50.0"
}

description = "pg-index-health-test-starter build"

allprojects {
group = "io.github.mfvanek"
version = "0.10.1-SNAPSHOT"
version = "0.10.1"

repositories {
mavenLocal()
mavenCentral()
}
}

subprojects {
apply(plugin = "java")
apply(plugin = "org.sonarqube")
apply(plugin = "checkstyle")
apply(plugin = "pmd")
apply(plugin = "com.github.spotbugs")
apply(plugin = "jacoco")
apply(plugin = "net.ltgt.errorprone")

dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.1"))

checkstyle("com.thomasjensen.checkstyle.addons:checkstyle-addons:7.0.1")
errorprone("com.google.errorprone:error_prone_core:2.23.0")
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
withJavadocJar()
withSourcesJar()
}
tasks.withType<JavaCompile>().configureEach {
options.errorprone {
disableWarningsInGeneratedCode.set(true)
}
}

tasks {
test {
useJUnitPlatform()
dependsOn(checkstyleMain, checkstyleTest, pmdMain, pmdTest, spotbugsMain, spotbugsTest)
finalizedBy(jacocoTestReport, jacocoTestCoverageVerification)
}

jar {
manifest {
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
}
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}

javadoc {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}

jacocoTestReport {
dependsOn(test)
reports {
xml.required.set(true)
html.required.set(true)
}
}

jacocoTestCoverageVerification {
dependsOn(jacocoTestReport)
violationRules {
rule {
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "METHOD"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "LINE"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
minimum = "1.0".toBigDecimal()
}
}
}
}

check {
dependsOn(jacocoTestCoverageVerification)
}

withType<SonarTask>().configureEach {
dependsOn(test, jacocoTestReport)
}
}

jacoco {
toolVersion = rootProject.libs.versions.jacoco.get()
}

checkstyle {
toolVersion = rootProject.libs.versions.checkstyle.get()
configFile = file("../config/checkstyle/checkstyle.xml")
isIgnoreFailures = false
maxWarnings = 0
maxErrors = 0
}

pmd {
toolVersion = rootProject.libs.versions.pmd.get()
isConsoleOutput = true
ruleSetFiles = files("../config/pmd/pmd.xml")
ruleSets = listOf()
}

spotbugs {
showProgress.set(true)
effort.set(Effort.MAX)
reportLevel.set(Confidence.LOW)
excludeFilter.set(file("../config/spotbugs/exclude.xml"))
}
tasks.withType<SpotBugsTask>().configureEach {
reports {
create("xml") { enabled = true }
create("html") { enabled = true }
}
tasks {
wrapper {
gradleVersion = "8.4"
}
}

Expand Down Expand Up @@ -186,10 +47,3 @@ tasks.named<DependencyUpdatesTask>("dependencyUpdates").configure {
isNonStable(candidate.version)
}
}

// To avoid creation of jar's in build folder in the root
tasks {
jar {
isEnabled = false
}
}
24 changes: 24 additions & 0 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
plugins {
`kotlin-dsl`
}

repositories {
gradlePluginPortal()
}

dependencies {
implementation("com.github.spotbugs.snom:spotbugs-gradle-plugin:5.2.3")
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:4.4.1.3373")
implementation("net.ltgt.gradle:gradle-errorprone-plugin:3.1.0")

testImplementation(platform(libs.junit.bom))
testImplementation("org.junit.jupiter:junit-jupiter-api")

testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
}

tasks {
test {
useJUnitPlatform()
}
}
9 changes: 9 additions & 0 deletions buildSrc/settings.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
rootProject.name = "pg-index-health-test-starter-conventions"

dependencyResolutionManagement {
versionCatalogs {
create("libs") {
from(files("../gradle/libs.versions.toml"))
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import com.github.spotbugs.snom.Confidence
import com.github.spotbugs.snom.Effort
import com.github.spotbugs.snom.SpotBugsTask
import net.ltgt.gradle.errorprone.errorprone
import org.sonarqube.gradle.SonarTask

plugins {
id("java")
id("jacoco")
id("com.github.spotbugs")
id("checkstyle")
id("pmd")
id("org.sonarqube")
id("net.ltgt.errorprone")
}

dependencies {
testImplementation(platform("org.junit:junit-bom:5.10.1"))

checkstyle("com.thomasjensen.checkstyle.addons:checkstyle-addons:7.0.1")
errorprone("com.google.errorprone:error_prone_core:2.23.0")
}

java {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
tasks.withType<JavaCompile>().configureEach {
options.errorprone {
disableWarningsInGeneratedCode.set(true)
}
}

tasks {
test {
useJUnitPlatform()
dependsOn(checkstyleMain, checkstyleTest, pmdMain, pmdTest, spotbugsMain, spotbugsTest)
finalizedBy(jacocoTestReport, jacocoTestCoverageVerification)
}

jar {
manifest {
attributes["Implementation-Title"] = project.name
attributes["Implementation-Version"] = project.version
}
isPreserveFileTimestamps = false
isReproducibleFileOrder = true
}

javadoc {
if (JavaVersion.current().isJava9Compatible) {
(options as StandardJavadocDocletOptions).addBooleanOption("html5", true)
}
}

jacocoTestReport {
dependsOn(test)
reports {
xml.required.set(true)
html.required.set(true)
}
}

jacocoTestCoverageVerification {
dependsOn(jacocoTestReport)
violationRules {
rule {
limit {
counter = "CLASS"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "METHOD"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "LINE"
value = "MISSEDCOUNT"
maximum = "0.0".toBigDecimal()
}
}
rule {
limit {
counter = "INSTRUCTION"
value = "COVEREDRATIO"
minimum = "1.0".toBigDecimal()
}
}
}
}

check {
dependsOn(jacocoTestCoverageVerification)
}

withType<SonarTask>().configureEach {
dependsOn(test, jacocoTestReport)
}
}

jacoco {
toolVersion = "0.8.11"
}

checkstyle {
toolVersion = "10.12.5"
configFile = file("../config/checkstyle/checkstyle.xml")
isIgnoreFailures = false
maxWarnings = 0
maxErrors = 0
}

pmd {
toolVersion = "6.55.0"
isConsoleOutput = true
ruleSetFiles = files("../config/pmd/pmd.xml")
ruleSets = listOf()
}

spotbugs {
showProgress.set(true)
effort.set(Effort.MAX)
reportLevel.set(Confidence.LOW)
excludeFilter.set(file("../config/spotbugs/exclude.xml"))
}
tasks.withType<SpotBugsTask>().configureEach {
reports {
create("xml") { enabled = true }
create("html") { enabled = true }
}
}

0 comments on commit c76573f

Please sign in to comment.