Java - ServiceLoader - Intellij cannot find implementation class files

2k Views Asked by At

Intro

I am trying to create multiple services which fuzz the input (for testing purposes. I am using the concept of dependency injection using java.util.ServiceLoader<T> feature. I am using IntelliJ for this project.

Github Project Link: https://github.com/ghoshabhi/java-service-loader

Problem

I have created a META-INF/services directory with one file within it: htmlfuzzing.spi.HtmlFuzzer mentioning the path to my implementation class (htmlfuzzing.TagReplacer). I was trying to create a structure similar to an example on Oracle's website.

I also went ahead and marked the META-INF directory as resources by going to Project Settings > Modules :

enter image description here

Here's what my output directory looks like:

enter image description here

As you can see above, the implementation class' class files are not added to the out/ directory.

Here's my complete directory structure:

enter image description here

Question

I am obviously doing something wrong here, but I am not able to understand what. What is the correct way of adding or marking the META-INF directory as the resources or what is the correct way to include all the service implementation classes?

Any help or hint towards solving this is appreciated.

EDIT - 1

Added src/resource folder and placed the META-INF directory within it. But I still don't see the implementation class' class files in the out directory.

Also, one thing I have noticed is as soon as I mark any directory as resource in the project structure - it vanishes from the project view pan on the left. Anything odd there?

enter image description here

0

There are 0 best solutions below