title: Run tests for library project with different dependency sets
body: <p>Environment:</p>
  
  <ul>
  <li>Java 8</li>
  <li>Gradle 4</li>
  <li>JUnit 5</li>
  </ul>
  
  <p>I have a library project that supports multiple setups / optional dependencies.</p>
  
  <p>The library always requires Spring Boot + grpc-java.
  However the user of the lib can decide whether he wants to use either netty or netty-shaded.
  And finally the lib adds additional features if Spring-Security and/or Spring-Cloud are present.</p>
  
  <p>I have a set of tests that runs with the default setup (netty + Spring-Security).
  How do I test that I can also use all features from the library with the other setup combinations, without copying my tests multiple times?</p>
  
  <p>(During the last update I used a class from the wrong lib in one of the library classes and thus the library didn't work correctly if the optional dependency was missing. Now I want to prevent similar issues in the future)</p>
  
  <p><strong>Possible solutions</strong></p>
  
  <ul>
  <li>Create a test lib project that contains the test code and create multiple test projects that execute the tests from that lib.</li>
  </ul>
  
  <p>Not all tests work for all setups. (A security test will obviously fail if no security lib is present).
  Unfortunately the number of test projects can easily explode. Currently ~8 projects are needed to test all possible combinations. If I add another optional dependency (which I consider to do) this will increase to 16.
  If there is nothing easier way, I probably use this one.</p>
  
  <ul>
  <li>Copy the dependencies to a specific folder and use some code to add them to the classloader dynamically.</li>
  </ul>
  
  <p>This requires extra coding and some bad classloader magic and possibly a forked test execution mode, that does not execute the tests in parallel (because they might have to bind a port)</p>
  
  <p><strong>TLDR:</strong> Is there an easy way to run JUnit 5 Tests with different dependency sets using gradle?</p>