license-maven-plugin 第三方许可 FreeMarker 模板中需要哪些数据?
What data to expect in license-maven-plugin third party license FreeMarker template?
我将 Mojo License Maven plugin to generate a list of third party licenses. According to the documentation I could use a custom FreeMarker template to format the file using the fileTemplate
parameter, but there is no documentation on the data that will be passed to the FreeMarker template. There is a link on the examples page 用于现有模板,但 link 已损坏。
经过一番搜索,我找到了 template on GitHub:
...
<#-- To render the third-party file.
Available context :
- dependencyMap a collection of Map.Entry with
key are dependencies (as a MavenProject) (from the maven project)
values are licenses of each dependency (array of string)
- licenseMap a collection of Map.Entry with
key are licenses of each dependency (array of string)
values are all dependencies using this license
-->
<#function licenseFormat licenses>
<#assign result = ""/>
<#list licenses as license>
<#assign result = result + " (" +license + ")"/>
</#list>
<#return result>
</#function>
<#function artifactFormat p>
<#if p.name?index_of('Unnamed') > -1>
<#return p.artifactId + " (" + p.groupId + ":" + p.artifactId + ":" + p.version + " - " + (p.url!"no url defined") + ")">
<#else>
<#return p.name + " (" + p.groupId + ":" + p.artifactId + ":" + p.version + " - " + (p.url!"no url defined") + ")">
</#if>
</#function>
<#if dependencyMap?size == 0>
The project has no dependencies.
<#else>
Lists of ${dependencyMap?size} third-party dependencies.
<#list dependencyMap as e>
<#assign project = e.getKey()/>
<#assign licenses = e.getValue()/>
${licenseFormat(licenses)} ${artifactFormat(project)}
</#list>
</#if>
它使用这个LicenseMap
我将 Mojo License Maven plugin to generate a list of third party licenses. According to the documentation I could use a custom FreeMarker template to format the file using the fileTemplate
parameter, but there is no documentation on the data that will be passed to the FreeMarker template. There is a link on the examples page 用于现有模板,但 link 已损坏。
经过一番搜索,我找到了 template on GitHub:
...
<#-- To render the third-party file.
Available context :
- dependencyMap a collection of Map.Entry with
key are dependencies (as a MavenProject) (from the maven project)
values are licenses of each dependency (array of string)
- licenseMap a collection of Map.Entry with
key are licenses of each dependency (array of string)
values are all dependencies using this license
-->
<#function licenseFormat licenses>
<#assign result = ""/>
<#list licenses as license>
<#assign result = result + " (" +license + ")"/>
</#list>
<#return result>
</#function>
<#function artifactFormat p>
<#if p.name?index_of('Unnamed') > -1>
<#return p.artifactId + " (" + p.groupId + ":" + p.artifactId + ":" + p.version + " - " + (p.url!"no url defined") + ")">
<#else>
<#return p.name + " (" + p.groupId + ":" + p.artifactId + ":" + p.version + " - " + (p.url!"no url defined") + ")">
</#if>
</#function>
<#if dependencyMap?size == 0>
The project has no dependencies.
<#else>
Lists of ${dependencyMap?size} third-party dependencies.
<#list dependencyMap as e>
<#assign project = e.getKey()/>
<#assign licenses = e.getValue()/>
${licenseFormat(licenses)} ${artifactFormat(project)}
</#list>
</#if>
它使用这个LicenseMap