How to share java class output from one subproject with another


I am trying to share a java class output from a subproject which is compiled from src/main to another subproject and access it in it’s src/test. I read the gradle docs (Sharing outputs between projects) and can’t seem to get it working and it seems to only work for jars?

Can anyone help?

“Sharing outputs between projects” should not really apply here.
You just declare a dependency from one subproject to the other and it will work.
If something is not working as expected, you should probably share an MCVE of what you try.

This works, but only in src/main. Not in src/test

Still, can you share an MCVE to make it clear what you mean?