I am trying to develop a bamboo task for one of my project. The purpose of this jar is to parse the working directory and create a JSON output. For this purpose, I have also developed a java library which will take the working directory as input and provide a parsed output in JSON. Now, this java library uses java's ServiceLoader to load some dependent service classes. Independently, this library works as expected and loads all the dependencies and does its work. However, on using this library as a third party lib in the plugin, the library is not loading the dependent classes. In some post i saw the loading classes in atlassian sdk is triky. Please advise what I am doing wrong or missing.
the pom at the pluging:
<dependency>
<groupId>com.abd.plug</groupId>
<artifactId>buildInspLib</artifactId>
<version>1</version>
<scope>compile</scope>
</dependency>
The dependencies which would be loaded by serviceLoader at the pom at the buildIspLib:
<dependency>
<groupId>com.abd.parser</groupId>
<artifactId>parser1</artifactId>
<version>1</version>
</dependency>
<dependency>
<groupId>com.abd.parser</groupId>
<artifactId>parser2</artifactId>
<version>1</version>
</dependency>
The code to load the service implementations. the buildInspLib has the META-INF directory which has the file with the implementing classes in it. Please note, this library works as expected if run outside of the atlassian sdk
//loads all the classes implementing ParserService
ServiceLoader<ParserService> loader = ServiceLoader.load(ParserService.class);
ExecutorService exec = Executors.newCachedThreadPool();
List<Future<ComputedData>> analysersOutput = new ArrayList<>();
System.out.println(" before distribution.."); //THIS LINE GETS PRINTED IN THE PLUGIN
for (ParserService serv : loader) {
try {
System.out.println(" distributing for : "+serv.getAnalyserType()+" );
//THIS LINE NEVER GETS PRINTED IN THE PLUGIN
....
...
How am I using this thirdparty lib?
new ParserInspector().inspect(taskContext.getWorkingDirectory().getAbsolutePath())
Please note: the library is being loaded. I can say that because, i could see the logs being printed. However, the service loader is not able to find the implementation classes