forked from google/nomulus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dependency_lic.gradle
87 lines (80 loc) · 3.48 KB
/
dependency_lic.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
// Copyright 2019 The Nomulus Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
// Legacy-style declaration of the gradle-license-report plugin, which is necessary
// in shared scripts.
// Note that the 'apply plugin' line does not use string literal. It references directly the
// main class of the plugin.
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.github.jk1:gradle-license-report:2.0'
}
}
apply plugin: com.github.jk1.license.LicenseReportPlugin
// Configures the checkLicense task.
//
// This task discovers license information for each dependency including a
// name phrase and possibly additional details, such as an http link or relative
// path of a file in the jar. This information is saved in json format under
// build/reports/dependency-license. It is not used right now, but may be useful
// if we want to check the content of the licenses.
//
// The required 'allowedLicensesFile' contains the acceptable license name phrases.
// If a phrase not in this file is found, the checkLicense task will fail. Exact
// string match is used, so they are case-sensitive and preceding/trailing whitespaces are important.
//
// This plugin also generates an html report under build/reports/dependency-license.
// The optional 'filters' parameter accepts custom name-normalization rules. This
// report is not currently in use.
//
// Note that this task needs to be explicitly invoked on buildSrc.
//
// Also note that dependencies of buildscript classpath and 'official' Gradle plugins are
// not checked.
//
// Due to a bug/feature of this plugin, the Nomulus project can not lock all dependencies.
// The 'dependencyLicenseReport' configuration must be excluded from locking.
// TODO(weiminyu): add github issue number after reporting to author.
licenseReport {
ext.toFullFilePath = { relativePath ->
if (rootDir.path.endsWith('buildSrc')) {
return "${rootDir.path}/../${relativePath}"
}
return "${rootDir.path}/${relativePath}"
}
// Check licenses dependencies in all configurations. This does not include
// buildscript-classpath.
configurations = ALL
def configFolder = 'config/dependency-license'
allowedLicensesFile = file(toFullFilePath("${configFolder}/allowed_licenses.json"))
filters = new com.github.jk1.license.filter.LicenseBundleNormalizer(
bundlePath: toFullFilePath("${configFolder}/license_normalizer_bundle.json"),
createDefaultTransformationRules: false)
// The following dependency jars do not contain license info.
// Investigation results are documented inline.
excludes = [
// BSD: https://github.com/javacc/javacc/blob/master/LICENSE
'javacc:javacc',
// CDDL+GPL2.0 according to Maven Central:
// https://mvnrepository.com/artifact/javax.servlet/servlet-api/2.5
'javax.servlet:servlet-api',
// Presumed free since this is from Apache:
// http://www.apache.org/licenses/
'xerces:xmlParserAPIs'
]
}