Uploaded image for project: 'Maven Enforcer Plugin'
  1. Maven Enforcer Plugin
  2. MENFORCER-507

Add xsltLocation parameter to ExternalRules

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • next-release
    • externalRules
    • None

    Description

      Add a new optional parameter called xsltLocation to org.apache.maven.enforcer.rules.ExternalRules.

      The new parameter points at a location of an XSLT file used to transform the rule document available via location before it is applied.

      This is useful, when users want to consume rules defined in an external project, but they need to remove or adapt some of those for the local circumstances.

      Example

      If location points at the following rule set:

      <enforcer>
         <rules>
           <bannedDependencies>
              <excludes>
                <exclude>com.google.code.findbugs:jsr305</exclude>
                <exclude>com.google.guava:listenablefuture</exclude>
              </excludes>
           </bannedDependencies>
         </rules>
       </enforcer>
      

      And if xsltLocation points at the following transformation

       <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
         <xsl:output omit-xml-declaration="yes"/>
      
         <!-- Copy everything unless there is a template with a more specific matcher -->
         <xsl:template match="node()|@*">
           <xsl:copy>
             <xsl:apply-templates select="node()|@*"/>
           </xsl:copy>
         </xsl:template>
      
         <!-- An empty template will effectively remove the matching nodes -->
         <xsl:template match=
       "//bannedDependencies/excludes/exclude[contains(text(), 'com.google.code.findbugs:jsr305')]"/>
       </xsl:stylesheet>
      

      Then the effective rule set will look like to following:

       <enforcer>
         <rules>
           <bannedDependencies>
              <excludes>
                <exclude>com.google.guava:listenablefuture</exclude>
              </excludes>
           </bannedDependencies>
         </rules>
       </enforcer>
      

      A PR follows

      Attachments

        Issue Links

          Activity

            People

              ppalaga Peter Palaga
              ppalaga Peter Palaga
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: