2022-07-28 16:51:36 +02:00
|
|
|
plugins {
|
2022-08-04 09:41:27 +02:00
|
|
|
id 'java'
|
2022-08-24 18:27:40 +02:00
|
|
|
id 'org.springframework.boot' version '2.7.3'
|
2022-08-09 17:51:50 +02:00
|
|
|
id 'io.openapiprocessor.openapi-processor' version '2022.2'
|
2022-08-24 18:27:40 +02:00
|
|
|
id 'io.spring.dependency-management' version '1.0.13.RELEASE'
|
2022-08-08 10:03:26 +02:00
|
|
|
id 'com.github.jk1.dependency-license-report' version '2.1'
|
2022-08-24 18:27:40 +02:00
|
|
|
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'
|
2022-08-26 16:54:46 +02:00
|
|
|
id 'info.solidsoft.pitest' version '1.9.0'
|
2022-08-24 18:27:40 +02:00
|
|
|
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'
|
|
|
|
|
2022-08-04 12:24:54 +02:00
|
|
|
wrapper {
|
|
|
|
distributionType = Wrapper.DistributionType.BIN
|
|
|
|
gradleVersion = '7.5'
|
|
|
|
}
|
|
|
|
|
2022-07-28 16:51:36 +02:00
|
|
|
configurations {
|
|
|
|
compileOnly {
|
|
|
|
extendsFrom annotationProcessor
|
|
|
|
}
|
2022-08-23 14:10:50 +02:00
|
|
|
testCompile {
|
2022-09-10 14:49:01 +02:00
|
|
|
extendsFrom testAnnotationProcessor
|
|
|
|
|
2022-08-23 14:10:50 +02:00
|
|
|
// 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()
|
|
|
|
}
|
|
|
|
|
2022-08-05 13:10:11 +02:00
|
|
|
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'
|
2022-08-24 18:27:40 +02:00
|
|
|
implementation 'org.springdoc:springdoc-openapi-ui:1.6.11'
|
2022-07-28 16:51:36 +02:00
|
|
|
implementation 'org.liquibase:liquibase-core'
|
2022-09-09 09:57:03 +02:00
|
|
|
implementation 'com.vladmihalcea:hibernate-types-55:2.19.0'
|
2022-08-09 17:51:50 +02:00
|
|
|
implementation 'org.openapitools:jackson-databind-nullable:0.2.3'
|
2022-08-08 16:54:35 +02:00
|
|
|
implementation 'org.modelmapper:modelmapper:3.1.0'
|
2022-07-28 16:51:36 +02:00
|
|
|
|
|
|
|
compileOnly 'org.projectlombok:lombok'
|
2022-09-10 14:49:01 +02:00
|
|
|
testCompileOnly 'org.projectlombok:lombok'
|
2022-07-28 16:51:36 +02:00
|
|
|
|
|
|
|
developmentOnly 'org.springframework.boot:spring-boot-devtools'
|
|
|
|
|
|
|
|
runtimeOnly 'org.postgresql:postgresql'
|
|
|
|
|
|
|
|
annotationProcessor 'org.projectlombok:lombok'
|
2022-09-10 14:49:01 +02:00
|
|
|
testAnnotationProcessor 'org.projectlombok:lombok'
|
2022-07-28 16:51:36 +02:00
|
|
|
|
|
|
|
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'
|
2022-08-09 17:51:50 +02:00
|
|
|
testImplementation 'io.rest-assured:spring-mock-mvc'
|
2022-08-26 16:06:27 +02:00
|
|
|
testImplementation 'org.hamcrest:hamcrest-core:2.2'
|
|
|
|
testImplementation 'org.pitest:pitest-junit5-plugin:1.0.0'
|
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
|
2022-08-05 13:10:11 +02:00
|
|
|
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-05 13:10:11 +02:00
|
|
|
}
|
|
|
|
|
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
|
2022-08-08 16:54:35 +02:00
|
|
|
openapiProcessor {
|
2022-09-02 13:11:15 +02:00
|
|
|
springRoot {
|
|
|
|
processorName 'spring'
|
2022-08-09 17:51:50 +02:00
|
|
|
processor 'io.openapiprocessor:openapi-processor-spring:2022.4'
|
2022-08-08 16:54:35 +02:00
|
|
|
apiPath "$projectDir/src/main/resources/api-definition.yaml"
|
|
|
|
mapping "$projectDir/src/main/resources/api-mappings.yaml"
|
2022-09-02 13:11:15 +02:00
|
|
|
targetDir "$projectDir/build/generated/sources/openapi"
|
|
|
|
showWarnings true
|
|
|
|
openApiNullable true
|
|
|
|
}
|
|
|
|
springRbac {
|
|
|
|
processorName 'spring'
|
|
|
|
processor 'io.openapiprocessor:openapi-processor-spring:2022.4'
|
|
|
|
apiPath "$projectDir/src/main/resources/api-definition/rbac/rbac.yaml"
|
|
|
|
mapping "$projectDir/src/main/resources/api-definition/rbac/api-mappings.yaml"
|
|
|
|
targetDir "$projectDir/build/generated/sources/openapi"
|
|
|
|
showWarnings true
|
|
|
|
openApiNullable true
|
|
|
|
}
|
|
|
|
springTest {
|
|
|
|
processorName 'spring'
|
|
|
|
processor 'io.openapiprocessor:openapi-processor-spring:2022.4'
|
|
|
|
apiPath "$projectDir/src/main/resources/api-definition/test/test.yaml"
|
|
|
|
mapping "$projectDir/src/main/resources/api-definition/test/api-mappings.yaml"
|
|
|
|
targetDir "$projectDir/build/generated/sources/openapi"
|
2022-08-08 16:54:35 +02:00
|
|
|
showWarnings true
|
2022-08-09 17:51:50 +02:00
|
|
|
openApiNullable true
|
2022-08-08 16:54:35 +02:00
|
|
|
}
|
2022-09-06 11:07:08 +02:00
|
|
|
springHs {
|
|
|
|
processorName 'spring'
|
|
|
|
processor 'io.openapiprocessor:openapi-processor-spring:2022.4'
|
2022-09-13 13:27:52 +02:00
|
|
|
apiPath "$projectDir/src/main/resources/api-definition/hs-office/hs-office.yaml"
|
|
|
|
mapping "$projectDir/src/main/resources/api-definition/hs-office/api-mappings.yaml"
|
2022-09-06 11:07:08 +02:00
|
|
|
targetDir "$projectDir/build/generated/sources/openapi"
|
|
|
|
showWarnings true
|
|
|
|
openApiNullable true
|
|
|
|
}
|
2022-08-08 16:54:35 +02:00
|
|
|
}
|
|
|
|
sourceSets.main.java.srcDir 'build/generated/sources/openapi'
|
2022-09-06 11:07:08 +02:00
|
|
|
abstract class ProcessSpring extends DefaultTask {}
|
|
|
|
tasks.register('processSpring', ProcessSpring)
|
|
|
|
['processSpringRoot', 'processSpringRbac', 'processSpringTest', 'processSpringHs'].each {
|
|
|
|
project.tasks.processSpring.dependsOn it
|
2022-09-02 13:11:15 +02:00
|
|
|
}
|
2022-09-06 11:07:08 +02:00
|
|
|
project.tasks.processResources.dependsOn processSpring
|
|
|
|
project.tasks.compileJava.dependsOn processSpring
|
2022-08-08 16:54:35 +02:00
|
|
|
|
2022-08-19 10:11:19 +02:00
|
|
|
// Spotless Code Formatting
|
2022-08-04 09:41:27 +02:00
|
|
|
spotless {
|
|
|
|
java {
|
2022-08-09 17:51:50 +02:00
|
|
|
// removeUnusedImports() TODO: reactivate once it can deal with multi-line-strings
|
|
|
|
indentWithSpaces(4)
|
2022-08-04 09:41:27 +02:00
|
|
|
endWithNewline()
|
|
|
|
toggleOffOn()
|
2022-08-08 16:54:35 +02:00
|
|
|
|
2022-08-09 17:51:50 +02:00
|
|
|
target fileTree(rootDir) {
|
2022-08-08 16:54:35 +02:00
|
|
|
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-09-06 11:07:49 +02:00
|
|
|
project.tasks.dependencyCheckAnalyze.doFirst { // Why not doLast? See README.md!
|
2022-09-02 08:58:15 +02:00
|
|
|
println "OWASP Dependency Security Report: file:///${project.rootDir}/build/reports/dependency-check-report.html"
|
|
|
|
}
|
|
|
|
|
2022-08-08 10:03:26 +02:00
|
|
|
|
2022-08-19 10:11:19 +02:00
|
|
|
// License Check
|
2022-08-08 10:03:26 +02:00
|
|
|
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 = [
|
2022-09-02 13:11:15 +02:00
|
|
|
'net.hostsharing.hsadminng.**.generated.**',
|
2022-08-19 10:11:19 +02:00
|
|
|
]
|
|
|
|
}
|
|
|
|
jacocoTestReport {
|
|
|
|
dependsOn test
|
|
|
|
afterEvaluate {
|
|
|
|
classDirectories.setFrom(files(classDirectories.files.collect {
|
|
|
|
fileTree(dir: it, exclude: [
|
2022-09-02 13:11:15 +02:00
|
|
|
"net/hostsharing/hsadminng/**/generated/**/*.class",
|
2022-09-13 13:27:52 +02:00
|
|
|
"net/hostsharing/hsadminng/hs/HsadminNgApplication.class"
|
2022-08-19 10:11:19 +02:00
|
|
|
])
|
|
|
|
}))
|
|
|
|
}
|
2022-09-06 11:07:49 +02:00
|
|
|
doFirst { // Why not doLast? See README.md!
|
2022-08-19 10:11:19 +02:00
|
|
|
println "HTML Jacoco Test Code Coverage Report: file://${reports.html.outputLocation.get()}/index.html"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
project.tasks.check.dependsOn(jacocoTestCoverageVerification)
|
|
|
|
jacocoTestCoverageVerification {
|
|
|
|
violationRules {
|
|
|
|
rule {
|
|
|
|
limit {
|
2022-09-26 12:40:59 +02:00
|
|
|
minimum = 0.92
|
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 = [
|
2022-09-02 13:11:15 +02:00
|
|
|
'net.hostsharing.hsadminng.**.generated.**',
|
2022-08-19 10:11:19 +02:00
|
|
|
'net.hostsharing.hsadminng.HsadminNgApplication',
|
2022-09-02 13:11:15 +02:00
|
|
|
'net.hostsharing.hsadminng.PingController',
|
2022-08-28 17:30:27 +02:00
|
|
|
'net.hostsharing.hsadminng.Mapper'
|
2022-08-19 10:11:19 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
limit {
|
|
|
|
counter = 'LINE'
|
|
|
|
value = 'COVEREDRATIO'
|
2022-09-21 09:44:25 +02:00
|
|
|
minimum = 0.98
|
2022-08-19 10:11:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
rule {
|
|
|
|
element = 'METHOD'
|
|
|
|
excludes = [
|
2022-09-02 13:11:15 +02:00
|
|
|
'net.hostsharing.hsadminng.**.generated.**',
|
2022-08-26 14:13:02 +02:00
|
|
|
'net.hostsharing.hsadminng.HsadminNgApplication.main',
|
2022-09-02 13:11:15 +02:00
|
|
|
'net.hostsharing.hsadminng.PingController.*'
|
2022-08-28 17:30:27 +02:00
|
|
|
]
|
2022-08-19 10:11:19 +02:00
|
|
|
|
|
|
|
limit {
|
|
|
|
counter = 'BRANCH'
|
|
|
|
value = 'COVEREDRATIO'
|
2022-09-21 09:44:25 +02:00
|
|
|
minimum = 1.00
|
2022-08-19 10:11:19 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-08-26 16:06:27 +02:00
|
|
|
// pitest mutation testing
|
|
|
|
pitest {
|
|
|
|
targetClasses = ['net.hostsharing.hsadminng.**']
|
|
|
|
excludedClasses = [
|
|
|
|
'net.hostsharing.hsadminng.config.**',
|
2022-09-06 11:07:08 +02:00
|
|
|
'net.hostsharing.hsadminng.**.*Controller',
|
2022-09-02 13:11:15 +02:00
|
|
|
'net.hostsharing.hsadminng.**.generated.**'
|
2022-08-26 16:06:27 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
targetTests = ['net.hostsharing.hsadminng.**.*UnitTest', 'net.hostsharing.hsadminng.**.*RestTest']
|
|
|
|
excludedTestClasses = ['**AcceptanceTest*', '**IntegrationTest*']
|
|
|
|
|
|
|
|
pitestVersion = '1.9.0'
|
|
|
|
junit5PluginVersion = '1.0.0'
|
|
|
|
|
|
|
|
threads = 4
|
|
|
|
|
|
|
|
// As Java unit tests are pretty pointless in our case, this maybe makes not much sense.
|
2022-09-06 11:07:08 +02:00
|
|
|
mutationThreshold = 71
|
|
|
|
coverageThreshold = 57
|
2022-09-30 16:27:18 +02:00
|
|
|
testStrengthThreshold = 87
|
2022-08-26 16:06:27 +02:00
|
|
|
|
|
|
|
outputFormats = ['XML', 'HTML']
|
|
|
|
timestampedReports = false
|
|
|
|
}
|
|
|
|
project.tasks.check.dependsOn(project.tasks.pitest)
|
2022-09-06 11:07:49 +02:00
|
|
|
project.tasks.pitest.doFirst { // Why not doLast? See README.md!
|
2022-08-26 16:06:27 +02:00
|
|
|
println "PiTest Mutation Report: file:///${project.rootDir}/build/reports/pitest/index.html"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-08-24 18:27:40 +02:00
|
|
|
// Dependency Versions Upgrade
|
|
|
|
useLatestVersions {
|
|
|
|
finalizedBy check
|
|
|
|
}
|