0

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?

pditommaso
  • 3,186
  • 6
  • 28
  • 43

1 Answers1

1

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

neversleepz
  • 422
  • 4
  • 10
  • 1
    It looks cool, but unfortunately I'm getting this error message `Could not find property 'allGroovy' on source set 'main'`. Could it be a problem with Gradle version? I'm using Gradle 2.1 – pditommaso Sep 16 '14 at 08:51
  • 1
    I'm using 2.1 also. Are you applying the codenarc plugin to the root project and the subprojects? – neversleepz Sep 16 '14 at 09:48