jooby
jooby copied to clipboard
OpenAPI generation issue in multimodule project
Task to generate openAPI falls with Application class not found. Did you forget to set `mainClassName`?
But this code works if you pull it into a single-module project.
jooby = 3.1.2 kotlin = 2.0.0
plugins {
application
alias(libs.plugins.jvm)
alias(libs.plugins.kapt)
alias(libs.plugins.jooby)
alias(libs.plugins.dependency.management)
alias(libs.plugins.jooby.openAPI)
id("com.google.osdetector") version "1.7.3"
id("com.github.johnrengelman.shadow") version "8.1.1"
}
group "com.example.app.server.backend"
version = "1.0-SNAPSHOT"
val mainAppClassName = "com.example.app.server.backend.MainKt"
application {
mainClass = mainAppClassName
}
dependencies {
testImplementation(kotlin("test"))
implementation(project(":api:meta"))
implementation(platform(libs.jooby.bom))
implementation(libs.bundles.jooby.bom)
implementation(libs.swagger.annotations)
kapt("io.jooby:jooby-apt:3.1.2")
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("io.jooby:jooby-test")
testImplementation("com.squareup.okhttp3:okhttp:4.12.0")
}
tasks.test {
useJUnitPlatform()
}
kotlin {
jvmToolchain(17)
compilerOptions {
javaParameters = true
}
}
tasks {
kapt {
arguments {
arg("jooby.incremental", true)
arg("jooby.services", true)
arg("jooby.debug", false)
}
}
test {
useJUnitPlatform()
}
shadowJar {
mergeServiceFiles()
dependsOn("openAPI")
}
joobyRun {
mainClass = mainAppClassName
restartExtensions = listOf("conf", "properties", "class")
compileExtensions = listOf("java", "kt")
port = 8080
dependsOn("openAPI")
}
}
did you try to run from parent/main module?
did you try to run from parent/main module?
Yes. I moved it to the top of the hierarchy. Set application.mainClass on top of it. Nothing works.
- I create project by cli and include it but same problem.
- Put classname in ext of project and application.
- Put classname in *.properties.
I tried all possible solutions to specify the main class name.
Looks like problem is in multi module system itself.
@IzzzGoy can you share a gradle multiproject example?