gradle-code-quality-tools-plugin

我要开发同款
匿名用户2021年11月26日
49阅读
开发技术Kotlin
所属分类手机/移动开发
授权协议Apache-2.0 License

作品详情

gradle-code-quality-tools-plugin

GradlepluginthatconfiguresErrorProne,Checkstyle,PMD,CPD,Lint,Detekt&Ktlint.Allofthesetoolsarealsoautomaticallyhookedintothecheckgradletask.Below,I'llgomoreintodepthhoweachofthosepluginsareconfigured.

ThispluginrequiresGradle5.0orlater.

Setup

root/build.gradle

buildscript{repositories{mavenCentral()google()gradlePluginPortal()//RequiredfortheErrorproneGradlePlugin.}dependencies{classpath"com.vanniktech:gradle-code-quality-tools-plugin:0.20.0"}}applyplugin:"com.vanniktech.code.quality.tools"

Information:ThispluginisalsoavailableonGradleplugins

Snapshotbuildscript{repositories{maven{url"https://oss.sonatype.org/content/repositories/snapshots"}}dependencies{classpath"com.vanniktech:gradle-code-quality-tools-plugin:0.21.0-SNAPSHOT"}}applyplugin:"com.vanniktech.code.quality.tools"Configuration

Thephilosophyofthispluginistofailearly.Thismeanshavingzerowarnings/errorsreportedfromanytools.Ifyou'rejustgettingstartedwiththisinalargecodebaseyoumightnotbeabletoachievethisrightawayinwhichcaseyoumightwanttosetfailEarlytofalseandthenapplyatafinermoregranularscopehoweachtoolshouldbehavee.g.checkstyle{ignoreFailures=false}.

Thosearealltheavailableconfigurations-shownwithdefaultvaluesandtheirtypes.MoreinformationcanbefoundintheKotlinDocumentationoftheExtensionandtherespectiveextensionsfordesignatedintegrations.

codeQualityTools{booleanfailEarly=truebooleanxmlReports=truebooleanhtmlReports=falsebooleantextReports=falseString[]ignoreProjects=[]checkstyle{booleanenabled=trueStringtoolVersion='8.6'StringconfigFile='code_quality_tools/checkstyle.xml'BooleanignoreFailures=nullBooleanshowViolations=nullStringsource='src'List<String>include=['**/*.java']List<String>exclude=['**/gen/**']}pmd{booleanenabled=trueStringtoolVersion='6.0.0'StringruleSetFile='code_quality_tools/pmd.xml'BooleanignoreFailures=nullStringsource='src'List<String>include=['**/*.java']List<String>exclude=['**/gen/**']}lint{booleanenabled=trueBooleantextReport=nullStringtextOutput='stdout'BooleanabortOnError=nullBooleanwarningsAsErrors=nullBooleancheckAllWarnings=nullStringbaselineFileName=nullBooleanabsolutePaths=nullFilelintConfig=nullBooleancheckReleaseBuilds=falseBooleancheckTestSources=nullBooleancheckDependencies=null}ktlint{booleanenabled=trueStringtoolVersion='0.32.0'booleanexperimental=false}detekt{booleanenabled=trueStringtoolVersion='1.0.0'Stringconfig='code_quality_tools/detekt.yml'StringbaselineFileName=nullbooleanfailFast=true}cpd{booleanenabled=trueStringsource='src'Stringlanguage='java'BooleanignoreFailures=nullintminimumTokenCount=50}errorProne{booleanenabled=trueStringtoolVersion='2.1.3'}kotlin{booleanallWarningsAsErrors=true}}Tools

HereI'llgiveabitmoreinformationabouthoweachofthetoolswillbeapplied.Ifthere'saGradletaskthatthispluginwillgenerateitwillalsobehookedupintothecheckGradletask.Thismeansthatwhenyouexecutecheckalloftheroolswillberunningforyou.

ErrorProne

It'llapplytheErrorProneGradlePluginwhichwillruntogetherwithassemble.There'snoreportgeneratedforthisbutyou'llgetcompilewarnings&errors.

Checkstyle

It'llapplytheCheckstylePluginandgeneratethecheckstyletaskthatwillexecutecheckstyle.TheconfigurationpropertiesofcodeQualityTools->checkstylemirrorthepropertiesfromtheplugin.

PMD

It'llapplythePMDPluginandgeneratethepmdtaskthatwillexecutepmd.TheconfigurationpropertiesofcodeQualityTools->pmdmirrorthepropertiesfromtheplugin.

CPD

It'llapplytheCPDPluginandgeneratethecpdChecktaskthatwillexecutecpd.TheconfigurationpropertiesofcodeQualityTools->cpdmirrorthepropertiesfromtheplugin.

Lint

ThiswillonlyworkwhenoneoftheAndroidPlugins(com.android.application,com.android.library,etc.)areapplied.TheconfigurationpropertiesofcodeQualityTools->lintmirrorthepropertiesfromthelintOptions.

Detekt

It'llusethespecifieddetektversionandgeneratethedetektChecktaskwhichwillrundetektonyourcodebase.

Ktlint

It'llusethespecifiedktlintversionandthengeneratetwotasks.ktlintwhichwillrunktlintoveryourcodeandflagissues.ktlintFormatwillreformatyourcode.

Note:TheremightbesomeconfigurationpropertiesthatarenotmirroredinwhichcasefeelfreetoopenaPR.Personally,Idon'thavetheneedforallofthem.

License

Copyright(C)2016Vanniktech-NiklasBaudy

LicensedundertheApacheLicense,Version2.0

声明:本文仅代表作者观点,不代表本站立场。如果侵犯到您的合法权益,请联系我们删除侵权资源!如果遇到资源链接失效,请您通过评论或工单的方式通知管理员。未经允许,不得转载,本站所有资源文章禁止商业使用运营!
下载安装【程序员客栈】APP
实时对接需求、及时收发消息、丰富的开放项目需求、随时随地查看项目状态

评论