hs.hsadmin.ng/build.gradle

219 lines
6.4 KiB
Groovy
Raw Normal View History

2022-07-28 16:51:36 +02:00
plugins {
2022-08-04 09:41:27 +02:00
id 'java'
id 'org.springframework.boot' version '2.7.3'
id 'io.openapiprocessor.openapi-processor' version '2022.2'
id 'io.spring.dependency-management' version '1.0.13.RELEASE'
id 'com.github.jk1.dependency-license-report' version '2.1'
id "org.owasp.dependencycheck" version "7.1.2"
id "com.diffplug.spotless" version "6.10.0"
2022-08-19 10:11:19 +02:00
id 'jacoco'
id 'se.patrikerdes.use-latest-versions' version '0.2.18'
id 'com.github.ben-manes.versions' version '0.42.0'
2022-07-28 16:51:36 +02:00
}
group = 'net.hostsharing'
version = '0.0.1-SNAPSHOT'
wrapper {
distributionType = Wrapper.DistributionType.BIN
gradleVersion = '7.5'
}
2022-07-28 16:51:36 +02:00
configurations {
compileOnly {
extendsFrom annotationProcessor
}
testCompile {
// Only JUNit 5 (Jupiter) should be used at compile time.
// For runtime it's still needed by testcontainers, though.
exclude group: 'junit', module: 'junit'
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
2022-07-28 16:51:36 +02:00
}
repositories {
mavenCentral()
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}
2022-07-28 16:51:36 +02:00
ext {
set('testcontainersVersion', "1.17.3")
}
2022-08-04 09:41:27 +02:00
// wrapper
2022-07-28 16:51:36 +02:00
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-data-rest'
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springdoc:springdoc-openapi-ui:1.6.11'
2022-07-28 16:51:36 +02:00
implementation 'org.liquibase:liquibase-core'
implementation 'com.vladmihalcea:hibernate-types-55:2.18.0'
implementation 'org.openapitools:jackson-databind-nullable:0.2.3'
implementation 'org.modelmapper:modelmapper:3.1.0'
2022-07-28 16:51:36 +02:00
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
runtimeOnly 'org.postgresql:postgresql'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.testcontainers:testcontainers'
testImplementation 'org.testcontainers:junit-jupiter'
testImplementation 'org.testcontainers:postgresql'
2022-08-02 15:17:24 +02:00
testImplementation 'com.tngtech.archunit:archunit-junit5:1.0.0-rc1'
testImplementation 'io.rest-assured:spring-mock-mvc'
2022-07-28 16:51:36 +02:00
}
dependencyManagement {
imports {
mavenBom "org.testcontainers:testcontainers-bom:${testcontainersVersion}"
}
}
2022-08-19 10:11:19 +02:00
// Java Compiler Options
tasks.withType(JavaCompile) {
2022-08-19 10:11:19 +02:00
options.compilerArgs += [
"-parameters" // keep parameter names => no need for @Param for SpringData
]
}
2022-08-19 10:11:19 +02:00
// Use JUnit Jupiter
2022-07-28 16:51:36 +02:00
tasks.named('test') {
useJUnitPlatform()
}
2022-08-04 09:41:27 +02:00
2022-08-19 10:11:19 +02:00
// OpenAPI Source Code Generation
openapiProcessor {
spring {
processor 'io.openapiprocessor:openapi-processor-spring:2022.4'
apiPath "$projectDir/src/main/resources/api-definition.yaml"
targetDir "$projectDir/build/generated/sources/openapi"
mapping "$projectDir/src/main/resources/api-mappings.yaml"
showWarnings true
openApiNullable true
}
}
sourceSets.main.java.srcDir 'build/generated/sources/openapi'
project.tasks.processResources.dependsOn('processSpring')
project.tasks.compileJava.dependsOn('processSpring')
2022-08-19 10:11:19 +02:00
// Spotless Code Formatting
2022-08-04 09:41:27 +02:00
spotless {
java {
// removeUnusedImports() TODO: reactivate once it can deal with multi-line-strings
indentWithSpaces(4)
2022-08-04 09:41:27 +02:00
endWithNewline()
toggleOffOn()
target fileTree(rootDir) {
include '**/*.java'
exclude '**/generated/**/*.java'
}
2022-08-04 09:41:27 +02:00
}
}
2022-08-04 12:26:41 +02:00
project.tasks.check.dependsOn(spotlessCheck)
2022-08-19 10:11:19 +02:00
// OWASP Dependency Security Test
2022-08-04 12:26:41 +02:00
dependencyCheck {
cveValidForHours=4
format = 'ALL'
suppressionFile = 'etc/owasp-dependency-check-suppression.xml'
failOnError = true
failBuildOnCVSS = 7
}
project.tasks.check.dependsOn(dependencyCheckAnalyze)
2022-08-19 10:11:19 +02:00
// License Check
licenseReport {
excludeBoms = true
allowedLicensesFile = new File("$projectDir/etc/allowed-licenses.json")
}
project.tasks.check.dependsOn(checkLicense)
2022-08-19 10:11:19 +02:00
// JaCoCo Test Code Coverage
jacoco {
toolVersion = "0.8.8"
}
test {
finalizedBy jacocoTestReport // generate report after tests
excludes = [
'net.hostsharing.hsadminng.generated.**',
]
}
jacocoTestReport {
dependsOn test
afterEvaluate {
classDirectories.setFrom(files(classDirectories.files.collect {
fileTree(dir: it, exclude: [
"net/hostsharing/hsadminng/generated/**/*.class",
2022-08-25 17:27:17 +02:00
"net/hostsharing/hsadminng/TestController.class",
"net/hostsharing/hsadminng/hs/hscustomer/HsadminNgApplication.class"
2022-08-19 10:11:19 +02:00
])
}))
}
doLast {
println "HTML Jacoco Test Code Coverage Report: file://${reports.html.outputLocation.get()}/index.html"
}
}
project.tasks.check.dependsOn(jacocoTestCoverageVerification)
jacocoTestCoverageVerification {
violationRules {
rule {
excludes = ['net.hostsharing.hsadminng.generated.**']
limit {
2022-08-25 17:27:17 +02:00
minimum = 0.8 // TODO: increase to 0.9
2022-08-19 10:11:19 +02:00
}
}
// element: PACKAGE, BUNDLE, CLASS, SOURCEFILE or METHOD
// counter: INSTRUCTION, BRANCH, LINE, COMPLEXITY, METHOD, or CLASS
// value: TOTALCOUNT, COVEREDCOUNT, MISSEDCOUNT, COVEREDRATIO or MISSEDRATIO
rule {
element = 'CLASS'
excludes = [
'net.hostsharing.hsadminng.generated.**',
'net.hostsharing.hsadminng.HsadminNgApplication',
'net.hostsharing.hsadminng.TestController',
// TODO: improve test code coverage:
2022-08-25 17:27:17 +02:00
'net.hostsharing.hsadminng.Mapper',
2022-08-19 10:11:19 +02:00
]
limit {
counter = 'LINE'
value = 'COVEREDRATIO'
2022-08-25 17:27:17 +02:00
minimum = 0.95
2022-08-19 10:11:19 +02:00
}
}
rule {
element = 'METHOD'
excludes = [
'net.hostsharing.hsadminng.generated.**',
'net.hostsharing.hsadminng.HsadminNgApplication.*',
2022-08-25 17:27:17 +02:00
'net.hostsharing.hsadminng.TestController.*']
2022-08-19 10:11:19 +02:00
limit {
counter = 'BRANCH'
value = 'COVEREDRATIO'
minimum = 0.5 // TODO: increase test code coverage
}
}
}
}
// Dependency Versions Upgrade
useLatestVersions {
finalizedBy check
}