I have proj2 depending on proj1. proj2 also requires proj1 for test sources because the test classes in proj2 depending on test classes in proj1. I am trying to get this to work using composite build functionality without success.
* What went wrong:
Could not resolve all dependencies for configuration ':testCompileClasspath'.
> Could not find proj1-testArtifacts.jar (app1:proj1:unspecified).
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
Whilst not an answer to your question, it’s worth noting that nebula have deprecated their nebula.test-jar plugin for the following reason
We will be removing this functionality in the next major release. We feel it is better to create a project for any shared test harnesses than to try and create an extra jar out of the test classes.
test of proj2 should not depend on test of proj1. test of proj1 should only contain tests for proj1, not for proj2.
IF you have code like test fixtures, base classes, utilities, and so on, you should use the java-test-fixtures plugin which defines a test fixtures source set where you are meant to put test code that should also be shared with other projects.
Of course you could expose the test source set in the same manner like that plugin does for the testFixtures source set, just look at its sources, but it would be cleaner to not mix the responsibilities.