简体   繁体   中英

How create a single CodeNarc report for a multiple-project Gradle build

I have a Gradle multi-projects build where each subproject creates its own CodeNarc report.

Is it possibile to create a single CodeNarc analysis report for all the projects in my build instead of a separate report for each of them?

You can create your own CodeNarc task and configure it with the sourcesets of all its subprojects as follows.

task supernarc(type: CodeNarc) {
  def allGroovySourceDirs = subprojects.collect { Project p -> p.sourceSets.main.allGroovy.getSrcDirs() }.flatten()

  allGroovySourceDirs.each {
    source(it)
  }

  // BTW, if you know you have some violations and don't want the builds to fail because of too many violations, you can increase the threshold as follows
  maxPriority1Violations = 5
  maxPriority2Violations = 5
  maxPriority3Violations = 5

}

I created this sample on Github for you so you could see a project using it.

Does that help?

Cheers Kon

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM