After upgrading to gradle 2.2.1 I started having some weird issues with my PMD plugin. I kept getting this error:

1
2
3
4
5
6
7
8
[adrian@localhost project]$ gradle pmdMain
:pmdMain
* file: ./src/main/java/src/com/ncona/project/File.java
    src:  File.java:45:45
    rule: UselessParentheses
    msg:  Useless parentheses.
    code: getCurrentTime() + (1000 * 60 * 60 * 2),
...

I wasn’t specifically including this rule in my ruleset file but I tried excluding it to see what happened. I added this to my ruleset.xml file:

1
2
3
<rule ref="rulesets/java/unnecessary.xml">
  <exclude name="UselessParentheses" />
</rule>

This didn’t have any effect. I didn’t know what else to do, so I tried to find an answer in Google. It turns out a feature was added to the plugin where it automatically adds some rules for you. Luckily someone found the issue before me and got a work around:

1
2
3
4
pmd {
  ruleSets = [] // This overwrites the rules that are being added
  ruleSetFiles = files('config/pmd/rulesets.xml')
}

This fixed the issue.

[ mobile  android  automation  gradle  productivity  ]
Android development with Docker android automation mobile productivity
Getting familiar with Terraform automation productivity
Taking over existing instances with Terraform automation productivity
Terraform automation productivity
Autotools automation productivity