forked from Consensys/teku
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcheck-licenses.gradle
216 lines (206 loc) · 8.88 KB
/
check-licenses.gradle
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
/**
* Check that the licenses of our 3rd parties are in our acceptedLicenses list.
*
* run it with "gradle checkLicenses"
*
* To add new accepted licenses you need to update this script.
* Some products may be available with multiple licenses. In this case you must update
* this script to add it in the downloadLicenses#licenses.
*/
// Some parts of this code comes from Zipkin/https://github.com/openzipkin/zipkin/pull/852
// Zipkin itself is under Apache License.
/**
* The lists of the license we accept.
*/
ext.acceptedLicenses = [
'BSD License',
'BSD 2-Clause',
'BSD 3-Clause',
'The JSON License',
'Eclipse Distribution License - v 1.0',
'Eclipse Distribution License v. 1.0',
'EDL 1.0',
'Eclipse Public License - v 1.0',
'Eclipse Public License v1.0',
'Eclipse Public License - Version 1.0',
'Eclipse Public License 1.0',
'Eclipse Public License - v 2.0',
'MIT License',
'The MIT License (MIT)',
'Apache License, Version 2.0',
'Bouncy Castle Licence',
'Public Domain',
'Public Domain, per Creative Commons CC0',
'Mozilla Public License 1.0',
'Mozilla Public License Version 1.1',
'Mozilla Public License, Version 2.0',
'CC0',
'CC0 1.0 Universal License',
'Common Development and Distribution License 1.0',
'Unicode/ICU License',
]*.toLowerCase()
/**
* This is the configuration we need for our licenses plugin: 'com.github.hierynomus.license'
* This plugin generates a list of dependencies.
*/
downloadLicenses {
includeProjectDependencies = true
reportByDependency = false
reportByLicenseType = true
dependencyConfiguration = 'testCompile'
ext.apache = license('Apache License, Version 2.0', 'http://opensource.org/licenses/Apache-2.0')
ext.mit = license('MIT License', 'http://www.opensource.org/licenses/mit-license.php')
ext.bsd = license('BSD License', 'http://www.opensource.org/licenses/bsd-license.php')
ext.bsd3Clause = license('BSD 3-Clause', 'http://opensource.org/licenses/BSD-3-Clause')
ext.bsd2Clause = license('BSD 2-Clause', 'http://opensource.org/licenses/BSD-2-Clause')
ext.mpl = license('Mozilla Public License', 'http://www.mozilla.org/MPL')
ext.mpl1_1 = license('Mozilla Public License Version 1.1', 'http://www.mozilla.org/MPL/1.1/')
ext.mpl2_0 = license('Mozilla Public License, Version 2.0', 'http://www.mozilla.org/MPL/2.0/')
ext.cddl = license('Common Development and Distribution License 1.0', 'http://opensource.org/licenses/CDDL-1.0')
ext.cddl1_1 = license('Common Development and Distribution License 1.0', 'http://oss.oracle.com/licenses/CDDL-1.1')
ext.epl2_0 = license('Eclipse Public License - v 2.0', 'https://www.eclipse.org/legal/epl-2.0/')
ext.JSON = license('The JSON License', 'http://json.org/license.html')
aliases = [
(apache) : [
'Apache Software License - Version 2.0',
'Apache Software License, version 2.0',
'The Apache Software License, Version 2.0',
'The Apache Software License, version 2.0',
'Apache License Version 2.0',
'Apache License, Version 2.0',
'The Apache License, Version 2.0',
'Apache 2',
'Apache 2.0',
'Apache License 2.0',
'Apache-2.0',
license('Apache License', 'http://www.apache.org/licenses/LICENSE-2.0'),
license('Apache Software Licenses', 'http://www.apache.org/licenses/LICENSE-2.0.txt'),
license('Apache', 'http://www.opensource.org/licenses/Apache-2.0')
],
(JSON) : [
'The JSON License',
license('The JSON License', 'http://json.org/license.html')
],
(mit) : ['MIT','The MIT License'],
(bsd) : [
'BSD',
'BSD licence',
'The BSD License',
'Berkeley Software Distribution (BSD) License',
license('New BSD License', 'http://www.opensource.org/licenses/bsd-license.php')
],
(bsd3Clause): [
'3-Clause BSD License',
'BSD 3-Clause',
'BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)',
license('BSD 3-clause', 'http://opensource.org/licenses/BSD-3-Clause'),
license('BSD 3-Clause', 'http://www.scala-lang.org/license.html')
],
(bsd2Clause): [
'BSD 2-Clause',
'BSD-2-Clause',
'BSD 2-Clause "New" or "Revised" License (BSD-2-Clause)',
license('BSD 2-clause', 'http://opensource.org/licenses/BSD-2-Clause'),
license('BSD 2-Clause', 'http://www.scala-lang.org/license.html'),
'New BSD license'
],
(mpl): [
'MPL',
'Mozilla Public License',
'Mozilla Public License 1.0',
license('Mozilla Public License', 'http://www.mozilla.org/MPL')
],
(mpl1_1): [
'MPL 1.1',
'Mozilla Public License Version 1.1',
license('Mozilla Public License Version 1.1', 'http://www.mozilla.org/media/MPL/1.1/index.0c5913925d40.txt')
],
(mpl2_0): [
'Mozilla Public License, Version 2.0',
'MPL 2.0',
'Mozilla Public License Version 2.0',
license('Mozilla Public License 2.0', 'http://www.mozilla.org/media/MPL/2.0/index.815ca599c9df.txt')
],
(cddl): [
'CDDL',
'CDDL/GPLv2+CE',
'Common Development and Distribution License (CDDL) v1.0',
'Common Development and Distribution License 1.0',
'CDDL + GPLv2 with classpath exception',
'Dual license consisting of the CDDL v1.1 and GPL v2'
],
(cddl1_1): [
'CDDL 1.1',
'COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.1',
],
(epl2_0): [
'EPL 2.0',
'Eclipse Public License 2.0',
'Eclipse Public License - v 2.0',
'Eclipse Public License v2.0',
license('Eclipse Public License - v 2.0','https://www.eclipse.org/legal/epl-2.0/')
]
]
licenses = [
(group('teku')) : apache,
(group('teku.ethereum')) : apache,
(group('teku.services')) : apache,
(group('teku.consensus')) : apache,
(group('teku.data')) : apache,
(group('teku.infrastructure')) : apache,
(group('teku.storage')) : apache,
(group('teku.validator')) : apache,
(group('teku.networking')) : apache,
(group('com.fasterxml')) : apache,
// https://checkerframework.org/manual/#license
// The more permissive MIT License applies to code that you might want
// to include in your own program, such as the annotations and run-time utility classes.
(group('org.checkerframework')): mit,
// RocksDB is dual licensed under Apache v2.0 and GPL 2 licenses
// Explicitly declare that we are using the Apache v2.0 license
(group('org.rocksdb')): apache,
/// Explicilitly declare Apache 2.0 license for javassist
(group('org.javassist')): apache,
/// Explicilitly declare Apache 2.0 license for javassist
(group('javax.ws.rs')): cddl1_1,
(group('org.glassfish.jersey.core')): apache,
(group('org.glassfish.jersey.bundles.repackaged')): apache,
(group('org.glassfish.jersey.connectors')): apache,
// Explicitly declare jaxb-api as CDDL 1.1 - it's dual licensed with GPL2
'javax.xml.bind:jaxb-api:2.3.1': cddl1_1,
'javax.activation:javax.activation-api:1.2.0': cddl1_1,
//Explicitly declare EPL 2.0 for jnr-poxix - it is simultaneously licensed under 3 licenses.
'com.github.jnr:jnr-posix:3.0.33': epl2_0,
'com.github.jnr:jnr-posix:3.0.47': epl2_0,
(group('com.github.java-json-tools')): apache,
(group('com.github.fge')): apache,
//JMH-Core is licensed under GPLv2 with the Classpath Exception, which allows us to link it and license the derived work under our license.
'org.openjdk.jmh:jmh-core:1.21': apache,
(group('io.libp2p')): apache,
(group('tech.pegasys')): apache,
]
}
task checkLicenses {
description "Verify that all dependencies use white-listed licenses."
dependsOn ':downloadLicenses'
def bads = ""
doLast {
def xml = new XmlParser().parse("${rootProject.buildDir}/reports/license/license-dependency.xml")
xml.each { license ->
if (!acceptedLicenses.contains((license.@name).toLowerCase())) {
def depStrings = []
license.dependency.each { depStrings << it.text() }
bads = bads + depStrings + " => ${license.@name} \n"
}
}
if (bads != "") {
throw new GradleException("Some 3rd parties are using licenses not in our accepted licenses list:\n" +
bads +
"If it's a license acceptable for us, add it in the file check-licenses.gradle\n"+
"Be careful, some 3rd parties may accept multiple licenses.\n" +
"In this case, select the one you want to use by changing downloadLicenses.licenses\n"
)
}
}
}
check.dependsOn checkLicenses