Skip to content

Commit

Permalink
Merge pull request #59 from Rancho-7/master
Browse files Browse the repository at this point in the history
Support for JMeter test script
  • Loading branch information
shalousun authored Dec 10, 2023
2 parents 02fbdc0 + e6910b6 commit 255c02a
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,7 @@
- 更新日期:2020-10-12
- 更新内容:
1. 此版本优化了插件源码加载逻辑,提升用户体验

- 更新日期:2023-12-6
- 更新内容:
1. 支持JMeter测试脚本生成
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 @@ -33,6 +33,8 @@ public interface MojoConstants {

String MARKDOWN_MOJO = "markdown";

String JMETER_MOJO = "jmeter";

String OPENAPI_MOJO = "openapi";

String SWAGGER_MOJO = "swagger";
Expand Down
52 changes: 52 additions & 0 deletions src/main/java/com/ly/doc/plugin/mojo/JMeterMojo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.JMeterBuilder;
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;

/**
* @author Lansg
*/
@Execute(phase = LifecyclePhase.COMPILE)
@Mojo(name = MojoConstants.JMETER_MOJO, requiresDependencyResolution = ResolutionScope.COMPILE)
public class JMeterMojo extends BaseDocsGeneratorMojo {

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

0 comments on commit 255c02a

Please sign in to comment.