Cross-subproject dependency on JavaCompile task outputs

If you really want to add the single files, iirc you have to iterate through the files and add each as single artifact or something like that. You could probably look at the java-library plugin that adds the classes secondary variant.

Other than that, you could add the jar as artifact to your configuration and then unpack them on the consumer side if you need them unpacked.

You can also have a look at the java-test-fixtures plugin and add a feature variant like it does it for your use-case.