DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations

Gradle CodeNarc Plugin

Evgeny Goldin user avatar by
Evgeny Goldin
·
Aug. 16, 11 · Interview
Like (0)
Save
Tweet
Share
9.35K Views

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'
..

As always, examples and documentation are available in the Wiki. Your comments, feedback and bug reports are most welcome!

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!

 

From http://evgeny-goldin.com/blog/gradle-codenarc-plugin

Gradle

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • [DZone Survey] Share Your Expertise and Take our 2023 Web, Mobile, and Low-Code Apps Survey
  • Public Key and Private Key Pairs: Know the Technical Difference
  • How To Best Use Java Records as DTOs in Spring Boot 3
  • Asynchronous Messaging Service

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: