Skip to content

Commit

Permalink
Merge pull request #52 from Fioooooooo/master
Browse files Browse the repository at this point in the history
基于 git 管理的增量文档构建
  • Loading branch information
shalousun authored Nov 19, 2023
2 parents 1831fda + 1b9e36e commit 02fbdc0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public abstract class BaseDocsGeneratorMojo extends AbstractMojo {
private Set includes;
@Parameter(property = "skip")
private String skip;
@Parameter(property = "increment", defaultValue = "false")
private boolean increment;
@Parameter(defaultValue = "${mojoExecution}")
private MojoExecution mojoEx;
private DependencyNode rootNode;
Expand All @@ -133,7 +135,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
this.getLog().info("Smart-doc Start preparing sources at: " + DateTimeUtil.nowStrTime());
projectArtifacts = project.getArtifacts().stream().map(moduleName -> moduleName.getGroupId() + ":" + moduleName.getArtifactId())
.collect(Collectors.toList());
ApiConfig apiConfig = MojoUtils.buildConfig(configFile, projectName, project, projectBuilder, session, projectArtifacts, getLog());
ApiConfig apiConfig = MojoUtils.buildConfig(configFile, projectName, project, projectBuilder, session, projectArtifacts, increment, getLog());
if (Objects.isNull(apiConfig)) {
this.getLog().info(GlobalConstants.ERROR_MSG);
return;
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/com/ly/doc/plugin/util/MojoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,13 @@ public boolean shouldSkipClass(Class<?> aClass) {
* @param projectBuilder ProjectBuilder
* @param mavenSession maven session
* @param projectArtifacts project artifacts
* @param increment whether incrementally build the doc
* @param log maven plugin log
* @return com.power.doc.model.ApiConfig
* @return com.ly.doc.model.ApiConfig
* @throws MojoExecutionException MojoExecutionException
*/
public static ApiConfig buildConfig(File configFile, String projectName, MavenProject project, ProjectBuilder projectBuilder
, MavenSession mavenSession, List<String> projectArtifacts, Log log) throws MojoExecutionException {
, MavenSession mavenSession, List<String> projectArtifacts, boolean increment, Log log) throws MojoExecutionException {
try {
ClassLoader classLoader = ClassLoaderUtil.getRuntimeClassLoader(project);
String data = FileUtil.getFileContent(new FileInputStream(configFile));
Expand Down Expand Up @@ -122,6 +123,9 @@ public static ApiConfig buildConfig(File configFile, String projectName, MavenPr
requestBodyAdvice.setWrapperClass(getClassByClassName(requestBodyAdvice.getClassName(), classLoader));
}

apiConfig.setIncrement(increment);
apiConfig.setBaseDir(project.getBasedir().getAbsolutePath());

if (StringUtil.isEmpty(apiConfig.getProjectName()) && StringUtil.isEmpty(projectName)) {
apiConfig.setProjectName(project.getName());
} else if (StringUtil.isNotEmpty(apiConfig.getProjectName())
Expand Down Expand Up @@ -287,7 +291,7 @@ private static File getRootPath(MavenProject project, Log log) {
if (log.isDebugEnabled()) {
log.debug(project.getName() + " parent is: " + mavenProject.getName());
}
if (Objects.nonNull(mavenProject)) {
if (null != mavenProject) {
if (mavenProject.getBasedir() == null) {
return project.getBasedir();
} else {
Expand Down

0 comments on commit 02fbdc0

Please sign in to comment.