Menu

#1274 ant integration broken with pmd-5.2.0

PMD-5.2.1
closed
None
PMD
3-Major
Bug
5.2
2015-02-15
2014-10-20
No

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>

Related

Discussion: Cannot Exclude UselessParentheses from java-basic
Discussion: IllegalArgumentException after upgrading to PMD 5.2.0 in Gradle build

Discussion

  • Andreas Dangel

    Andreas Dangel - 2014-10-20

    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?

    <path id="pmd.classpath">
        <pathelement location="${build}"/>
        <fileset dir="/path/to/my/pmd/lib/">
            <include name="*.jar"/>
        </fileset>
    </path>
    
    <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
    
     
  • James Jamieson

    James Jamieson - 2014-10-20

    I do and both jars are in the fileset location

    Snippet from build file:

    <path id="pmd.classpath">
        <fileset dir="${pmdLib.dir}">
            <include name="*.jar"/>
        </fileset>
    </path>
    
    <taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask" classpathref="pmd.classpath"/>
    
     
  • Andreas Dangel

    Andreas Dangel - 2014-10-20

    Well, for now, you'll need to specify the classpath from outside when running ant:

    ant -lib /your/path/to/pmd/lib/
    

    This will add all the pmd jars to the classpath.

     
  • James Jamieson

    James Jamieson - 2014-10-20

    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!

     
  • James Jamieson

    James Jamieson - 2014-10-20

    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!

     
  • Andreas Dangel

    Andreas Dangel - 2014-10-23
    • summary: IllegalArgumentException when parsing rules --> ant integration broken with pmd-5.2.0
    • status: open --> in-progress
    • assigned_to: Andreas Dangel
    • Milestone: New Tickets --> PMD-next
     
  • Andreas Dangel

    Andreas Dangel - 2014-11-03
    • status: in-progress --> closed
     

Log in to post a comment.

MongoDB Logo MongoDB