<?xml version="1.0"?>

<ruleset name="Basic POM"
    xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 http://pmd.sourceforge.net/ruleset_2_0_0.xsd">
  <description>
The Basic POM Ruleset contains a collection of good practices regarding Maven's POM files.
  </description>

    <rule name="ProjectVersionAsDependencyVersion"
         language="xml"
         since="5.4"
         message="Do not use project's version to express a dependency's version."
         class="net.sourceforge.pmd.lang.rule.XPathRule"
         externalInfoUrl="${pmd.website.baseurl}/rules/pom/basic.html#ProjectVersionAsDependencyVersion">
     <description>
 <![CDATA[
Using that expression in dependency declarations seems like a shortcut, but it can go wrong. By far the most common problem is the use of
${project.version} in a BOM or parent POM.
 ]]>
     </description>
     <priority>3</priority>
     <properties>
         <property name="xpath">
             <value>
 <![CDATA[
//dependency/version/text[contains(@Image,'{project.version}')]
]]>
             </value>
         </property>
     </properties>
     <example>
 <![CDATA[
<project...>
  ...
  <dependency>
    ...
    <version>${project.dependency}</version>
  </dependency>
</project>
 ]]>
     </example>
     </rule>

  <rule name="InvalidDependencyTypes"
        language="xml"
        since="5.4"
        message="By default, Maven only recognized the following types: $validTypes."
        class="net.sourceforge.pmd.lang.rule.XPathRule"
        externalInfoUrl="${pmd.website.baseurl}/rules/pom/basic.html#InvalidDependencyTypes">
     <description><![CDATA[
While Maven will not failed if you use an invalid type for a dependency in the dependency management section, it will not also uses the dependency. ]]>
     </description>
     <priority>3</priority>
     <properties>
         <property name="xpath">
             <value>
<![CDATA[
//dependencyManagement/dependency/type/text[not(contains('pom, jar, maven-plugin, ejb, war, ear, rar, par',@Image))]
]]>
             </value>
         </property>
         <!-- FIXME: property injection seems to be failing with XML.... -->
         <!-- property name="validTypes" value="pom, jar, maven-plugin, ejb, war, ear, rar, par" description="Set of valid types."-->
     </properties>
     <example>
 <![CDATA[
<project...>
  ...
  <dependencyManagement>
      ...
    <dependency>
      <groupId>org.jboss.arquillian</groupId>
      <artifactId>arquillian-bom</artifactId>
      <version>${arquillian.version}</version>
      <type>bom</type> <!-- not a valid type ! 'pom' is ! -->
      <scope>import</scope>
    </dependency>
    ...
  </dependencyManagement>
</project>
 ]]>
     </example>
     </rule>

 </ruleset>
