keycloak-aplcache

KEYCLOAK-5843 Add custom license processing plugin to avoid

11/27/2017 3:31:31 PM

Changes

distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/src/main/resources/licenses/common 1(+0 -1)

distribution/adapters/fuse-adapter-zip/src/main/resources/licenses/common 1(+0 -1)

distribution/adapters/js-adapter-zip/src/main/resources/licenses/common 1(+0 -1)

distribution/adapters/wildfly-adapter/src/main/resources/licenses/common 1(+0 -1)

distribution/feature-packs/server-feature-pack/src/main/resources/licenses/common/append-product-licenses.groovy 60(+0 -60)

distribution/feature-packs/server-feature-pack/src/main/resources/licenses/common/keycloak-components-license.html 1(+0 -1)

distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/src/main/resources/licenses/common 1(+0 -1)

distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/src/main/resources/licenses/common 1(+0 -1)

pom.xml 107(+6 -101)

Details

diff --git a/distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/assembly.xml b/distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/assembly.xml
index 96ea486..dc6cfb3 100755
--- a/distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/assembly.xml
+++ b/distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/assembly.xml
@@ -52,6 +52,9 @@
         <fileSet>
             <directory>src/main/resources/licenses/${product.slot}</directory>
             <outputDirectory>docs/licenses-${product.slot}-adapter</outputDirectory>
+            <excludes>
+                <exclude>licenses.xml</exclude>
+            </excludes>
         </fileSet>
         <fileSet>
             <directory>target/licenses</directory>
diff --git a/distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/pom.xml b/distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/pom.xml
index 7e4c526..6bd3df4 100755
--- a/distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/pom.xml
+++ b/distribution/adapters/as7-eap6-adapter/eap6-adapter-zip/pom.xml
@@ -90,35 +90,9 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- License Data -->
             <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-copy-common</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.gmaven</groupId>
-                <artifactId>groovy-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-append-product</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>xml-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-generate-html</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
+                <groupId>org.keycloak</groupId>
+                <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
diff --git a/distribution/adapters/fuse-adapter-zip/assembly.xml b/distribution/adapters/fuse-adapter-zip/assembly.xml
index fa9cd46..bc0f148 100644
--- a/distribution/adapters/fuse-adapter-zip/assembly.xml
+++ b/distribution/adapters/fuse-adapter-zip/assembly.xml
@@ -36,6 +36,9 @@
         <fileSet>
             <directory>src/main/resources/licenses/${product.slot}</directory>
             <outputDirectory>docs/licenses-${product.slot}-adapter</outputDirectory>
+            <excludes>
+                <exclude>licenses.xml</exclude>
+            </excludes>
         </fileSet>
         <fileSet>
             <directory>target/licenses</directory>
diff --git a/distribution/adapters/fuse-adapter-zip/pom.xml b/distribution/adapters/fuse-adapter-zip/pom.xml
index a6950c3..fdb345a 100644
--- a/distribution/adapters/fuse-adapter-zip/pom.xml
+++ b/distribution/adapters/fuse-adapter-zip/pom.xml
@@ -168,35 +168,9 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- License Data -->
             <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-copy-common</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.gmaven</groupId>
-                <artifactId>groovy-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-append-product</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>xml-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-generate-html</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
+                <groupId>org.keycloak</groupId>
+                <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
diff --git a/distribution/adapters/js-adapter-zip/assembly.xml b/distribution/adapters/js-adapter-zip/assembly.xml
index e30752e..01d555b 100755
--- a/distribution/adapters/js-adapter-zip/assembly.xml
+++ b/distribution/adapters/js-adapter-zip/assembly.xml
@@ -39,6 +39,9 @@
         <fileSet>
             <directory>src/main/resources/licenses/${product.slot}</directory>
             <outputDirectory>docs/licenses-${product.slot}-adapter</outputDirectory>
+            <excludes>
+                <exclude>licenses.xml</exclude>
+            </excludes>
         </fileSet>
         <fileSet>
             <directory>target/licenses</directory>
diff --git a/distribution/adapters/js-adapter-zip/pom.xml b/distribution/adapters/js-adapter-zip/pom.xml
index ebab869..67f6769 100755
--- a/distribution/adapters/js-adapter-zip/pom.xml
+++ b/distribution/adapters/js-adapter-zip/pom.xml
@@ -83,35 +83,9 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- License Data -->
             <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-copy-common</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.gmaven</groupId>
-                <artifactId>groovy-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-append-product</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>xml-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-generate-html</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
+                <groupId>org.keycloak</groupId>
+                <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
diff --git a/distribution/adapters/wildfly-adapter/assembly.xml b/distribution/adapters/wildfly-adapter/assembly.xml
index 5f06462..69b8728 100755
--- a/distribution/adapters/wildfly-adapter/assembly.xml
+++ b/distribution/adapters/wildfly-adapter/assembly.xml
@@ -70,6 +70,9 @@
         <fileSet>
             <directory>src/main/resources/licenses/${product.slot}</directory>
             <outputDirectory>docs/licenses-${product.slot}-adapter</outputDirectory>
+            <excludes>
+                <exclude>licenses.xml</exclude>
+            </excludes>
         </fileSet>
         <fileSet>
             <directory>target/licenses</directory>
diff --git a/distribution/adapters/wildfly-adapter/pom.xml b/distribution/adapters/wildfly-adapter/pom.xml
index edf58f1..68c15cf 100644
--- a/distribution/adapters/wildfly-adapter/pom.xml
+++ b/distribution/adapters/wildfly-adapter/pom.xml
@@ -80,35 +80,9 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- License Data -->
             <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-copy-common</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.gmaven</groupId>
-                <artifactId>groovy-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-append-product</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>xml-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-generate-html</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
+                <groupId>org.keycloak</groupId>
+                <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
diff --git a/distribution/feature-packs/server-feature-pack/assembly.xml b/distribution/feature-packs/server-feature-pack/assembly.xml
index e18d383..c933938 100644
--- a/distribution/feature-packs/server-feature-pack/assembly.xml
+++ b/distribution/feature-packs/server-feature-pack/assembly.xml
@@ -60,6 +60,9 @@
         <fileSet>
             <directory>src/main/resources/licenses/${product.slot}</directory>
             <outputDirectory>content/docs/licenses-${product.slot}</outputDirectory>
+            <excludes>
+                <exclude>licenses.xml</exclude>
+            </excludes>
         </fileSet>
         <fileSet>
             <directory>target/licenses</directory>
diff --git a/distribution/feature-packs/server-feature-pack/pom.xml b/distribution/feature-packs/server-feature-pack/pom.xml
index f306277..73f7da9 100644
--- a/distribution/feature-packs/server-feature-pack/pom.xml
+++ b/distribution/feature-packs/server-feature-pack/pom.xml
@@ -767,38 +767,9 @@
                 </executions>
             </plugin>
 
-            <!-- License Data -->
-
-            <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-copy-common</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-
             <plugin>
-                <groupId>org.codehaus.gmaven</groupId>
-                <artifactId>groovy-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-append-product</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>xml-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-generate-html</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
+                <groupId>org.keycloak</groupId>
+                <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
diff --git a/distribution/licenses-common/assembly.xml b/distribution/licenses-common/assembly.xml
new file mode 100644
index 0000000..55ec809
--- /dev/null
+++ b/distribution/licenses-common/assembly.xml
@@ -0,0 +1,45 @@
+<!--
+  ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
+  ~ and other contributors as indicated by the @author tags.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<assembly>
+    <id>licenses-common</id>
+
+    <formats>
+        <format>zip</format>
+    </formats>
+
+    <baseDirectory>${artifactId}</baseDirectory>
+
+    <fileSets>
+        <fileSet>
+            <directory>src/main/resources</directory>
+            <outputDirectory/>
+            <includes>
+                <include>**</include>
+            </includes>
+        </fileSet>
+    </fileSets>
+
+    <files>
+        <file>
+            <source>../../License.html</source>
+            <destName>keycloak-components-license.html</destName>
+            <fileMode>0664</fileMode>
+        </file>
+    </files>
+
+</assembly>
diff --git a/distribution/licenses-common/pom.xml b/distribution/licenses-common/pom.xml
new file mode 100644
index 0000000..fdac51f
--- /dev/null
+++ b/distribution/licenses-common/pom.xml
@@ -0,0 +1,46 @@
+<!--
+  ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
+  ~ and other contributors as indicated by the @author tags.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>keycloak-distribution-parent</artifactId>
+        <groupId>org.keycloak</groupId>
+        <version>3.4.1.Final-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>keycloak-distribution-licenses-common</artifactId>
+    <packaging>jar</packaging>
+    <name>Keycloak Distribution Licenses Common</name>
+
+    <build>
+        <resources>
+            <resource>
+                <targetPath>keycloak-licenses-common</targetPath>
+                <directory>../../</directory>
+                <includes>
+                    <include>License.html</include>
+                </includes>
+            </resource>
+            <resource>
+                <targetPath>keycloak-licenses-common</targetPath>
+                <directory>src/main/resources</directory>
+            </resource>
+        </resources>
+    </build>
+
+</project>
diff --git a/distribution/maven-plugins/licenses-processor/pom.xml b/distribution/maven-plugins/licenses-processor/pom.xml
new file mode 100644
index 0000000..02ceaa0
--- /dev/null
+++ b/distribution/maven-plugins/licenses-processor/pom.xml
@@ -0,0 +1,53 @@
+<!--
+  ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
+  ~ and other contributors as indicated by the @author tags.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>keycloak-distribution-maven-plugins-parent</artifactId>
+        <groupId>org.keycloak</groupId>
+        <version>3.4.1.Final-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
+    <packaging>maven-plugin</packaging>
+    <name>Keycloak Licenses Processor Maven Plugin</name>
+    <description>Performs multiple operations on a license xml to produce release-ready files</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.keycloak</groupId>
+            <artifactId>keycloak-distribution-licenses-common</artifactId>
+            <version>${project.version}</version>
+            <scope>runtime</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.gmavenplus</groupId>
+                <artifactId>gmavenplus-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-plugin-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/distribution/maven-plugins/licenses-processor/src/main/groovy/LicenseProcessMojo.groovy b/distribution/maven-plugins/licenses-processor/src/main/groovy/LicenseProcessMojo.groovy
new file mode 100644
index 0000000..d015d4a
--- /dev/null
+++ b/distribution/maven-plugins/licenses-processor/src/main/groovy/LicenseProcessMojo.groovy
@@ -0,0 +1,124 @@
+import java.nio.file.FileSystem
+import java.nio.file.FileSystems
+import java.nio.file.Files
+import java.nio.file.Path
+import java.nio.file.StandardCopyOption
+import java.nio.file.attribute.PosixFilePermissions
+import javax.xml.transform.Transformer
+import javax.xml.transform.TransformerFactory
+import javax.xml.transform.stream.StreamResult
+import javax.xml.transform.stream.StreamSource
+
+import org.apache.maven.plugin.AbstractMojo
+import org.apache.maven.plugins.annotations.LifecyclePhase
+import org.apache.maven.plugins.annotations.Mojo
+import org.apache.maven.plugins.annotations.Parameter
+import org.apache.maven.project.MavenProject
+
+import groovy.xml.XmlUtil
+
+@Mojo(name="process", defaultPhase=LifecyclePhase.PROCESS_RESOURCES)
+class LicenseProcessMojo extends AbstractMojo {
+
+    @Parameter(defaultValue='${project}', readonly=true)
+    private MavenProject project
+
+    void execute() {
+        FileSystem fs = FileSystems.default
+
+        // Property configuration with defaults
+        def outputDirectoryRaw = project.properties['outputDirectory'] ?: "${project.build.directory}/licenses"
+        def xmlFileSource = project.properties['xmlFileSource'] ?: "${project.basedir}/src/main/resources/licenses/${project.properties['product.slot']}/licenses.xml"
+        def licenseName = project.properties['licenseName'] ?: "Apache Software License 2.0"
+        def licenseUrl = project.properties['licenseUrl'] ?: "https://raw.githubusercontent.com/keycloak/keycloak/${project.version}/License.html"
+        def groupId = project.properties['groupId'] ?: "org.keycloak"
+
+        Path outputDirectory = fs.getPath(outputDirectoryRaw)
+        Files.createDirectories(outputDirectory)
+
+        // Load license data XML for modification
+        Path licensesXmlFile = fs.getPath(xmlFileSource)
+        Node root = new XmlParser().parse(licensesXmlFile.toFile())
+        Node dependencies = root.dependencies[0]
+
+        // For each direct dependency, append those matching the groupId filter
+        log.info("Appending first party dependency license data")
+        Path licenseFileRoot = outputDirectory
+        Path licenseFile = null
+        def matched = false
+        project.dependencyArtifacts.toSorted().each { artifact ->
+            if (artifact.groupId == groupId) {
+                matched = true
+
+                def dependency = dependencies.appendNode('dependency')
+                dependency.appendNode('groupId', artifact.groupId)
+                dependency.appendNode('artifactId', artifact.artifactId)
+                dependency.appendNode('version', artifact.version)
+                def licenses = dependency.appendNode('licenses')
+                def license = licenses.appendNode('license')
+                license.appendNode('name', licenseName)
+                license.appendNode('url', licenseUrl)
+
+                def newFilename = "${artifact.groupId},${artifact.artifactId},${artifact.version},${licenseName}.txt"
+                Path newFile = licenseFileRoot.resolve(newFilename)
+                if (licenseFile == null) {
+                    log.info("==> ${newFilename}")
+                    InputStream original = this.class.getResourceAsStream("keycloak-licenses-common/License.html")
+                    Files.copy(original, newFile, StandardCopyOption.REPLACE_EXISTING)
+                    licenseFile = newFile
+                } else {
+                    log.info("  -> ${newFilename}")
+                    try {
+                        Files.createSymbolicLink(newFile, licenseFile.fileName);
+                    } catch ( IOException e ) {
+                        log.debug("Can't create symbolic link, assuming due to lack of OS support")
+                        // Assume we're on Windows and the user doesn't have
+                        // SeCreateSymbolicLinkPrivilege and/or NTFS. Fallback to
+                        // writing something similar to what git would with
+                        // core.symlinks disabled.
+                        newFile.withWriter('utf-8') { writer ->
+                            writer.writeLine licenseFile.fileName.toString()
+                        }
+                    }
+                }
+            }
+        }
+        if (!matched) {
+            fail("No project direct dependencies matched groupId ${groupId}")
+        }
+
+        // Write out XML with appended data to new path
+        Path outputLicensesXmlFile = outputDirectory.resolve("licenses.xml")
+        log.info("Writing XML to ${outputLicensesXmlFile}")
+        outputLicensesXmlFile.withWriter("utf-8") { writer ->
+            XmlUtil.serialize(root, writer)
+        }
+
+        // Copy misc. files from the resource jar
+        ["licenses.xsl", "licenses.css"].each { filename ->
+            InputStream input = this.class.getResourceAsStream("keycloak-licenses-common/${filename}")
+            Path out = outputDirectory.resolve(filename)
+            Files.copy(input, out, StandardCopyOption.REPLACE_EXISTING)
+        }
+
+        // Generate HTML by applying XSLT to XML. Have to switch to the Java
+        // libraries for XSLT support.
+        Path outputHtmlFile = outputDirectory.resolve("licenses.html")
+        log.info("Writing transformed HTML to ${outputHtmlFile}")
+        Transformer transformer
+        L:{
+            InputStream input = this.class.getResourceAsStream("keycloak-licenses-common/licenses.xsl")
+            transformer = TransformerFactory.newInstance().newTemplates(new StreamSource(input)).newTransformer()
+        }
+        transformer.setParameter("productname", project.properties['product.name.full'])
+        transformer.setParameter("version", project.version)
+        outputLicensesXmlFile.withInputStream() { inStream ->
+            def input = new StreamSource(inStream)
+            outputHtmlFile.withOutputStream() { outStream ->
+                def out = new StreamResult(outStream)
+                transformer.transform(input, out)
+            }
+        }
+    }
+
+}
diff --git a/distribution/maven-plugins/pom.xml b/distribution/maven-plugins/pom.xml
new file mode 100644
index 0000000..5b4e38b
--- /dev/null
+++ b/distribution/maven-plugins/pom.xml
@@ -0,0 +1,105 @@
+<!--
+  ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
+  ~ and other contributors as indicated by the @author tags.
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~ http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <artifactId>keycloak-distribution-parent</artifactId>
+        <groupId>org.keycloak</groupId>
+        <version>3.4.1.Final-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>keycloak-distribution-maven-plugins-parent</artifactId>
+    <packaging>pom</packaging>
+    <name>Keycloak Distribution Maven Plugins Parent</name>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.codehaus.groovy</groupId>
+            <artifactId>groovy-all</artifactId>
+            <version>2.4.12</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>3.3.9</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-core</artifactId>
+            <version>3.3.9</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.plugin-tools</groupId>
+            <artifactId>maven-plugin-annotations</artifactId>
+            <version>3.4</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <modules>
+        <module>licenses-processor</module>
+    </modules>
+
+    <build>
+        <pluginManagement>
+            <plugins>
+                <plugin>
+                    <groupId>org.codehaus.gmavenplus</groupId>
+                    <artifactId>gmavenplus-plugin</artifactId>
+                    <version>1.6</version>
+                    <executions>
+                        <execution>
+                            <id>compile-groovy</id>
+                            <goals>
+                                <goal>addSources</goal>
+                                <goal>addTestSources</goal>
+                                <goal>generateStubs</goal>
+                                <goal>compile</goal>
+                                <goal>removeStubs</goal>
+                                <goal>generateTestStubs</goal>
+                                <goal>compileTests</goal>
+                                <goal>removeTestStubs</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+                <plugin>
+                    <groupId>org.apache.maven.plugins</groupId>
+                    <artifactId>maven-plugin-plugin</artifactId>
+                    <executions>
+                        <execution>
+                            <id>generate-descriptor</id>
+                            <goals>
+                                <goal>descriptor</goal>
+                            </goals>
+                        </execution>
+                        <execution>
+                            <id>generate-help</id>
+                            <goals>
+                                <goal>helpmojo</goal>
+                            </goals>
+                        </execution>
+                    </executions>
+                </plugin>
+            </plugins>
+        </pluginManagement>
+    </build>
+
+</project>
diff --git a/distribution/pom.xml b/distribution/pom.xml
index 6be6ce8..ba73b2a 100755
--- a/distribution/pom.xml
+++ b/distribution/pom.xml
@@ -39,6 +39,8 @@
         <module>adapters</module>
         <module>saml-adapters</module>
         <module>feature-packs</module>
+        <module>licenses-common</module>
+        <module>maven-plugins</module>
         <module>server-dist</module>
         <module>server-overlay</module>
     </modules>
diff --git a/distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/assembly.xml b/distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/assembly.xml
index 8e1e5d0..ed16317 100755
--- a/distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/assembly.xml
+++ b/distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/assembly.xml
@@ -49,6 +49,9 @@
         <fileSet>
             <directory>src/main/resources/licenses/${product.slot}</directory>
             <outputDirectory>docs/licenses-${product.slot}-adapter</outputDirectory>
+            <excludes>
+                <exclude>licenses.xml</exclude>
+            </excludes>
         </fileSet>
         <fileSet>
             <directory>target/licenses</directory>
diff --git a/distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/pom.xml b/distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/pom.xml
index 04624c3..660b9b7 100755
--- a/distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/pom.xml
+++ b/distribution/saml-adapters/as7-eap6-adapter/eap6-adapter-zip/pom.xml
@@ -90,35 +90,9 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- License Data -->
             <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-copy-common</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.gmaven</groupId>
-                <artifactId>groovy-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-append-product</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>xml-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-generate-html</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
+                <groupId>org.keycloak</groupId>
+                <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/assembly.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/assembly.xml
index 9ff9e62..41ffac3 100755
--- a/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/assembly.xml
+++ b/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/assembly.xml
@@ -50,6 +50,9 @@
         <fileSet>
             <directory>src/main/resources/licenses/${product.slot}</directory>
             <outputDirectory>docs/licenses-${product.slot}-adapter</outputDirectory>
+            <excludes>
+                <exclude>licenses.xml</exclude>
+            </excludes>
         </fileSet>
         <fileSet>
             <directory>target/licenses</directory>
diff --git a/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/pom.xml b/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/pom.xml
index 1bb3912..d8317bc 100755
--- a/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/pom.xml
+++ b/distribution/saml-adapters/wildfly-adapter/wildfly-adapter-zip/pom.xml
@@ -87,35 +87,9 @@
                     </execution>
                 </executions>
             </plugin>
-            <!-- License Data -->
             <plugin>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-copy-common</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.gmaven</groupId>
-                <artifactId>groovy-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-append-product</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>xml-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>licenses-generate-html</id>
-                        <phase>process-resources</phase>
-                    </execution>
-                </executions>
+                <groupId>org.keycloak</groupId>
+                <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
             </plugin>
         </plugins>
     </build>
diff --git a/misc/DependencyLicenseInformation.md b/misc/DependencyLicenseInformation.md
index 8a5ce1b..404e964 100644
--- a/misc/DependencyLicenseInformation.md
+++ b/misc/DependencyLicenseInformation.md
@@ -84,7 +84,7 @@ After modifying a license XML, you must run `download-license-files.sh` against 
 Example command line:
 
 ```
-$ common/download-license-files.sh rh-sso/licenses.xml
+$ distribution/licenses-common/download-license-files.sh distribution/feature-packs/server-feature-pack/src/main/resources/licenses/rh-sso/licenses.xml
 ```
 
 The following shell commands must be available for the script to work:

pom.xml 107(+6 -101)

diff --git a/pom.xml b/pom.xml
index 29e4feb..62065df 100755
--- a/pom.xml
+++ b/pom.xml
@@ -1535,112 +1535,17 @@
                     <artifactId>frontend-maven-plugin</artifactId>
                     <version>${frontend.plugin.version}</version>
                 </plugin>
-                <!-- License Data -->
                 <plugin>
-                    <artifactId>maven-resources-plugin</artifactId>
+                    <groupId>org.keycloak</groupId>
+                    <artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
+                    <version>${project.version}</version>
                     <executions>
                         <execution>
-                            <id>licenses-copy-common</id>
+                            <id>process-licenses</id>
                             <goals>
-                                <goal>copy-resources</goal>
+                                <goal>process</goal>
                             </goals>
-                            <!-- When needed in a child pom, bind to process-resources phase -->
-                            <phase>none</phase>
-                            <configuration>
-                                <outputDirectory>${project.build.directory}/licenses</outputDirectory>
-                                <resources>
-                                    <!-- Commmon -->
-                                    <resource>
-                                        <directory>${project.basedir}/src/main/resources/licenses/common</directory>
-                                        <includes>
-                                            <include>licenses.xsl</include>
-                                            <include>licenses.css</include>
-                                        </includes>
-                                    </resource>
-                                    <!-- Slot-specific XML -->
-                                    <resource>
-                                        <directory>${project.basedir}/src/main/resources/licenses/${product.slot}</directory>
-                                        <includes>
-                                            <include>licenses.xml</include>
-                                            <!-- Do not use maven-resources-plugin to copy symlinks! -->
-                                        </includes>
-                                    </resource>
-                                </resources>
-                            </configuration>
-                        </execution>
-                    </executions>
-                </plugin>
-                <plugin>
-                    <groupId>org.codehaus.gmaven</groupId>
-                    <artifactId>groovy-maven-plugin</artifactId>
-                    <version>2.0</version>
-                    <dependencies>
-                        <dependency>
-                            <groupId>org.codehaus.groovy</groupId>
-                            <artifactId>groovy-all</artifactId>
-                            <version>2.4.12</version>
-                        </dependency>
-                    </dependencies>
-                    <executions>
-                        <execution>
-                            <id>licenses-append-product</id>
-                            <goals>
-                                <goal>execute</goal>
-                            </goals>
-                            <!-- When needed in a child pom, bind to process-resources phase -->
-                            <phase>none</phase>
-                            <configuration>
-                                <source>${project.basedir}/src/main/resources/licenses/common/append-product-licenses.groovy</source>
-                                <properties>
-                                    <groupId>org.keycloak</groupId>
-                                    <xmlFile>${project.build.directory}/licenses/licenses.xml</xmlFile>
-                                    <licenseName>Apache Software License 2.0</licenseName>
-                                    <licenseUrl>https://raw.githubusercontent.com/keycloak/keycloak/${project.version}/License.html</licenseUrl>
-                                    <licenseFile>${project.basedir}/src/main/resources/licenses/common/keycloak-components-license.html</licenseFile>
-                                </properties>
-                            </configuration>
-                        </execution>
-                    </executions>
-                </plugin>
-                <plugin>
-                    <groupId>org.codehaus.mojo</groupId>
-                    <artifactId>xml-maven-plugin</artifactId>
-                    <version>1.0.1</version>
-                    <executions>
-                        <execution>
-                            <id>licenses-generate-html</id>
-                            <goals>
-                                <goal>transform</goal>
-                            </goals>
-                            <!-- When needed in a child pom, bind to process-resources phase -->
-                            <phase>none</phase>
-                            <configuration>
-                                <transformationSets>
-                                    <transformationSet>
-                                        <dir>${project.build.directory}/licenses</dir>
-                                        <includes>
-                                            <include>licenses.xml</include>
-                                        </includes>
-                                        <stylesheet>${project.build.directory}/licenses/licenses.xsl</stylesheet>
-                                        <outputDir>${project.build.directory}/licenses</outputDir>
-                                        <fileMappers>
-                                            <fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
-                                                <targetExtension>.html</targetExtension>
-                                            </fileMapper>
-                                        </fileMappers>
-                                        <parameters>
-                                            <parameter>
-                                                <name>productname</name>
-                                                <value>${product.name.full}</value>
-                                            </parameter>
-                                            <parameter>
-                                                <name>version</name>
-                                                <value>${project.version}</value>
-                                            </parameter>
-                                        </parameters>
-                                    </transformationSet>
-                                </transformationSets>
-                            </configuration>
+                            <phase>process-resources</phase>
                         </execution>
                     </executions>
                 </plugin>