I have an app which uses ServiceLoader.
There is one service interface MyFancyService and its implementations: AppClassA, AppClassB and test implementations: TestClassC, TestClassD
There is META-INF.services in the app package and another META-INF.services in test package.
META-INF.services in app point to provider classes AppClassA and AppClassB
META-INF.services in test point to provider classes TestClassC and TestClassD
While running the app, ServiceLoader.load(MyFancyService.class))
loads only AppClassA
, AppClassB
. Obviously there are no test classes in the classpath and that's why. I understand that and it's desirable
While running tests, ServiceLoader.load(MyFancyService.java)) loads all the classes AppClassA, AppClassB, TestClassC, TestClassD.
Is there a way to limit service loader to only load TestClassC
, TestClassD
while running tests ?