hotmeatballsoup:
してください注:私が作成し、あなたが正確に問題を作り出すために、このGitHubのプロジェクトを。
Javaの8と、ここでのGradle 4.6。あなたが経由で新しいJava Gradleのプロジェクトを作成した場合gradle init --type java-library
と、それまでのGradleのCheckstyleプラグイン、および使用するためにプラグインすることを設定し、GoogleののCheckstyle XMLをそれはボックスの右アウトを失敗します。
plugins {
id 'java-library'
}
apply plugin: 'checkstyle'
dependencies {
testCompile(
'junit:junit:4.12'
)
}
repositories {
jcenter()
mavenCentral()
}
checkstyle {
// Go to the Google Checks link above and paste its
// contents into checkstyle.xml
config = rootProject.resources.text.fromFile('buildConfig/checkstyle/checkstyle.xml')
}
その設定では、ランニングが./gradle clean build
生成されます。
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':checkstyleMain'.
> Unable to create a Checker: configLocation {/Users/myuser/workspace/test-gradle-checkstyle/buildConfig/checkstyle/checkstyle.xml}, classpath {/Users/myuser/workspace/test-gradle-checkstyle/build/classes/java/main:/Users/myuser/workspace/test-gradle-checkstyle/build/resources/main}.
* 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.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s
4 actionable tasks: 4 executed
$ pwd
/Users/myuser/workspace/test-gradle-checkstyle
$ git init
Initialized empty Git repository in /Users/myuser/workspace/test-gradle-checkstyle/.git/
私は、なぜ思ったんだけど?
(将来のGooglerのための)編集:
使用して--stacktrace
、実際のエラーがあります
cannot initialize module TreeWalker - Token "METHOD_REF" was not found in Acceptable tokens list in check com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck
ボアズ:
どうやらのGradleは、Checkstyleはの古いバージョンを使用しています - しかし、これを解決する方法があります!
まず、私はあなたがあなたのビルドで問題が発生した際に、使用することをお勧めしたい--stacktrace
か、-S
それを使用することにより、あなたは失敗している正確に何を参照してくださいよ、実際の失敗を参照してください。
cannot initialize module TreeWalker - Token "METHOD_REF" was not found in Acceptable tokens list in check com.puppycrawl.tools.checkstyle.checks.whitespace.SeparatorWrapCheck
Gradleでは4.6が最新解きにこの問題を使用する構成をアップグレードし、今ではかなり古いですCheckstyleは6.19を、(最新は8.11である)使用しているためです。
checkstyle {
config = rootProject.resources.text.fromFile('buildConfig/checkstyle/checkstyle.xml')
toolVersion '8.11'
}
結果は次のとおりです。
> Task :checkstyleMain
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/main/java/Library.java:5: 'method def modifier' has incorrect indentation level 4, expected level should be 2. [Indentation]
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/main/java/Library.java:6: 'method def' child has incorrect indentation level 8, expected level should be 4. [Indentation]
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/main/java/Library.java:7: 'method def rcurly' has incorrect indentation level 4, expected level should be 2. [Indentation]
> Task :checkstyleTest
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/test/java/LibraryTest.java:5: 'import' should be separated from previous statement. [EmptyLineSeparator]
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/test/java/LibraryTest.java:5: Import statement for 'org.junit.Assert.*' is in the wrong order. Should be in the 'STATIC' group, expecting not assigned imports on this line. [CustomImportOrder]
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/test/java/LibraryTest.java:5: Using the '.*' form of import should be avoided - org.junit.Assert.*. [AvoidStarImport]
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/test/java/LibraryTest.java:8: 'method def modifier' has incorrect indentation level 4, expected level should be 2. [Indentation]
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/test/java/LibraryTest.java:9: 'method def' child has incorrect indentation level 8, expected level should be 4. [Indentation]
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/test/java/LibraryTest.java:10: 'method def' child has incorrect indentation level 8, expected level should be 4. [Indentation]
[ant:checkstyle] [WARN] /.../test-gradle-checkstyle/src/test/java/LibraryTest.java:11: 'method def rcurly' has incorrect indentation level 4, expected level should be 2. [Indentation]
BUILD SUCCESSFUL in 9s
7 actionable tasks: 7 executed
いくつかのバグは、この問題のGradleプロジェクトにとのCheckstyleプロジェクトの両方に開いています