META-INF/services in JAR with Gradle

后端 未结 5 1873
予麋鹿
予麋鹿 2020-12-14 07:06

I wanted to build a plugin module that can be loaded with a ServiceLoader. This requires adding a file to the META-INF/services directory, that is named after t

5条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 07:48

    You place META-INF/services/org.example.plugins.PluginService in src/main/java, but it's not a source, it's a resource file, therefore it should be placed in resources folder according to Maven directory layout convention, that is

    src/main/resources/META-INF/services/org.example.plugins.PluginService
    

    In this case everything should work out of the box.

提交回复
热议问题