Gradle CodeNarc Plugin
Gradle CodeNarc Plugin
Join the DZone community and get the full member experience.Join For Free
After working on Gradle CodeNarc plugin for some time and using it in 3 of my projects, I decided to officially release it last week. This plugin allows to easily run a CodeNarc Groovy code analysis from your Gradle build script.
In the simplest form the plugin can be used as:
.. apply from: 'https://raw.github.com/evgeny-goldin/gradle-plugins/master/src/main/groovy/CodeNarc.gradle' ..
which adds new "codenarc" Gradle task. But it is better not to rely on default values of CodeNarc version and RuleSet files which will change every time a newer CodeNarc version is released. Specifying some of parameters makes Gradle builds less vulnerable to CodeNarc updates:
.. codenarcVersion = '0.15' codenarcRuleSetFiles = [ 'codenarc.groovy' ] apply from: 'https://raw.github.com/evgeny-goldin/gradle-plugins/master/src/main/groovy/CodeNarc.gradle' ..
This is the third Gradle plugin released as of today. Two others are:
- “About” plugin adds textual “about” file to build artifacts created, linking each binary artifact to the build environment and sources it was created with. The file added contains details about build date and time, last commit made in the project, Java / Gradle versions used for build and some other optional elements like project dependencies, local paths, system and environment variables. If the project was built by Jenkins, TeamCity or Hudson build server then corresponding job details are also added to the file generated.
This is a simple and powerful way to keep all your artifacts aware of their build context, timestamp, and environment.
- “Duplicates” plugin locates duplicate libraries in Gradle configurations. Duplicate libraries have different coordinates (group or name) but contain an identically named classes, i.e., classes with identical fully qualified names. One source of possible duplicates are changes done to library coordinates in Maven repositories. When libraries evolve, migrate, grow up and split up they may start naming their artifacts differently. And then having an old and new version of the same library in Gradle configuration causes a duplicate problem.
Another possible source of duplicate classes in the same configuration are repacking portions of one library in another which may happen from time to time. Whatever reason for duplicate is, this plugin quickly locates all of them and either fails the build or displays a warning.
New Gradle plugins will surely be added later so stay tuned!
Opinions expressed by DZone contributors are their own.