I am using gradle to build some a uber jar file, this jar file has dependencies and I used this guide to create the task that I can run
My task is like this btw I am using kotlin
tasks.register<Jar>("uberJar") {
archiveClassifier.set("uber")
from(sourceSets.main.get().output)
duplicatesStrategy = DuplicatesStrategy.EXCLUDE;
dependsOn(configurations.runtimeClasspath)
from({
configurations.runtimeClasspath.get().filter { it.name.endsWith("jar") }.map { zipTree(it) }
}})
What can I add to this task to add my .java files as well.
Also I don't really understand much of what is going on here like what actually is SourceSets?
CodePudding user response:
Try adding this to your build.gradle.kts
and see if it works:
tasks.named<ProcessResources>("processResources") {
from("src/main/java")
}
When your uber-JAR builds, it should contain the source files. Though this will also add the source files to any JAR. If that is not what you want, then you will need to configure something similar in the uber-JAR setup.