Skip to content

Commit

Permalink
Merge pull request #60 from chenqi146/master
Browse files Browse the repository at this point in the history
feat: add word rest mojo
  • Loading branch information
shalousun authored Dec 17, 2023
2 parents 255c02a + 790b634 commit 71fd097
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/com/ly/doc/plugin/constant/MojoConstants.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,4 +50,6 @@ public interface MojoConstants {
String TORNA_REST_MOJO = "torna-rest";

String TORNA_RPC_MOJO = "torna-rpc";

String WORD_REST_MOJO = "word-rest";
}
54 changes: 54 additions & 0 deletions src/main/java/com/ly/doc/plugin/mojo/WordRestMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* smart-doc
*
* Copyright (C) 2018-2023 smart-doc
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package com.ly.doc.plugin.mojo;

import com.ly.doc.builder.WordDocBuilder;
import com.ly.doc.model.ApiConfig;
import com.ly.doc.plugin.constant.MojoConstants;
import com.thoughtworks.qdox.JavaProjectBuilder;
import org.apache.maven.plugins.annotations.Execute;
import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.ResolutionScope;

/**
* Send API documents to Word
*
* @author cqmike
*/
@Execute(phase = LifecyclePhase.COMPILE)
@Mojo(name = MojoConstants.WORD_REST_MOJO, requiresDependencyResolution = ResolutionScope.COMPILE)
public class WordRestMojo extends BaseDocsGeneratorMojo {

@Override
public void executeMojo(ApiConfig apiConfig, JavaProjectBuilder javaProjectBuilder) {
try {
WordDocBuilder.buildApiDoc(apiConfig, javaProjectBuilder);
} catch (Throwable e) {
getLog().error(e);
if (apiConfig.isStrict()) {
throw new RuntimeException(e.getMessage());
}
}
}
}

0 comments on commit 71fd097

Please sign in to comment.