【问题标题】:Maven configuration in gradlegradle 中的 Maven 配置
【发布时间】:2016-01-03 06:33:19
【问题描述】:

我想在 gradle 中指定以下 maven 插件。如何在gradle中指定配置?

<build>
<plugins>
    <plugin>
        <groupId>com.github.kongchen</groupId>
        <artifactId>swagger-maven-plugin</artifactId>
        <version>${swagger-maven-plugin-version}</version>
        <configuration>
            <apiSources>
                <apiSource>
                   test
                </apiSource>
            </apiSources>
        </configuration>
    </plugin>
</plugins>

【问题讨论】:

标签: maven gradle maven-2


【解决方案1】:

一般来说,在 Gradle 中“按原样”使用 Maven 插件是不可能的。 Maven 插件在内部依赖于一些只存在于 Maven 宇宙中的类。 因此,最好的方法是将插件移植到 Gradle。

在您的特定情况下,有一个 Swagger Maven 插件的 Gradle 端口。我自己没有使用过,但快速谷歌搜索会发现:

Gradle Swagger plugin

【讨论】:

    【解决方案2】:

    我同意 Mark Bramnik 的回答,但您可以通过比较两个存储库的文档来尝试可行的方法:https://github.com/dave-ellis/gradle-swagger-pluginhttps://github.com/kongchen/swagger-maven-plugin。前一个名为“apiSource 的配置”的表中标识的所有名称都可以是 gradle 的 swagger 块内的变量。

    buildscript {
            repositories {
                mavenLocal()
                maven { url "http://repo.maven.apache.org/maven2" }
            }
            dependencies {
                classpath group: 'com.github.gradle-swagger', name: 'gradle-swagger-plugin', version: '1.0.1-SNAPSHOT'
            }
        }
    
        apply plugin: 'maven'
        apply plugin: 'swagger'
        apply plugin: 'java'
    
        swagger {
            endPoints = [
                    'com.foo.bar.apis',
                    'com.foo.bar.apis.internal.Resource'
            ]
            apiVersion = 'v1'
            basePath = 'http://www.example.com'
            mustacheFileRoot = "${projectDir}/src/main/resources/"
            outputTemplate = "${mustacheFileRoot}/strapdown.html.mustache"
            swaggerDirectory = "${buildDir}/site/api-docs"
            outputPath = "${buildDir}/site/swagger/strapdown.html"
        }
    

    【讨论】:

    • 感谢您的指点,但 gradle 版本最后一次提交是在一年多以前。
    猜你喜欢
    • 2017-04-01
    • 1970-01-01
    • 2011-11-12
    • 1970-01-01
    • 1970-01-01
    • 2017-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多