I am using shadow Gradle plugin to build JAR, containing all referenced jars inside.
In my build.gradle
I have only
apply plugin: "com.github.johnrengelman.shadow"
and
jar {
manifest {
attributes 'Main-Class': 'MYCLASS'
}
}
related to that. I don't know, how it knows, what to build, but it works.
Now, is it possible, to include test classes too?
From the official documentation https://imperceptiblethoughts.com/shadow/custom-tasks/
Shadowing Test Sources and Dependencies
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar task testJar(type: ShadowJar) { classifier = 'tests' from sourceSets.test.output configurations = [project.configurations.testRuntime] }
The code snippet above will geneated a shadowed JAR contain both the main and test sources as well as all runtime and testRuntime dependencies. The file is output to build/libs/--tests.jar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With