Howto handle clash of tasks for two gradle plugins?

Viewed 494

I use gradle with the two plugins com.jfrog.artifactory and io.swagger.core.v3.swagger-gradle-plugin .

Now I want to configure as described here https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin the generation of code. But it seems that the resolve task has already been defined from artifactory. How do I adress the method of swagger-plugin directly?

This is in my build.gradle:

resolve {
   outputFileName = 'bananas'
   outputFileName = 'PetStoreAPI'
   outputFormat = 'JSON'
   prettyPrint = 'TRUE'
   classpath = sourceSets.main.runtimeClasspath
   resourcePackages = ['io.test']
   outputDir = file('test')
}

and this is the error message: Could not set unknown property 'outputFileName' for object of type org.jfrog.gradle.plugin.artifactory.dsl.ResolverConfig.

1 Answers

There is indeed a clash between Artifactory resolve extension and Swagger plugin resolve tasks (of type import io.swagger.v3.plugins.gradle.tasks.ResolveTask)

One way to solve this is to reference the swagger tasks explicitly using fully-qualified name, as follows:

io.swagger.v3.plugins.gradle.tasks.ResolveTask swaggerResolve = tasks.getByName("resolve")
swaggerResolve.configure {
    outputFileName = 'PetStoreAPI'
    outputFormat = 'JSON'
    prettyPrint = 'TRUE'
    classpath = sourceSets.main.runtimeClasspath
    resourcePackages = ['io.test']
    outputDir = file('test')
}

EDIT Simpler solution , see Lukas's comment

tasks.resolve { 
   outputFileName = 'PetStoreAPI'
   // ....
}
Related