-
Notifications
You must be signed in to change notification settings - Fork 16
/
license-third-party.ftl
107 lines (89 loc) · 3.3 KB
/
license-third-party.ftl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<#function artifactFormat p>
<#-- Declare missingLicenses[] and missingLicenseUrls[] -->
<#assign missingLicenses = [
["asm:asm", "BSD 3-Clause"],
["asm:asm-commons", "BSD 3-Clause"],
["asm:asm-tree", "BSD 3-Clause"],
["com.cenqua.shaj:shaj", "Apache 2.0"],
["commons-codec:commons-codec", "Apache 2.0"],
["cglib:cglib-nodep", "Apache 2.0"],
["javax.servlet:jstl", "CDDL 1.1 / GPL 2.0"],
["jdom:jdom", "Apache 2.0"],
["nekohtml:nekohtml", "Apache 2.0"],
["org.antlr:antlr-runtime", "BSD 3-Clause"],
["org.eclipse.mylyn.github:org.eclipse.egit.github.core", "Eclipse Public License 1.0"],
["oro:oro", "Apache 2.0"]
]/>
<#assign missingLicenseUrls = [
["Apache 2.0", "https://www.apache.org/licenses/LICENSE-2.0.txt"],
["BSD 3-Clause", "https://asm.ow2.io/license.html"],
["CDDL 1.1 / GPL 2.0", "https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html"],
["Eclipse Public License 1.0", "http://www.eclipse.org/legal/epl-v10.html"]
]/>
<#assign result = ""/>
<#-- Fill in missing license names and urls from missingLicenses[] and missingLicenseUrls[] -->
<#if p.licenses?size == 0>
<#assign licenseName = ""/>
<#assign licenseUrl = ""/>
<#list missingLicenses as l1>
<#if l1[0] == "${p.groupId}:${p.artifactId}">
<#assign licenseName = l1[1]/>
<#list missingLicenseUrls as l2>
<#if l1[1] == l2[0]>
<#assign licenseUrl = l2[1]/>
</#if>
</#list>
</#if>
</#list>
<#assign result>
${result}
{
"name": "${p.groupId!""}:${p.artifactId!""}",
"version": "${p.version!""}",
"url": "${p.url!""}",
"license": "${licenseName!""}",
"licenseUrl": "${licenseUrl!""}"
},
</#assign>
<#else>
<#-- Iterate on automatically detected licenses -->
<#list p.licenses as l>
<#assign licenseName = ""/>
<#assign licenseUrl = ""/>
<#-- Divide license by new lines, because one l.name can store several licenses -->
<#assign siblingLicenses = (l.name)?split("\n")>
<#assign siblingLicenseUrls = (l.url!"")?split("\n")>
<#list siblingLicenses as siblingLicense>
<#assign licenseName = siblingLicense?trim/>
<#assign licenseUrl = siblingLicenseUrls[siblingLicense?index]?trim/>
<#if licenseName?ends_with(" and")>
<#assign licenseName = licenseName?substring(0, licenseName?length - 4)>
</#if>
<#if licenseUrl?ends_with(" and")>
<#assign licenseUrl = licenseUrl?substring(0, licenseUrl?length - 4)>
</#if>
<#assign result>
${result}
{
"name": "${p.groupId!""}:${p.artifactId!""}",
"version": "${p.version!""}",
"url": "${p.url!""}",
"license": "${licenseName!""}",
"licenseUrl": "${licenseUrl!""}"
},
</#assign>
</#list>
</#list>
</#if>
<#return result>
</#function>
<#if dependencyMap?size == 0>
<#else>
[
<#list dependencyMap as e>
<#assign project = e.getKey()/>
<#assign licenses = e.getValue()/>
${artifactFormat(project)}
</#list>
]
</#if>