Configuring CodeNarc in Gradle

I am trying to wrap my head using CodeNarc inside Gradle .

According to the CodeNarc docs, my project should have the config file config/codenarc/codenarc.xml . But then I see a lot of examples of configuration files (such as this StarterRuleSet ) that seem to use Groovy DSL.

So I ask:

  • Is it possible to use Groovy DSL, and if so, what should be the name of the file, where should it be located in my project, and how to connect it to my Gradle build ?; and
  • Where is the Groovy DSL documentation located ?; and
  • By default, CodeNarc displays a report called main.html ; How can I change the name of this file, say codenarc.html ?
+6
source share
1 answer

It looks like in build.gradle you can just put:

 codenarc { toolVersion = "0.20" } codenarcMain { configFile = rootProject.file("path/to/CodeNarcMain.groovy") } codenarcTest { configFile = rootProject.file("path/to/CodeNarcTest.groovy") } 

If file names ( CodeNarcMain , CodeNarcTest ) is what you want them to be.

Groovy DSL documentation is here. If you need to configure a specific rule, review it in the documentation and if the rule has the public properties that it provides, they will be listed in the table in accordance with the specific documentation for the rules.

And it looks like you can change the format of the report file (HTML, XML, text, console), but not the actual file name.

+9
source

Source: https://habr.com/ru/post/975617/


All Articles