0%
September 12, 2024

Customization on build.gradle.kts

gradle

kotlin

bootRun with Custom Active Profiles

tasks.register("bootRun-UAT-James-LocalDB-JamesStripe") {
    group = "application"
    description = "bootRun with James self-localhosted-DB and James Stripe Account"

    doFirst {
        tasks.bootRun.configure {
            args("--spring.profiles.active=uat,james_db_and_james_stripe")
        }
    }
    finalizedBy("bootRun")
}

Result:

Known Issue. If we run debugger using a custom task, the process will not be killed by ending the debug process.

Set MainClass for boorJar Created jar file

tasks.getByName<Jar>("jar") {
    manifest {
        attributes["Main-Class"] = "com.billie.payment.PaymentApplicationKt"
    }
}

Skip Running Tests

tasks.named<Test>("test") {
    enabled = false
}

Skip Compiling Test Files, i.e., Skip compileTestKotlin

tasks.named<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>("compileTestKotlin") {
    enabled = false
}

Customize the Jar Name for bootRun

tasks.bootJar {
    archiveFileName.set("application.jar")
}