Howto handle clash of tasks for two gradle plugins?

放肆的年华 提交于 2020-06-29 05:40:12

问题


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:


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'
   // ....
}


来源:https://stackoverflow.com/questions/62588752/howto-handle-clash-of-tasks-for-two-gradle-plugins

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!