Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] 多模块项目,配置文件是否存在覆盖关系 #1028

Open
Autoloop opened this issue Sep 6, 2023 · 3 comments
Open

[Question] 多模块项目,配置文件是否存在覆盖关系 #1028

Autoloop opened this issue Sep 6, 2023 · 3 comments
Labels
type: question&discussion Further information is requested wontfix This will not be worked on

Comments

@Autoloop
Copy link

Autoloop commented Sep 6, 2023

项目背景:
多模块项目,在项目的根目录下面,存在一个配置文件 .easy.api.config 我用来配置公共属性,和默认值
模块内部,会在模块的根目录下面,存在一个配置文件 .easy.api.config 用来配置个性化的属性,比如说归属到的module,和folder

插件版本:2.5.4.191.0

以下是几种尝试过的配置:
一、

  1. 根目录下面 存在 如下配置
    module.name=A
    folder.name=defaultFolderName
    2)模块内部存在配置:
    module.name=A
    folder.name=realFolder

二、

  1. 根目录下面 存在 如下配置
    module.name=A
    folder.name=defaultFolderName
    2)模块内部存在配置:
    module.name=B
    folder.name=#folder

三、

  1. 根目录下面 存在 如下配置
    module.name=A
    folder.name=defaultFolderName
    2)模块内部存在配置:
    module.name=B
    [email protected]#value

在上述几种情况下,只有方案一,模块内部能够读取到正确的 module.name 跟 folder.name,其他两种都不行

对于其余没有覆盖的到的属性,读取值是正常的

@Autoloop Autoloop added the type: question&discussion Further information is requested label Sep 6, 2023
@Autoloop
Copy link
Author

Autoloop commented Sep 6, 2023

不知道是存在,只有字啊常量之间才有覆盖关系,我看文档里面没有相关说明

@tangcent
Copy link
Owner

tangcent commented Sep 6, 2023

不知道是存在,只有字啊常量之间才有覆盖关系,我看文档里面没有相关说明

没有覆盖关系,但有加载执行顺序。所以逻辑上部分规则可能表现得像覆盖关系。
可以看ClassExportRuleKeys中规则声明的mode。
如果一个规则类型为StringRuleMode.SINGLE的,又配置了多条,那第一个返回非空值的那一条生效后,就不执行其他条了。
module.namefolder.name都是这样的规则。

在上述几种情况下,只有方案一,模块内部能够读取到正确的 module.name 跟 folder.name,其他两种都不行
对于其余没有覆盖的到的属性,读取值是正常的

你可以加一些日志,比如这样:

module.name=groovy:logger.info("1")
module.name=A
folder.name=groovy:logger.info("2")
folder.name=defaultFolderName

也可以这样:

module.name=groovy:```
    logger.info("1")
    return "a"
```
folder.name=groovy:```
    logger.info("2")
    return "defaultFolderName"
```

Copy link

stale bot commented Dec 15, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix This will not be worked on label Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question&discussion Further information is requested wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants