2015-07-08 3 views
1

Я использую Mojo License Maven plugin для создания списка third party licenses. Согласно документации, я мог бы использовать собственный шаблон FreeMarker для форматирования файла с помощью fileTemplate parameter, но нет документации по данным, которые будут переданы шаблону FreeMarker. Существует ссылка на examples page на существующие шаблоны, но эта ссылка не работает.Какие данные можно ожидать в лицензии License-maven-plugin для сторонних разработчиков FreeMarker?

ответ

1

После некоторых поисков я нашел 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') &gt; -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