Checkstyle gradle Unable to instantiate AvoidConstantAsFirstOperandInConditionCheck when checking style -
i have configured gradle build script make use of checkstyle added sventu checkstyle checks, when execute checkstylemain task, build fails following error:
* went wrong: execution failed task ':checkstylemain'. > unable create checker: cannot initialize module treewalker - unable instantiate avoidconstantasfirstoperandinconditioncheck this happens though have included checkstyle jar in build. below relevant parts of build script:
repositories { mavencentral() maven { url "http://sevntu-checkstyle.github.com/sevntu.checkstyle/maven2" } } checkstyle { configfile = new file("etc/config/dev.xml"); toolversion = "6.8" } configurations { checkstyle } dependencies { checkstyle "com.github.sevntu.checkstyle:sevntu-checks:1.13.4" } note build works when remove dependencies section , test checkstyle xml doc not have sevntu checks configured. configuration similar example @ sevntu-checkstyle/checkstyle-samples
what missing here?
so figured out:
turns out example @ https://github.com/sevntu-checkstyle/checkstyle-samples/blob/master/gradle-project/build.gradle works if put full classpath of custom checks name each custom check.
this due checkstyle not knowing custom checks located in package. turns out checkstyle can find out if include checkstyle_packages.xml file in jar describes packages contains checks.
unfortunately there no such file in com.github.sevntu.checkstyle:sevntu-checks:1.13.4. information, need include "com.github.sevntu.checkstyle:sevntu-checkstyle-maven-plugin:1.13.4", contains nothing checkstyle_packages.xml file.
so i've added dependencies , checkstyle rules parses:
dependencies { checkstyle "com.github.sevntu.checkstyle:sevntu-checks:1.13.4", "com.github.sevntu.checkstyle:sevntu-checkstyle-maven-plugin:1.13.4" } hoping save pain in future :)
Comments
Post a Comment