From 790b6349079bccb392a616715b465911c8922c8e Mon Sep 17 00:00:00 2001 From: chenqi <1535985458@qq.com> Date: Thu, 14 Dec 2023 08:55:07 +0800 Subject: [PATCH] feat: add word rest mojo --- .../ly/doc/plugin/constant/MojoConstants.java | 2 + .../com/ly/doc/plugin/mojo/WordRestMojo.java | 54 +++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 src/main/java/com/ly/doc/plugin/mojo/WordRestMojo.java diff --git a/src/main/java/com/ly/doc/plugin/constant/MojoConstants.java b/src/main/java/com/ly/doc/plugin/constant/MojoConstants.java index 888845c..8dfc78f 100644 --- a/src/main/java/com/ly/doc/plugin/constant/MojoConstants.java +++ b/src/main/java/com/ly/doc/plugin/constant/MojoConstants.java @@ -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"; } diff --git a/src/main/java/com/ly/doc/plugin/mojo/WordRestMojo.java b/src/main/java/com/ly/doc/plugin/mojo/WordRestMojo.java new file mode 100644 index 0000000..954be50 --- /dev/null +++ b/src/main/java/com/ly/doc/plugin/mojo/WordRestMojo.java @@ -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()); + } + } + } +}