Unable to resolve module using --module-source-path

只愿长相守 提交于 2019-12-02 09:42:25

问题


Following up on How to define qualified exports to unknown modules? I've posted a testcase with two modules: core and plugin.

core tries to expose a package to plugin using qualified exports but the compiler complains that plugin does not exist. Following up on Alan Bateman's recommendation, I tried adding --module-source-path <path-of-plugin> --module plugin pointing from core to plugin but the compiler complains:

module plugin not found in source path

Why isn't the compiler able to find module plugin?


回答1:


I figured it out through trial and error.

  1. Use --module-source-path ${project.basedir}/../*/src/main/java to make sure the compiler can see the source-code of both modules.
  2. Use --module core to make sure that the compiler only builds core in spite of seeing all modules.
  3. Tell maven-jar-plugin to package classes from classes/${module.name} instead of just classes because module-source-path causes the output to be prefixed by the module name. I have not found a way to disable this prefix.

The fixed code can be found at https://bitbucket.org/cowwoc/qualified-exports-testcase/

Caveat: This technique only works if the module directory name (the component resolved by *) matches the Java module name. In this particular example the module core had its sources in directory core/src/main/java. If, on the other hand, the directory name was core but the corresponding Java module was org.bitbucket.core then the compilation would fail with module org.bitbucket.core not found in module source path.



来源:https://stackoverflow.com/questions/53712924/unable-to-resolve-module-using-module-source-path

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!