KEYCLOAK-5843 Add custom license processing plugin to avoid directory symlinks (#4723)
Symlinks are frequently unavailable on Windows (must be on NTFS and user must have SeCreateSymbolicLinkPrivilege). Removing the symlinks for licenses/common/ should enable the build to function mostly normally on Windows. The individual license files will be incorrect, but that shouldn't matter for local builds. Release builds are done on *nix. The plugin rolls several different plugin executions into one. The common files are distributed using a resource jar, used by and unpacked by the plugin.
This commit is contained in:
parent
a8bcdfb401
commit
c860ca61c3
33 changed files with 417 additions and 368 deletions
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../feature-packs/server-feature-pack/src/main/resources/licenses/common
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../feature-packs/server-feature-pack/src/main/resources/licenses/common
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../feature-packs/server-feature-pack/src/main/resources/licenses/common
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../feature-packs/server-feature-pack/src/main/resources/licenses/common
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1,60 +0,0 @@
|
|||
import java.nio.file.FileSystem
|
||||
import java.nio.file.FileSystems
|
||||
import java.nio.file.Files
|
||||
import java.nio.file.Path
|
||||
import java.nio.file.attribute.PosixFilePermissions
|
||||
|
||||
import groovy.xml.XmlUtil
|
||||
|
||||
// Insert nodes into the xml file for the filtered dependencies in the active
|
||||
// maven project. Also create individual license files for the new xml nodes,
|
||||
// by copying one full copy, and symlinks to that copy for the rest.
|
||||
|
||||
FileSystem fs = FileSystems.default
|
||||
|
||||
Path licensesXmlFile = fs.getPath(properties['xmlFile'])
|
||||
log.info("File ${properties['licenseFile']} will be copied for use as common individual license file")
|
||||
Node root = new XmlParser().parse(licensesXmlFile.toFile())
|
||||
Node dependencies = root.dependencies[0]
|
||||
|
||||
Path licenseFileRoot = licensesXmlFile.parent
|
||||
Path licenseFile = null
|
||||
|
||||
def matched = false
|
||||
session.currentProject.dependencyArtifacts.toSorted().each { artifact ->
|
||||
if (artifact.groupId == properties['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', properties['licenseName'])
|
||||
license.appendNode('url', properties['licenseUrl'])
|
||||
|
||||
def newFilename = "${artifact.groupId},${artifact.artifactId},${artifact.version},${properties['licenseName']}.txt"
|
||||
Path newFile = licenseFileRoot.resolve(newFilename)
|
||||
if (licenseFile == null) {
|
||||
log.info("==> ${newFilename}")
|
||||
Path original = fs.getPath(properties['licenseFile'])
|
||||
Files.copy(original, newFile)
|
||||
// Drop any weird mode setting the original file might have
|
||||
Files.setPosixFilePermissions(newFile, PosixFilePermissions.fromString("rw-rw-r--"))
|
||||
licenseFile = newFile
|
||||
} else {
|
||||
log.info(" -> ${newFilename}")
|
||||
Files.createSymbolicLink(newFile, licenseFile.fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!matched) {
|
||||
fail("No project direct dependencies matched groupId ${properties['groupId']}")
|
||||
}
|
||||
|
||||
log.info("Updating XML ${properties['xmlFile']}")
|
||||
licensesXmlFile.withWriter("utf-8") { writer ->
|
||||
XmlUtil.serialize(root, writer)
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../../License.html
|
45
distribution/licenses-common/assembly.xml
Normal file
45
distribution/licenses-common/assembly.xml
Normal file
|
@ -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>
|
46
distribution/licenses-common/pom.xml
Normal file
46
distribution/licenses-common/pom.xml
Normal file
|
@ -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>
|
53
distribution/maven-plugins/licenses-processor/pom.xml
Normal file
53
distribution/maven-plugins/licenses-processor/pom.xml
Normal file
|
@ -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>
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
105
distribution/maven-plugins/pom.xml
Normal file
105
distribution/maven-plugins/pom.xml
Normal file
|
@ -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>
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../feature-packs/server-feature-pack/src/main/resources/licenses/common
|
|
@ -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>
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
../../../../../../../feature-packs/server-feature-pack/src/main/resources/licenses/common
|
|
@ -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:
|
||||
|
|
105
pom.xml
105
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>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>licenses-copy-common</id>
|
||||
<goals>
|
||||
<goal>copy-resources</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>
|
||||
<artifactId>keycloak-distribution-licenses-maven-plugin</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>licenses-generate-html</id>
|
||||
<id>process-licenses</id>
|
||||
<goals>
|
||||
<goal>transform</goal>
|
||||
<goal>process</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>
|
||||
|
|
Loading…
Reference in a new issue