如何处理两个 gradle 插件的任务冲突?

Howto handle clash of tasks for two gradle plugins?

我将 gradle 与两个插件 com.jfrog.artifactoryio.swagger.core.v3.swagger-gradle-plugin 一起使用。

现在我要按照此处所述配置生成代码https://github.com/swagger-api/swagger-core/tree/master/modules/swagger-gradle-plugin。但似乎 resolve 任务已经从 artifactory 中定义了。如何直接访问swagger-plugin的方法?

这是我的 build.gradle:

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

这是错误消息:Could not set unknown property 'outputFileName' for object of type org.jfrog.gradle.plugin.artifactory.dsl.ResolverConfig.

Artifactory resolve 扩展和 Swagger 插件 resolve 任务(import io.swagger.v3.plugins.gradle.tasks.ResolveTask 类型)之间确实存在冲突

解决这个问题的一种方法是使用完全限定名称显式引用 swagger 任务,如下所示:

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')
}

编辑 更简单的解决方案,请参阅 Lukas 的评论

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