How to work with resources in Java 9 modules

前端 未结 1 1288
小鲜肉
小鲜肉 2021-01-20 21:32

I built a small (hello world style) java 9 project using gradle and the jigsaw plugin.

For a junit test I tried to access some file as a resource, but classLoa

1条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 22:20

    This appears to be a Gradle bug.

    When I run Gradle with the -i option, I see that the actual command it’s executing to run your program includes this:

    --patch-module resourceTest=/home/vgr/src/java_9_resource_test/build/classes/java/test
    

    As you can see, it’s including the build/classes directory, but not the build/resources directory.

    Since the build places the classes and resources in separate places, there is no way to use --patch-module. The classes and resources must be together, in one file tree or one .jar file.

    Whether this is a flaw in the org.gradle.java.experimental-jigsaw plugin, or Gradle itself, I’m not sure.

    0 讨论(0)
提交回复
热议问题