CheckStyle Unable to create a Checker:configLocation 문제

1577 단어

CheckStyle Unable to create a Checker:configLocation 문제


최근에는 안드로이드 스튜디오 3.0 버전을 사용하면서 그레이드 버전을 3.3에서 3.5 버전으로 업그레이드했다.
원래 프로젝트에서 정적 코드 분석 도구인 CheckStyle을 사용할 수 없는 것을 갑자기 발견했습니다. 다음과 같은 오류가 발생했습니다.
1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:checkstyle'.
> Unable to create Root Module: configLocation {xxxx/xxxx/checkstyle/checkstyle.xml}, classpath {null}.

자료를 찾아보니 대체로 이렇다.Gradle3.5 릴리즈에서는 기본적으로 CheckStyle7.2 버전, 3.3 버전에서 5.9 버전을 사용하고 호환성 오류가 있습니다.
원문은 다음과 같다.
The specific problem here is that OperatorWrap did not support the METHOD_REF token until Checkstyle 7.2. Technically this configuration file is invalid unless you specify Checkstyle version 7.2 or higher.

With Gradle 3.3 (default Checkstyle 5.9), that configuration was still not correct, but you did not receive an error due to looser validation (in Checkstyle, not Gradle). That version only failed on tokens that were completely unknown, not those that were only valid for other rules.

그래서 공식적으로 해결 방안이 없는 경우Gradle에서 체크스타일 버전을 지정할 수 있다.
아래와 같다
apply plugin: 'checkstyle'

checkstyle {
    toolVersion = '5.9'
}

task checkstyle(type: Checkstyle) {
    configFile file("checkstyle.xml")

    ignoreFailures false
    showViolations true

    source 'src'
    include '**/*.java'
    exclude '**/gen/**', '**/test/**', '**/build/**'

    classpath = files()
}

공식 주소

좋은 웹페이지 즐겨찾기