I've seen these:
Gradle - Exclude file from being packaged with jar
Exclude one class file in gradle Android Studio
and am wondering what path or name I should use with exclude
. This is in a gradle.kts file:
group = "kaldrn.core"
jar {
exclude("kaldrn/CliKt.class")
}
That's my best guess, since it's the filepath in the jar. I've also tried using the source file, which doesn't work. I've tried using just basenames without path, no luck. The significance of the group
declaration in this context, if any, is lost on me (I was never a big java user pre kotlin).
The class is defined in cli.kt
, in package kaldrn
.
How do I determine what to use here?
Perhaps ironically the path above turns out to be the correct one -- see my comments on the accepted answer about a very nasty caveat that affects gradle and jar { exclude ...}
, at least for version 6.7.
The exclude path should contain the full path to the target file from the source route (eg, from main
).
In your case:
jar {
exclude("kaldrn/cli/CliKt.class")
}
If you are unsure in the path, look for your file under build/classes/kotlin/main