代码拉取完成,页面将自动刷新
A permissive license whose main conditions require preservation of copyright and license notices. Contributors provide an express grant of patent rights. Licensed works, modifications, and larger works may be distributed under different terms and without source code.
// All licenses that we accept, and their aliases
def allowList = [
[name: 'BSD-2-Clause', url: 'http://opensource.org/licenses/BSD-2-Clause', aliases: [
[name: 'BSD-style', url: 'http://www.opensource.org/licenses/bsd-license.php'],
[name: 'BSD', url: 'http://www.opensource.org/licenses/bsd-license.php'],
[name: 'The BSD License', url: 'http://www.opensource.org/licenses/bsd-license.php'],
[name: 'BSD 2-Clause License'],
[name: 'BSD 2-Clause license', url: 'http://opensource.org/licenses/BSD-2-Clause'],
[name: 'BSD', url: 'http://www.jcraft.com/jzlib/LICENSE.txt'],
[name: 'Revised BSD', url: 'http://www.jcraft.com/jsch/LICENSE.txt'],
]],
[name: 'BSD-3-Clause', url: 'http://opensource.org/licenses/BSD-3-Clause', aliases: [
[name: 'BSD-3-Clause', url: 'https://asm.ow2.io/license.html'],
[name: 'The BSD 3-Clause License'],
[name: 'The 3-Clause BSD License'],
[name: '3-Clause BSD License'],
[name: 'BSD 3-Clause'],
[name: 'BSD 3 Clause'],
[name: 'BSD 3-clause'],
[name: 'BSD 3-Clause License'],
[name: 'BSD Licence 3'],
[name: 'BSD License 3'],
[name: 'New BSD License'],
[name: 'New BSD license'],
[name: 'The New BSD License'],
[name: 'BSD License', url: 'http://www.antlr.org/license.html'],
[name: 'BSD licence', url: 'http://antlr.org/license.html'],
[name: 'The BSD License', url: 'http://www.antlr.org/license.html'],
[name: 'BSD', url: 'http://asm.ow2.org/license.html'],
[name: 'BSD', url: 'http://www.jcraft.com/jsch/LICENSE.txt'],
[name: 'BSD', url: 'https://github.com/sbt/test-interface/blob/master/LICENSE'],
[name: 'BSD', url: 'LICENSE.txt'],
[name: 'BSD 3-Clause "New" or "Revised" License (BSD-3-Clause)'],
[name: '', url: 'http://asm.ow2.org/license.html'],
[name: 'BSD', url: 'http://asm.objectweb.org/license.html'],
]],
[name: 'Apache-2.0', url: 'https://opensource.org/licenses/Apache-2.0', aliases: [
[name: 'The Apache Software License, Version 2.0'],
[name: 'The Apache License, Version 2.0'],
[name: 'The Apache Software License, version 2.0'],
[name: 'Apache 2'],
[name: 'Apache v2'],
[name: 'Apache License, Version 2.0'],
[name: 'Apache License, Version 2'],
[name: 'Apache Software License - Version 2.0'],
[name: 'Apache License 2.0'],
[name: 'Apache License'],
[name: 'Apache 2.0'],
[name: 'Apache-2.0'],
[name: 'Apache 2.0 License'],
[name: 'ASL'],
[name: 'ASL 2.0'],
[name: 'the Apache License, ASL Version 2.0'],
[name: 'Apache License V2.0'],
[name: 'Apache License v2.0'],
[name: 'Apache License Version 2.0'],
[name: '', url: 'http://www.apache.org/licenses/LICENSE-2.0.txt'],
]],
[name: 'MIT', url: 'https://opensource.org/licenses/MIT', aliases: [
[name: 'MIT'],
[name: 'MIT license'],
[name: 'MIT License'],
[name: 'The MIT License'],
[name: 'Bouncy Castle Licence'],
[name: 'MIT-0', url: 'https://spdx.org/licenses/MIT-0.html'],
]],
[name: 'Eclipse Distribution License - v 1.0', url: 'https://www.eclipse.org/licenses/edl-v10.html', aliases: [
[name: 'Eclipse Distribution License - v 1.0', url: 'http://www.eclipse.org/org/documents/edl-v10.php'],
[name: 'EDL 1.0'],
]],
[name: 'Eclipse Public License - v 1.0', url: 'https://www.eclipse.org/legal/epl-v10.html', aliases: [
[name: 'Eclipse Public License 1.0'],
[name: 'EPL', url: 'http://www.eclipse.org/legal/epl-v10.html']
]],
[name: 'Eclipse Public License - v 2.0', url: 'http://www.eclipse.org/legal/epl-2.0.html', aliases: [
[name: 'Eclipse Public License 2.0'],
[name: 'Eclipse Public License v2.0', url: 'https://www.eclipse.org/legal/epl-v20.html'],
[name: 'EPL 2.0', url: 'http://www.eclipse.org/legal/epl-2.0'],
[name: 'Eclipse Public License - v 2.0', url: 'https://www.eclipse.org/legal/epl-v20.html']
]],
[name: 'GNU General Public License (GPL), version 2, with the Classpath exception', url: 'http://openjdk.java.net/legal/gplv2+ce.html', aliases: [
[name: 'GPL-2.0'],
[name: 'GPL'],
[name: 'GNU General Public License Version 2', url: 'http://www.gnu.org/copyleft/gpl.html']
]],
[name: 'GNU LESSER GENERAL PUBLIC LICENSE, Version 2.1', url: 'https://www.gnu.org/licenses/old-licenses/lgpl-2.1.en.html'],
[name: 'Public Domain, per Creative Commons CC0', url: 'http://creativecommons.org/publicdomain/zero/1.0/', aliases: [
[name: 'CC0'],
[name: 'Public Domain'],
]],
[name: 'MPL-2.0', url: 'https://www.mozilla.org/MPL/2.0/', aliases: [
[name: 'Mozilla Public License Version 2.0'],
[name: 'Mozilla Public License, v. 2.0', url: 'http://mozilla.org/MPL/2.0/'],
]],
[name: 'Common Development and Distribution License Version 1.0', aliases: [
[name: 'COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0']
]],
[name: 'Common Development and Distribution License Version 1.1', aliases: [
[name: 'CDDL1.1'],
[name: 'CDDL 1.1'],
[name: 'Common Development and Distribution License (CDDL), Version 1.1'],
[name: 'CDDL License', url: 'http://www.opensource.org/licenses/cddl1.php']
]],
[name: 'Common Development and Distribution License Version 1.1 and GNU General Public License, version 2 with the Classpath Exception', aliases: [
[name: 'CDDL1.1-GPL2/CPE'],
[name: 'Dual license consisting of the CDDL v1.1 and GPL v2'],
[name: 'CDDL + GPLv2 with classpath exception'],
]],
[name: 'The Go license', url: 'https://golang.org/LICENSE'],
[name: 'The OpenLDAP Public License', url: 'http://www.openldap.org/software/release/license.html'],
]
// Dependency license reporting
downloadLicenses {
dependencyConfiguration = 'runtimeClasspath'
// Add licenses to some libraries which don't declare their license inside the POM. Should be rechecked if the version is updated.
licenses = [
'javax.servlet.jsp:jsp-api:2.1' : license('Common Development and Distribution License Version 1.1', null),
'org.antlr:ST4:4.1' : license('BSD-3-Clause', null),
'org.gradle:gradle-tooling-api:6.1.1' : license('Apache-2.0', null),
'org.jline:jline:3.22.0' : license('BSD-2-Clause', 'http://opensource.org/licenses/BSD-2-Clause'),
'com.sun.codemodel:codemodel:2.6' : license('Common Development and Distribution License Version 1.1', null),
]
aliases = allowList.collectEntries { lic ->
def actual = license(lic.name, lic.url)
def alternatives = lic.aliases.collect { it.url ? license(it.name, it.url) : it.name }
[(actual): alternatives]
}
}
tasks.downloadLicenses.ext.licenseToDependencyJson = { ->
def jsonDir = tasks.downloadLicenses.jsonDestination
def jsonFile = file("$jsonDir/license-dependency.json")
new groovy.json.JsonSlurper().parseText(jsonFile.text)
}
tasks.downloadLicenses.ext.dependencyToLicenseJson = { ->
def jsonDir = tasks.downloadLicenses.jsonDestination
def jsonFile = file("$jsonDir/dependency-license.json")
new groovy.json.JsonSlurper().parseText(jsonFile.text)
}
// Dependency license validation
tasks.register("validateLicenses") {
group = 'license'
description = 'Checks 3rd-party dependency licenses against an allowlist'
dependsOn tasks.downloadLicenses
def excludeNeo4jPattern = /^(org|com)\.neo4j.*/
doLast {
def allowListedNames = allowList.collect { it.name }
tasks.downloadLicenses.dependencyToLicenseJson().dependencies
.findAll { dep -> !dep.name.matches(excludeNeo4jPattern) }
.findAll { dep -> allowListedNames.intersect(dep.licenses.collect { it.name }).isEmpty() }
.each { dep -> logger.error("In project ${project.name}: Could not find an allowed license for dependency '$dep.name'. Details: ${dep.toMapString()}") }
.each { dep -> throw new GradleException("The dependency '$dep.name' has no allowed license") }
}
}
tasks.check.dependsOn tasks.validateLicenses
tasks.register("generateLicensesFiles") {
group = 'license'
description 'Generates a LICENSES and NOTICE file with 3rd-party dependency license information'
dependsOn tasks.downloadLicenses, tasks.validateLicenses
def licenseFile = "$tasks.downloadLicenses.jsonDestination/LICENSES.txt"
def noticesFile = "$tasks.downloadLicenses.jsonDestination/NOTICE.txt"
ext.licensesFile = file(licenseFile)
ext.noticeFile = file(noticesFile)
outputs.file(ext.licensesFile)
outputs.file(ext.noticeFile)
doLast {
// LICENSES.txt
licensesFile.createNewFile()
licensesFile.text = rootProject.file("$publicDir/licenses/headers/LICENSES-header.txt").text
tasks.downloadLicenses.licenseToDependencyJson().licences
.findAll { lic -> allowList.any { lic.name == it.name }}
.sort { it.name }.each {
licensesFile << '\n\n'
licensesFile << "------------------------------------------------------------------------------\n"
licensesFile << "$it.name\n"
it.dependencies.sort { it }.each { licensesFile << " $it\n" }
licensesFile << "------------------------------------------------------------------------------\n"
licensesFile << '\n'
licensesFile << rootProject.file("$publicDir/licenses/text/$it.name").text
}
// NOTICE.txt
noticeFile.createNewFile()
noticeFile.text = rootProject.file("$publicDir/licenses/headers/NOTICE-header.txt").text
noticeFile << '\n\n'
noticeFile << "Third-party licenses\n"
noticeFile << "--------------------\n"
tasks.downloadLicenses.licenseToDependencyJson().licences.sort { it.name }.each {
noticeFile << '\n'
noticeFile << "$it.name\n"
it.dependencies.sort { it }.each { noticeFile << " $it\n" }
}
// Compare this file to what we have stored already, fail if they differ so that the PR fails and we are forced
// to update it instead!
File storedLicenseFile = new File("$project.rootDir/LICENSES.txt")
boolean throwError = false
if (licensesFile.readLines().size() != storedLicenseFile.readLines().size()) {
throwError = true
}
for (def i = 0; i < licensesFile.readLines().size(); i++) {
if (throwError) break
if (licensesFile.readLines().get(i) != storedLicenseFile.readLines().get(i)) {
throwError = true
}
}
// Copy files to root project so they can be tracked
copy {
from licenseFile
into "$project.rootDir"
}
copy {
from noticesFile
into "$project.rootDir"
}
// Throw after copy task gets run and the file is updated ready for commit :)
// Note: You might need to do a `./gradlew clean` first if your file isn't updating!
if (throwError) {
throw new GradleException("The LICENSES.txt file has updated depenencies, please update by running `./gradlew generateLicensesFiles` and committing the changes.")
}
}
}
tasks.check.dependsOn tasks.generateLicensesFiles
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。