# smart-doc-gradle-plugin-demo **Repository Path**: smart-doc-team/smart-doc-gradle-plugin-demo ## Basic Information - **Project Name**: smart-doc-gradle-plugin-demo - **Description**: smart-doc-gradle-plugin集成demo - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 1 - **Created**: 2020-10-24 - **Last Updated**: 2023-07-22 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README smart-doc-gradle-plugin在gradle多模块中的应用 # 一、简介 在单模块和多模块项目中使用`smart-doc-gradle-plugin`是不一样的。 对于单模块项目直接在项目的`build.gradle`中添加`smart-doc`的`gradle`和配置即可。 而对于多模块则,你需要将`smart-doc`的`gradle`插件添加在根`build.gradle`配置文件中。 然后在需要生成文档的模块中添加smart-doc所需要的json配置文件。 # 二、构建实战 以本demo为例。`demo-web-admin`的api依赖了model类模块`core`。因此我们配置好后只能用 gradle的多模块构建命令在生成文档,就不要想着在IDEA上去点了,如果你们是成熟的团队, 文档生成的步骤直接放在CI的工具上去自动完成,这样smart-doc-gradle插件才能自动去加载core模块的源码。 我们使用命令操作看看结果 ``` gradle :demo-web-admin:smartDocRestHtml ``` 构建后插件输出可重要的信息 ``` Smart-doc Starting Create API Documentation. The loaded local code path is D:\workstation\iflytek-git\smart-doc-gradle-plugin-demo\demo-web-admin\src\main\java The loaded local code path is D:\workstation\iflytek-git\smart-doc-gradle-plugin-demo\core\src/main/java API Documentation output to D:\workstation\iflytek-git\smart-doc-gradle-plugin-demo\demo-web-admin/src/main/resources/static/doc ``` - The loaded local code path is: 插件打印了自己加载了本项目的那些模块的源代码进去辅助文档生成。 我们都知道smart-doc是利用源码来分析的,如果你在构建自己的项目时smart-doc-gradle插件没有打印你想要加载的源码, 那么说明的使用方式是存在问题的。 # 三、总结 多模块请按照官方的操作来,请不要自己胡乱搞,项目模块之间额依赖要符合gradle的要求, smart-doc-gradle插件是没法通过gradle的api顺藤摸瓜找到模块间的依赖源码。