How can I read setup resources from plugin jar?

Notice the path of the resource that displays in the error message. It references your JAR file with an exclamation mark at the end, followed by the file name in the JAR.

This is the location of your rule file found by the getResource(…) call. However, this is not a valid path for a File. You cannot treat a file inside of a JAR file (compressed archive) as a normal file.

You have several options here, one of which includes the incubating addition to the code quality extensions where you can specify a config rather than a file. You can either access the resource as a stream, read it in to a String and use resources.text.fromString(...) or you could try out resources.text.fromArchiveEntry(...), but you need to split out the archive name from the file name when you pass the arguments.

Alternatively, you could always extract the file from the jar so that you do have a normal file on disk to reference.

2 Likes