Pmd-xml: java.lang.IllegalArgumentException: Unknown Language 'xml', supported Languages are java

Hello Guys,

We are using pmd plugin with gradle to run custom pmd rules on our source code. We are able to run java custom rules without any issue.

Now, we are writing xml custom rules using pmd-xml. But, we are getting below error.
java.lang.IllegalArgumentException: Unknown Language ‘xml’ for ruleXmlRuleDemo, supported Languages are java.

It seems by default gradle supports only java for pmd plugin. Can you please help me out to override this property value in gradle file.

I am also sharing my code. Please check.


buildscript {
ext {
//springBootVersion = ‘2.0.0.RELEASE’
repositories {
dependencies {



apply plugin: ‘java’
apply plugin: ‘eclipse’
apply plugin: ‘pmd’
pmd {
ruleSets = []
sourceSets = [sourceSets.main]
ruleSetFiles = rootProject.files(“src/main/resources/archruleset.xml”)
toolVersion = “6.3.0”

group = ‘com.sample’
version = ‘0.0.1-SNAPSHOT’
sourceCompatibility = 1.8

repositories {

dependencies {
compile group: ‘net.sourceforge.pmd’, name: ‘pmd’, version: ‘6.3.0’
compile group: ‘net.sourceforge.pmd’, name: ‘pmd-java’, version: ‘6.3.0’
compile group: ‘net.sourceforge.pmd’, name: ‘pmd-xml’, version: ‘6.3.0’
task(runDebug, dependsOn: ‘classes’, type: JavaExec) {
main = “com.mything.server.HttpServer”
classpath = sourceSets.main.runtimeClasspath
jvmArgs = ["-Xdebug", “-Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5005”]


<?xml version="1.0" encoding="UTF-8"?>

This ruleset validates xml files

Able to parse Xml file using pmd 3

package com.sample.demo.xml;

import net.sourceforge.pmd.RuleContext;
import net.sourceforge.pmd.lang.xml.ast.XmlNode;
import net.sourceforge.pmd.lang.xml.rule.AbstractXmlRule;

public class XmlRuleDemo extends AbstractXmlRule{

public void visit(XmlNode xmlNode, RuleContext ruleContext){
	 addViolation(ruleContext, xmlNode);


Thank you in advance.

Best Regards,