我想在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>
通常,在Gradle中无法按原样使用Maven插件。 Maven插件在内部依赖于仅在Maven Universe中存在的某些类。因此,最好的方法是将插件移植到Gradle。
在您的特定情况下,有Swagger Maven插件的Gradle端口。我没有自己使用它,但是快速搜索可以发现:
我同意Mark Bramnik的回答,但是您可以通过比较两个存储库的文档https://github.com/dave-ellis/gradle-swagger-plugin和https://github.com/kongchen/swagger-maven-plugin来尝试可行的方法。前者称为“ apiSource的配置”的表中标识的所有名称都可以是swagger块中用于gradle的变量。]>
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"
}