[
https://issues.apache.org/jira/browse/MENFORCER-507?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Slawomir Jaranowski closed MENFORCER-507.
-----------------------------------------
Resolution: Fixed
PR merged ...
> Add xsltLocation parameter to ExternalRules
> -------------------------------------------
>
> Key: MENFORCER-507
> URL: https://issues.apache.org/jira/browse/MENFORCER-507
> Project: Maven Enforcer Plugin
> Issue Type: Bug
> Components: externalRules
> Reporter: Peter Palaga
> Assignee: Peter Palaga
> Priority: Major
> Fix For: next-release
>
>
> 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:
> {code:xml}
> <enforcer>
> <rules>
> <bannedDependencies>
> <excludes>
> <exclude>com.google.code.findbugs:jsr305</exclude>
> <exclude>com.google.guava:listenablefuture</exclude>
> </excludes>
> </bannedDependencies>
> </rules>
> </enforcer>
> {code}
> And if xsltLocation points at the following transformation
> {code:xml}
> <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>
> {code}
> Then the effective rule set will look like to following:
> {code:xml}
> <enforcer>
> <rules>
> <bannedDependencies>
> <excludes>
> <exclude>com.google.guava:listenablefuture</exclude>
> </excludes>
> </bannedDependencies>
> </rules>
> </enforcer>
> {code}
> A PR follows
--
This message was sent by Atlassian Jira
(v8.20.10#820010)