无法使用--module-source-path解析模块 [英] Unable to resolve module using --module-source-path

查看:433
本文介绍了无法使用--module-source-path解析模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

紧跟如何定义向未知模块的合格导出?我发布了

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

core尝试使用合格的导出将包暴露给plugin,但是编译器抱怨plugin不存在.遵循Alan Bateman的建议,我尝试将指向core--module-source-path <path-of-plugin> --module plugin指向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

为什么编译器无法找到模块plugin?

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

推荐答案

我通过反复试验弄清楚了.

I figured it out through trial and error.

  1. 使用--module-source-path ${project.basedir}/../*/src/main/java确保编译器可以看到两个模块的源代码.
  2. 使用--module core可以确保尽管看到了所有模块,编译器仍只构建core.
  3. 告诉maven-jar-pluginclasses/${module.name}而不是仅从classes打包类,因为module-source-path导致输出以模块名称作为前缀.我没有找到禁用此前缀的方法.
  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.

固定代码可以在> https://bitbucket.org/cowwoc/qualified中找到-exports-testcase/

注意事项:仅当模块目录名称(由*解析的组件)与Java模块名称匹配时,此技术才有效.在此特定示例中,模块core的源位于目录core/src/main/java中.另一方面,如果目录名称为core,但相应的Java模块为org.bitbucket.core,则编译将失败,并显示module org.bitbucket.core not found in module source path.

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.

这篇关于无法使用--module-source-path解析模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆