mudasar187
06/02/2023, 7:00 PMwithType<Test>().configureEach {
        useJUnitPlatform()
        testLogging {
            showExceptions = true
            showStackTraces = true
            exceptionFormat = FULL
            events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
        }
        // For å øke hastigheten på build kan vi benytte disse metodene
        maxParallelForks = Runtime.getRuntime().availableProcessors() / 2
        reports.forEach { report -> report.required.value(false) }
    }gradle.propertiesorg.gradle.parallel=true
org.gradle.caching=true
org.gradle.unsafe.configuration-cache=trueorg.gradle.parallel=truemaxParallelForks = Runtime.getRuntime().availableProcessors() / 2Adam S
06/02/2023, 7:05 PMorg.gradle.parallel=truemudasar187
06/02/2023, 7:06 PMAdam S
06/02/2023, 7:06 PMAdam S
06/02/2023, 7:08 PMmaxParallelForksmudasar187
06/02/2023, 7:09 PMmaxParallelForks = Runtime.getRuntime().availableProcessors() / 2maxParallelForks = (Runtime.getRuntime().availableProcessors() / 2).takeIf { it > 0 } ?: 1maxParallelForks = Runtime.getRuntime().availableProcessors()Adam S
06/02/2023, 7:11 PMmudasar187
06/02/2023, 7:14 PMAdam S
06/02/2023, 7:14 PMVampire
06/02/2023, 8:21 PMVampire
06/02/2023, 8:21 PMmudasar187
06/03/2023, 8:34 PMmaxParallelForksVampire
06/03/2023, 9:24 PMAdam S
06/04/2023, 8:20 AMmaxParallelForksmudasar187
06/04/2023, 8:28 AMmudasar187
06/04/2023, 8:28 AMmudasar187
06/04/2023, 8:31 AMAdam S
06/04/2023, 8:36 AM./gradlew check--no-build-cache--rerun-tasks--profile$buildDir/reports/profileAdam S
06/04/2023, 8:37 AMAdam S
06/04/2023, 8:42 AMorg.gradle.parallel=truesrc/mainmudasar187
06/04/2023, 9:28 AMBuild CacheAdam S
06/04/2023, 9:30 AMVampire
06/04/2023, 2:42 PMVampire
06/04/2023, 2:46 PM--rerun--rerun-tasksVampire
06/04/2023, 2:47 PMmudasar187
06/05/2023, 7:05 AMorg.gradle.parallel=trueVampire
06/05/2023, 7:09 AMmudasar187
06/05/2023, 7:11 AMmudasar187
06/05/2023, 7:12 AMbuild.gradle.ktsimport com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
import org.gradle.api.tasks.testing.logging.TestLogEvent
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.openapitools.generator.gradle.plugin.tasks.GenerateTask
plugins {
    kotlin("jvm") version "1.8.21"
    kotlin("plugin.serialization") version "1.8.21"
    id("org.openapi.generator") version "6.6.0"
    id("com.github.johnrengelman.shadow") version "8.1.1"
    application
}
group = "no.nav.sokos"
repositories {
    mavenCentral()
    maven { url = uri("<https://maven.pkg.jetbrains.space/public/p/ktor/eap>") }
}
val ktorVersion = "2.3.0"
val logbackVersion = "1.4.7"
val logstashVersion = "7.3"
val jacksonVersion = "2.15.1"
val prometheusVersion = "1.11.0"
val kotlinLoggingVersion = "3.0.5"
val janionVersion = "3.1.9"
val natpryceVersion = "1.6.10.0"
val kotestVersion = "5.6.2"
dependencies {
    // Ktor server
    implementation("io.ktor:ktor-server-core-jvm:$ktorVersion")
    implementation("io.ktor:ktor-server-call-logging-jvm:$ktorVersion")
    implementation("io.ktor:ktor-server-call-id-jvm:$ktorVersion")
    implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion")
    implementation("io.ktor:ktor-server-content-negotiation-jvm:$ktorVersion")
    implementation("io.ktor:ktor-server-swagger:$ktorVersion")
    // Ktor client
    implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
    implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
    implementation("io.ktor:ktor-client-apache-jvm:$ktorVersion")
    implementation("io.ktor:ktor-serialization-jackson-jvm:$ktorVersion")
    // Security
    implementation("io.ktor:ktor-server-auth-jvm:$ktorVersion")
    implementation("io.ktor:ktor-server-auth-jwt-jvm:$ktorVersion")
    // Jackson
    implementation("io.ktor:ktor-serialization-jackson:$ktorVersion")
    implementation("com.fasterxml.jackson.core:jackson-databind:$jacksonVersion")
    implementation("com.fasterxml.jackson.module:jackson-module-kotlin:$jacksonVersion")
    implementation("com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion")
    // Monitorering
    implementation("io.ktor:ktor-server-metrics-micrometer-jvm:$ktorVersion")
    implementation("io.micrometer:micrometer-registry-prometheus:$prometheusVersion")
    // Logging
    implementation("io.github.microutils:kotlin-logging-jvm:$kotlinLoggingVersion")
    runtimeOnly("org.codehaus.janino:janino:$janionVersion")
    runtimeOnly("ch.qos.logback:logback-classic:$logbackVersion")
    runtimeOnly("net.logstash.logback:logstash-logback-encoder:$logstashVersion")
    // Config
    implementation("com.natpryce:konfig:$natpryceVersion")
    // Test
    testImplementation("io.kotest:kotest-assertions-core-jvm:$kotestVersion")
    testImplementation("io.kotest:kotest-runner-junit5:$kotestVersion")
    testImplementation("io.kotest:kotest-assertions-core:$kotestVersion")
}
application {
    mainClass.set("no.nav.sokos.prosjektnavn.ApplicationKt")
}
sourceSets {
    main {
        java {
            srcDirs("$buildDir/generated/src/main/kotlin")
        }
    }
}
kotlin {
    jvmToolchain {
        languageVersion.set(JavaLanguageVersion.of(17))
    }
}
tasks {
    withType<KotlinCompile>().configureEach {
        dependsOn("openApiGenerate")
    }
    withType<GenerateTask>().configureEach {
        generatorName.set("kotlin")
        generateModelDocumentation.set(false)
        inputSpec.set("$rootDir/src/main/resources/openapi/pets.json")
        outputDir.set("$buildDir/generated")
        globalProperties.set(
            mapOf(
                "models" to ""
            )
        )
        configOptions.set(
            mapOf(
                "library" to "jvm-ktor",
                "serializationLibrary" to "jackson"
            )
        )
    }
    withType<ShadowJar>().configureEach {
        enabled = true
        archiveFileName.set("app.jar")
        manifest {
            attributes["Main-Class"] = "no.nav.sokos.prosjektnavn.ApplicationKt"
        }
    }
    ("jar") {
        enabled = false
    }
    withType<Test>().configureEach {
        testLogging {
            showExceptions = true
            showStackTraces = true
            exceptionFormat = FULL
            events = setOf(TestLogEvent.PASSED, TestLogEvent.SKIPPED, TestLogEvent.FAILED)
        }
        reports.forEach { report -> report.required.value(false) }
    }
}gradle.propertieskotlin.code.style=official
org.gradle.caching=true
# Får du en feil som henvender deg til denne
# <https://docs.gradle.org/8.0/userguide/configuration_cache.html#config_cache:requirements:disallowed_types>
# så markere du ut linjen nedenfor
org.gradle.unsafe.configuration-cache=trueVampire
06/05/2023, 7:21 AMIt does not get UP-TO-DATE and rerung the tests
UP-TO-DATEcleanWhen i change my tests i still get same resultWell, debug your tests then. Also, never trust a test you did not see fail for the correct reason.
mudasar187
06/05/2023, 7:25 AM./gradlew build shadowJarmudasar187
06/05/2023, 7:32 AMmudasar187
06/05/2023, 7:34 AMVampire
06/05/2023, 7:51 AMuseJunitPlatform()useKotest(...)mudasar187
06/05/2023, 8:21 AMuseJunitPlatform()Vampire
06/05/2023, 9:39 AMuseKotest()useJunitPlatform()useKotest()mudasar187
06/05/2023, 9:49 AMVampire
06/05/2023, 9:51 AMVampire
06/05/2023, 9:51 AMVampire
06/05/2023, 9:52 AMuseKotest()Marek Kubiczek
10/16/2024, 1:44 PMVampire
10/16/2024, 2:55 PM