【问题标题】:Duplicate gradle configuration java project重复的gradle配置java项目
【发布时间】:2022-01-06 02:44:19
【问题描述】:

有没有办法在 build.gradle 中避免这种重复?

pluginManager.withPlugin('java-library') {
    apply plugin: 'com.github.spotbugs'

    spotbugs {
        toolVersion = '4.5.2'
        ignoreFailures = false
        showStackTraces = true
        showProgress = true
        excludeFilter = rootProject.file(rootProject.ext.excludeFile)
        effort = 'default'
        reportLevel = 'default'
        reportsDir = file("$buildDir/spotbugs")
        maxHeapSize = '1g'
        extraArgs = [ '-nested:false' ] // no jar or zips
    }

在下面的某个地方: ...

pluginManager.withPlugin('application') {
    apply plugin: 'com.github.spotbugs'

spotbugs {
        toolVersion = '4.5.2'
        ignoreFailures = false
        showStackTraces = true
        showProgress = true
        excludeFilter = rootProject.file(rootProject.ext.excludeFile)
        effort = 'default'
        reportLevel = 'default'
        reportsDir = file("$buildDir/spotbugs")
        maxHeapSize = '1g'
        extraArgs = [ '-nested:false' ] // no jar or zips
    }

我只想将相同的配置放在一个地方。

【问题讨论】:

    标签: java gradle plugins build configuration


    【解决方案1】:

    尝试使用单个 gradle 文件,并将此 gradle 文件应用到您想要的位置:
    apply from: 'your_gradle_file.gradle'

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-24
      • 1970-01-01
      • 2013-03-27
      • 2021-02-04
      • 2018-08-05
      • 1970-01-01
      相关资源
      最近更新 更多