Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WFLY-18398] Integrate license generation during provisioning #4

Merged
merged 1 commit into from Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions galleon-content/pom.xml
Expand Up @@ -44,15 +44,33 @@
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>wildfly-myfaces-injection</artifactId>
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

Expand Down
@@ -0,0 +1,7 @@
<?xml version="1.0" ?>
<config xmlns="urn:jboss:galleon:config:1.0" model="standalone">
<packages>
<package name="docs.licenses" optional="true"/>
</packages>
</config>

38 changes: 38 additions & 0 deletions galleon-content/src/main/resources/license/licenses.xml
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<licenseSummary>
<dependencies>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-api</artifactId>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
</dependency>
<dependency>
<groupId>org.apache.myfaces.core</groupId>
<artifactId>myfaces-impl</artifactId>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-myfaces-injection</artifactId>
<licenses>
<license>
<name>Apache License 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
</dependency>
</dependencies>
</licenseSummary>
@@ -0,0 +1,97 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output method="html" encoding="utf-8" standalone="no" media-type="text/html" />
<xsl:param name="version"/>
<xsl:param name="product.release.name"/>
<xsl:variable name="lowercase" select="'abcdefghijklmnopqrstuvwxyz '" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ!'" />

<xsl:template match="/">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" type="text/css" href="licenses.css"/>
</head>
<body>
<h2><xsl:value-of select="$product.release.name"/><xsl:text> </xsl:text><xsl:value-of select="substring-before($version, '-')"/></h2>
<p>The following material has been provided for informational purposes only, and should not be relied upon or construed as a legal opinion or legal advice.</p>
<!-- Read matching templates -->
<table>
<tr>
<th>Package Group</th>
<th>Package Artifact</th>
<th>Package Version</th>
<th>Remote Licenses</th>
<th>Local Licenses</th>
</tr>
<xsl:for-each select="licenseSummary/dependencies/dependency">
<xsl:sort select="concat(groupId, '.', artifactId)"/>
<xsl:variable name="GAV" select="concat(groupId, ':', artifactId, ':', version)"/>
<xsl:variable name="countOfPrevious" select="count(preceding-sibling::*[(concat(groupId, ':', artifactId, ':', version) = $GAV)])"/>
<xsl:if test="$countOfPrevious = 0">
<tr>
<td><xsl:value-of select="groupId"/></td>
<td><xsl:value-of select="artifactId"/></td>
<td><xsl:value-of select="version"/></td>
<td>
<xsl:for-each select="licenses/license">
<xsl:choose>
<xsl:when test="name = 'Public Domain'">
<xsl:value-of select="name"/><br/>
</xsl:when>
<xsl:otherwise>
<a href="{./url}"><xsl:value-of select="name"/></a><br/>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</td>
<td>
<xsl:for-each select="licenses/license">
<xsl:variable name="filename">
<xsl:call-template name="remap-local-filename">
<xsl:with-param name="name" select="name" />
</xsl:call-template>
</xsl:variable>
<a href="{$filename}"><xsl:value-of select="$filename"/></a><br/>
</xsl:for-each>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

<xsl:template name="remap-local-filename">
<xsl:param name="name"/>
<xsl:choose>
<xsl:when test="$name = 'BSD 2-clause &quot;Simplified&quot; License'">
<xsl:text>bsd 2-clause simplified license.html</xsl:text>
</xsl:when>
<xsl:when test="$name = 'BSD 3-Clause &quot;New&quot; or &quot;Revised&quot; License'">
<xsl:text>bsd 3-clause new or revised license.html</xsl:text>
</xsl:when>
<xsl:when test="$name = 'Creative Commons Attribution 2.5'">
<xsl:text>creative commons attribution 2.5.html</xsl:text>
</xsl:when>
<xsl:when test="$name = 'FSF All Permissive License'">
<xsl:text>fsf all permissive license.html</xsl:text>
</xsl:when>
<xsl:when test="$name = 'Indiana University Extreme! Lab Software License 1.1.1'">
<xsl:text>indiana university extreme lab software license 1.1.1.html</xsl:text>
</xsl:when>
<xsl:when test="$name = 'MIT-0'">
<xsl:text>mit-0.html</xsl:text>
</xsl:when>
<xsl:when test="$name = 'Mozilla Public License 2.0'">
<xsl:text>mozilla public license 2.0.html</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="concat(translate($name, $uppercase, $lowercase), '.txt')"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
@@ -0,0 +1,4 @@
<?xml version="1.0" ?>

<package-spec xmlns="urn:jboss:galleon:package:2.0" name="docs.licenses">
</package-spec>
@@ -0,0 +1,12 @@
<?xml version="1.0" ?>

<tasks xmlns="urn:wildfly:wildfly-feature-pack-tasks:3.1">
<copy-path src="docs/licenses/licenses.xsl" relative-to="content" target="docs/licenses/wildfly-myfaces-licenses.xsl"/>
<transform stylesheet="docs/licenses/wildfly-myfaces-licenses.xsl" src="docs/licenses/wildfly-myfaces-feature-pack-licenses.xml" output="docs/licenses/wildfly-myfaces-feature-pack-licenses.html" feature-pack-properties="true" phase="FINALIZING"/>
<delete path="docs/licenses/wildfly-myfaces-licenses.xsl"/>
<line-endings phase="FINALIZING">
<unix>
<filter pattern="docs?licenses?wildfly-myfaces-feature-pack-licenses.html" include="true"/>
</unix>
</line-endings>
</tasks>
47 changes: 47 additions & 0 deletions myfaces-feature-pack/pom.xml
Expand Up @@ -39,11 +39,18 @@
<groupId>org.wildfly</groupId>
<artifactId>wildfly-ee-galleon-pack</artifactId>
<type>zip</type>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

<properties>
<common.resources.directory>${basedir}/../galleon-content/src/main/resources</common.resources.directory>
<license.directory>${project.build.directory}/resources/packages/docs.licenses/content/docs/licenses</license.directory>
</properties>

<build>
Expand Down Expand Up @@ -78,6 +85,45 @@
</resources>
</configuration>
</execution>
<execution>
<id>copy-feature-pack-resources</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${basedir}/target/resources</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.wildfly.maven.plugins</groupId>
<artifactId>licenses-plugin</artifactId>
<version>2.3.1.Final</version>
<inherited>false</inherited>
<executions>
<execution>
<id>update-licenses-xml</id>
<goals>
<goal>insert-versions</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<generateVersionProperty>true</generateVersionProperty>
<sortByGroupIdAndArtifactId>true</sortByGroupIdAndArtifactId>
<licensesConfigFiles>
<licensesConfigFile>${basedir}/target/resources/license/licenses.xml</licensesConfigFile>
</licensesConfigFiles>
<licensesOutputFile>${license.directory}/wildfly-myfaces-feature-pack-licenses.xml</licensesOutputFile>
<excludedArtifacts>wildfly-ee-galleon-pack|wildfly-myfaces-feature-pack-galleon-content\z</excludedArtifacts>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
Expand All @@ -92,6 +138,7 @@
<phase>compile</phase>
<configuration>
<resources-dir>${basedir}/target/resources</resources-dir>
<release-name>WildFly MyFaces feature pack</release-name>
</configuration>
</execution>
</executions>
Expand Down