Не удалось найти метод destination () для аргументов в XML-отчете типа org.gradle.api.plugins.quality.internal.findbugs.FindBugsXmlReportImpl - PullRequest
1 голос
/ 30 апреля 2019

После обновления версии Android Studio до 3.4.0 я обновил версию Gradle до 5.1.1 и попытался пересобрать проект, он выдает исключение в файле quality.gradle.

 Task failed with an exception.
-----------
* Where:
Script '/home/Desktop/workplace/testProject/quality/quality.gradle' line: 35

* What went wrong:
A problem occurred evaluating script.
> Could not find method destination() for arguments [/home/Desktop/workplace/testProject/app/build/reports/findbugs/findbugs.xml] on Report xml of type org.gradle.api.plugins.quality.internal.findbugs.FindBugsXmlReportImpl.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

URL-адрес classpath уровня проекта Android и URL-адрес распространения Gradle

classpath 'com.android.tools.build:gradle:3.4.0' distributionUrl = https://services.gradle.org/distributions/gradle-5.1.1-all.zip

Я попытался сделать недействительным кеш и перезапуститьпроект.он продолжает сбой

Вот мой файл quality.gradle

apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'pmd'

task checkstyle(type: Checkstyle) {
    configFile file("${project.rootDir}/quality/checkstyle/checkstyle.xml")
    configProperties = [
            'checkstyle.cache.file': rootProject.file('build/checkstyle.cache'),
            'checkstyleSuppressionsPath': file("${project.rootDir}/quality/checkstyle/suppressions.xml").absolutePath
    ]
    source 'src'
    include '**/*.java'
    exclude '**/gen/**'
    exclude '**/commons/**' //exclude copied stuff from apache commons
    classpath = files()
}

task findbugs(type: FindBugs) {
    ignoreFailures = false
    effort = "max"
    reportLevel = "high"
    excludeFilter file("${project.rootDir}/quality/findbugs/findbugs-filter.xml")
    classes = fileTree('build/intermediates/classes/')

    source 'src'
    include '**/*.java'
    exclude '**/gen/**'

    reports {
        xml.enabled = false
        html.enabled = true
        xml {
            destination "$project.buildDir/reports/findbugs/findbugs.xml"
        }
        html {
            destination "$project.buildDir/reports/findbugs/findbugs.html"
        }
    }

    classpath = files()
}

task pmd(type: Pmd) {
    ignoreFailures = false
    ruleSetFiles = files("${project.rootDir}/quality/pmd/pmd-ruleset.xml")
    ruleSets = []

    source 'src'
    include '**/*.java'
    exclude '**/gen/**'

    reports {
        xml.enabled = false
        html.enabled = true
        xml {
            destination "$project.buildDir/reports/pmd/pmd.xml"
        }
        html {
            destination "$project.buildDir/reports/pmd/pmd.html"
        }
    }
}

check.doLast {
    project.tasks.getByName("checkstyle").execute()
    project.tasks.getByName("findbugs").execute()
    project.tasks.getByName("pmd").execute()
    project.tasks.getByName("lint").execute()
}

checkstyle {
    toolVersion '6.17'    // set Checkstyle version here
}

Это происходит, когда я использую Gradle версии 5.1.1 и Gradle classpath version 3.4.0,Ранее я использовал Gradle 4.10.1 и classpath версии 3.3.2.

1 Ответ

5 голосов
/ 30 апреля 2019

В Gradle 5.x setDestination(Object file) был удален вместо Вы должны использовать

setDestination(File file)

, который принимает параметр File так вместо

destination "$yourpath"

замените его на

destination file("$yourpath")

проверка документация Gradle

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...