PMD ruleSetFiles with url


(Cédric Thiebault) #1

I’m trying to use PMD plugin with remote ruleSet files:

apply plugin: 'pmd'
pmd {
  ruleSetFiles = files('https://github.com/obiba/conventions/raw/master/obiba-pmd-ruleset.xml')
}

But it does not work:

Cannot convert URL 'https://github.com/obiba/conventions/raw/master/obiba-pmd-ruleset.xml' to a file.

I was able to do that with Maven but I don’t know how to do it with Gradle :frowning:


(René Groeschke) #2

Hello Cédric, remote URLs for ruleset files are currently not supported. But you can use two lines of groovy code to get this working.

pmd {
       def remoteRuleSets = file("$buildDir/remoteRulesets")
       remoteRuleSets.text = new URL('https://github.com/obiba/conventions/...').text
       ruleSetFiles = files(remoteRuleSets)
 }

cheers, René

ps.: IMO, there are two downsites with using remote rulesetFiles though

  1. you are not able to perform a offline build and always need remote access when running your build 2. the remote definition might change. This can cause problems with the reproducability of a build