When parsing rules using Ant, an Illegal Argument Exception is given even though the language attribute is correctly set for this rule in the pmd-java-5.2.0.jar.
java.lang.IllegalArgumentException: Unknown Language 'java' for Rule JumbledIncrementer, supported Languages are
at net.sourceforge.pmd.RuleSetFactory.parseSingleRuleNode(RuleSetFactory
.java:353)
at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:
264)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.ja
va:219)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:
164)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetReferenceNode(RuleSetF
actory.java:303)
at net.sourceforge.pmd.RuleSetFactory.parseRuleNode(RuleSetFactory.java:
262)
at net.sourceforge.pmd.RuleSetFactory.parseRuleSetNode(RuleSetFactory.ja
va:219)
at net.sourceforge.pmd.RuleSetFactory.createRuleSet(RuleSetFactory.java:
164)
at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java
:129)
at net.sourceforge.pmd.RuleSetFactory.createRuleSets(RuleSetFactory.java
:114)
at net.sourceforge.pmd.ant.PMDTask.doTask(PMDTask.java:174)
at net.sourceforge.pmd.ant.PMDTask.execute(PMDTask.java:322)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.jav
a:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.Target.execute(Target.java:390)
at org.apache.tools.ant.Target.performTasks(Target.java:411)
at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1360)
at org.apache.tools.ant.Project.executeTarget(Project.java:1329)
at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExe
cutor.java:41)
at org.apache.tools.ant.Project.executeTargets(Project.java:1212)
at org.apache.tools.ant.Main.runBuild(Main.java:801)
at org.apache.tools.ant.Main.startAnt(Main.java:218)
at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)
In addition, adding the sourceLanguage attribute to the Ant tasks produces a different error:
The following language is not supported:<language name="java" version="1.6">.</language>
Discussion: Cannot Exclude UselessParentheses from java-basic
Discussion: IllegalArgumentException after upgrading to PMD 5.2.0 in Gradle build
Thanks for testing the new version!
It seems like the classpath doesn't contain all necessary pmd jars (at least pmd-core-5.2.0.jar and pmd-java-5.2.0.jar are required).
Do you have something like this in your ant build.xml file?
I do and both jars are in the fileset location
Snippet from build file:
Well, for now, you'll need to specify the classpath from outside when running ant:
This will add all the pmd jars to the classpath.
That worked, specifying them directly in the command line for ant allowed 5.2 to run without issue. Hopefully this can be fixed in a future release!
That worked, specifying them directly in the command line for ant allowed 5.2 to run without issue. Hopefully this can be fixed in a future release!