mrkuz / kradle

Swiss army knife for Kotlin/JVM (and also Java) development
MIT License
83 stars 2 forks source link

Quarkus/Micronaut framework integrations #3

Open GavinRay97 opened 1 year ago

GavinRay97 commented 1 year ago

I'm a big Quarkus user/contributor so I'd love to get an integration if possible, and Micronaut would be great to have just for the popularity of kradle and to expand the userbase IMO.

I think I could potentially contribute the Quarkus plugin if needed. I was looking at the Spring Boot blueprint.

The way Quarkus works with Gradle is that it has:

A blank Quarkus Gradle Kotlin app looks like:

# Gradle properties
quarkusPluginId=io.quarkus
quarkusPluginVersion=2.14.2.Final
quarkusPlatformGroupId=io.quarkus.platform
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformVersion=2.14.2.Final
// settings.gradle.kts
pluginManagement {
    val quarkusPluginVersion: String by settings
    val quarkusPluginId: String by settings
    repositories {
        mavenCentral()
        gradlePluginPortal()
        mavenLocal()
    }
    plugins {
        id(quarkusPluginId) version quarkusPluginVersion
    }
}
rootProject.name="code-with-quarkus"
// build.gradle.kts
plugins {
    kotlin("jvm") version "1.7.20"
    kotlin("plugin.allopen") version "1.7.20"
    id("io.quarkus")
}

repositories {
    mavenCentral()
    mavenLocal()
}

val quarkusPlatformGroupId: String by project
val quarkusPlatformArtifactId: String by project
val quarkusPlatformVersion: String by project

dependencies {
    implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")

    implementation(enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}"))
    implementation("io.quarkus:quarkus-kotlin")
    implementation("io.quarkus:quarkus-arc")

    testImplementation("io.quarkus:quarkus-junit5")
    testImplementation("io.rest-assured:rest-assured")
}

tasks.withType<Test> {
    systemProperty("java.util.logging.manager", "org.jboss.logmanager.LogManager")
}
allOpen {
    annotation("javax.ws.rs.Path")
    annotation("javax.enterprise.context.ApplicationScoped")
    annotation("io.quarkus.test.junit.QuarkusTest")
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> {
    kotlinOptions.jvmTarget = JavaVersion.VERSION_17.toString()
    kotlinOptions.javaParameters = true
}
mrkuz commented 1 year ago

Thanks for Quarkus example and the insights.

I like the idea of bringing more frameworks to kradle, but don't know when I'll find time to actually start working on the topic.

GavinRay97 commented 1 year ago

No problem, as long as there aren't any tricky bits/gotchas to be aware of I can probably contribute the Quarkus implementation using the Spring one as a reference implementation

Micronaut, I have only a little experience with (and it's less of a personal usecase/priority)

Btw, I posted kradle on Java subreddit and it got a lot of positive attention 25,000 views and a silver award =) Thought you might like to know

image