In a multi-project setup, to generate a Fat Jar, t...
# ktor
f
In a multi-project setup, to generate a Fat Jar, the main class in the main project is set like this:
Copy code
application {
    mainClass.set("$group.ApplicationKt")
}
But for the child sub-projects, I had to set the main class to empty:
Copy code
application {
    mainClass.set("")
}
If I don't do this, I encounter an exception when running the buildFatJar task:
Copy code
Execution failed for task ':kcrud-employment:shadowJar'.
Error while evaluating property 'mainClassName' of task ':kcrud-employment:shadowJar'.
Cannot query the value of extension 'application' property 'mainClass' because it has no value available.
Is it expected behavior to explicitly set the mainClass to empty for sub-projects? I assumed this would be implicitly detected by the Gradle task.
d
What gradle plugins do you define for your subprojects? It might be that you have them defined as application as well, which you most likely don’t want.
f
Found the issue. In the main project I have:
Copy code
plugins {
    application
    alias(libs.plugins.kotlin.jvm)
    alias(libs.plugins.ktor)
    alias(libs.plugins.kotlin.serialization)
    alias(libs.plugins.graphql.expedia)
}
And the sub-projects I had:
Copy code
plugins {
    alias(libs.plugins.kotlin.jvm)
    alias(libs.plugins.ktor)
    alias(libs.plugins.kotlin.serialization)
    alias(libs.plugins.graphql.expedia)
}
Removing
alias(libs.plugins.ktor)
in the sub-projects solves the issue. I'm a bit confused about why.