Reputation: 479
I would like to specify the below maven plugin in gradle. How to specify the configuration in 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>
Upvotes: 1
Views: 883
Reputation: 42481
In general, it's impossible to use Maven plugin 'as is' in Gradle. Maven plugins internally depend on some classes that exist only in Maven universe. So, the best approach would be porting the plugin to Gradle.
In your particular case there is a Gradle port of Swagger Maven plugin. I haven't used it by myself, but quick googling reveals this:
Upvotes: 2
Reputation: 458
I aggree with Mark Bramnik answer but you can try what can work by comparing documentation of both repositories : https://github.com/dave-ellis/gradle-swagger-plugin and https://github.com/kongchen/swagger-maven-plugin. All name identified in table called "Configuration for apiSource" of the former one could be a variable inside swagger block for 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"
}
Upvotes: 1