Gradle PMD plugin doesn't accept URI for rule set location

I’m moving towards centralizing some project configuration, like static code analysis, code coverage and likes. Problem is that the Gradle PMD plugin expects a file as the rule set location thus forcing each project to copy the rule set. I don’t see why it can’t use a URI instead. Currently I’m working around it by doing the following:

afterEvaluate {
    def pmdRuleSet = file("${tempDir}/ruleset.xml")
      if (!pmdRuleSet.exists()) {
        tempDir.mkdirs()
          download("${projectURI}/src/main/config/pmd/ruleset.xml", tempDir.absolutePath)
    } else {
        println "Found PMD ruleset at ${pmdRuleSet}."
    }
      pmd {
        toolVersion = props['pmdVersion']
        sourceSets = [sourceSets.main]
        ignoreFailures = true
        targetJdk = props['projectSourceCompatibility']
        ruleSetFiles = files("${tempDir}/ruleset.xml")
    }
}
  def download(address, downloadLocation = "${tempDir}") {
    def f = new File(downloadLocation, address.tokenize("/")[-1])
    def fos = new FileOutputStream(f)
    def out = new BufferedOutputStream(fos)
    out << new URL(address).openStream()
    out.close()
      println "Downloaded ${address} to ${f.absolutePath}."
      f.absolutePath
}

By the way, I wanted to use gradle.projectsLoaded instead of afterEvaluate but the former doesn’t seem to get executed at all.

This is mainly due to the fact that the underlying PMD Ant task doesn’t expose an option for providing an URI. You might want to ask for that feature on the PMD user mailing list.

That’s a good idea but until that happens, couldn’t the Gradle plugin could do something like I did?