How to create a secondary Jar file?

How to setup the Gradle jar plugin so that running the build generates two jars? I’ve tried the following based on some articles and old questions on this forum but no luck.

task otherJar(type: Jar) {
    from sourceSets.main.groovy

The reason i’m trying to do this is that i’m trying to import module A into module B in test scope. The module A is a spring boot project so that class files in the, executable spring boot based, jar file are organized differently. So when the module B imports module A as a test dependency, it not able to detect the class files from module A jar file.