How to include test classes in shadowJar?

I am using the shadow Gradle plugin to build a JAR containing all the jars mentioned inside.

In mine build.gradle, I only have

apply plugin: "com.github.johnrengelman.shadow"

and

jar {
    manifest {
        attributes 'Main-Class': 'MYCLASS'
    }

}

related to this. I don’t know how he knows what to build, but it works.

Now, is it possible to include test classes?

+4
source share
1 answer

From the official documentation https://imperceptibleblyts.com/shadow/custom-tasks/

Shading Sources and Test Dependencies

import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar task testJar(type: ShadowJar) { classifier = 'tests' from sourceSets.test.output configurations = [project.configurations.testRuntime] }

JAR , , , testRuntime. build/libs / --tests.jar.

+1

Source: https://habr.com/ru/post/1662454/


All Articles