dnault / therapi-runtime-javadoc

Read Javadoc comments at run time.
Apache License 2.0
117 stars 19 forks source link

多模块项目中,最底层模块引入依赖后父模块无法读取注释 #78

Closed 48038411 closed 2 months ago

48038411 commented 3 months ago

项目结构:module/common api 我在common模块引入了0.15.0版本的

com.github.therapi
        <artifactId>therapi-runtime-javadoc-scribe</artifactId>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.github.therapi</groupId>
        <artifactId>therapi-runtime-javadoc</artifactId>
    </dependency>

common模块对应的类编译后都生成了_Javadoc.json文件,但是引入common模块的api未生成

48038411 commented 3 months ago
com.github.therapi therapi-runtime-javadoc-scribe 子模块引入的时候去掉了scope作用域就可以了
dnault commented 2 months ago

Please forgive me; I cannot read or write Chinese, so I used Google Translate to read your message and to translate this response.

If you declare the therapi-runtime-javadoc-scribe dependency without the provided scoope, this library will be a transitive dependency of your project. That may be fine if you are building a standalone app, but if you are building a library for other developers to use, they might not want to include therapi-runtime-javadoc-scribe in their project. That's why it's recommended to use provided scope.

Alternatively, I think with modern versions of Maven it might be better to configure the compiler plugin to use the annotation processor library using the "annotationProcessorPaths" option, instead of including it as a normal project dependency. The Maven compiler plugin documentation has an example of this here:

https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#optional-parameters


请原谅我,我不会读写中文,所以我用谷歌翻译来阅读您的消息并翻译这个回复。

如果您在声明therapi-runtime-javadoc-scribe依赖项时没有使用provided作用域,这个库将成为您项目的传递依赖。如果您正在构建一个独立的应用程序,这可能没问题,但如果您正在构建供其他开发人员使用的库,他们可能不希望在他们的项目中包含therapi-runtime-javadoc-scribe。这就是为什么建议使用provided作用域。

另外,我认为使用现代版本的Maven,通过配置编译器插件使用“annotationProcessorPaths”选项来使用注解处理器库可能更好,而不是将其作为普通的项目依赖包含进来。Maven编译器插件的文档在这里有一个示例:

https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#optional-parameters

48038411 commented 2 months ago

Please forgive me; I cannot read or write Chinese, so I used Google Translate to read your message and to translate this response.

If you declare the therapi-runtime-javadoc-scribe dependency without the provided scoope, this library will be a transitive dependency of your project. That may be fine if you are building a standalone app, but if you are building a library for other developers to use, they might not want to include therapi-runtime-javadoc-scribe in their project. That's why it's recommended to use provided scope.

Alternatively, I think with modern versions of Maven it might be better to configure the compiler plugin to use the annotation processor library using the "annotationProcessorPaths" option, instead of including it as a normal project dependency. The Maven compiler plugin documentation has an example of this here:

https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#optional-parameters

请原谅我,我不会读写中文,所以我用谷歌翻译来阅读您的消息并翻译这个回复。

如果您在声明therapi-runtime-javadoc-scribe依赖项时没有使用provided作用域,这个库将成为您项目的传递依赖。如果您正在构建一个独立的应用程序,这可能没问题,但如果您正在构建供其他开发人员使用的库,他们可能不希望在他们的项目中包含therapi-runtime-javadoc-scribe。这就是为什么建议使用provided作用域。

另外,我认为使用现代版本的Maven,通过配置编译器插件使用“annotationProcessorPaths”选项来使用注解处理器库可能更好,而不是将其作为普通的项目依赖包含进来。Maven编译器插件的文档在这里有一个示例:

https://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html#optional-parameters

I'm sorry for not paying attention to the author's nationality and communicating with you in Chinese. According to your suggestion, I defined in the parent module

org.apache.maven.plugins maven-compiler-plugin 3.8.1 21 21 org.projectlombok lombok ${lombok.version} com.github.therapi therapi-runtime-javadoc-scribe ${javadoc.version}

The problem was solved. Lombok was introduced because my project is also using lombok. If it is not configured, an error will be reported. Thank you very much for your answer!