在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):hierynomus/license-gradle-plugin开源软件地址(OpenSource Url):https://github.com/hierynomus/license-gradle-plugin开源编程语言(OpenSource Language):Groovy 73.4%开源软件介绍(OpenSource Introduction):License Gradle PluginThis plugin will scan and adapt your source files to include a provided header, e.g. a LICENSE file. By default it will scan every source set and report warnings. It will also create format tasks, which will properly format and apply the specified header. A bulk of the logic comes from the maven-license-plugin. This plugin will also report on the licenses of your dependencies. Applying the pluginFrom v0.11.0 onwards the Gradle 2.1 and aboveIn your plugins {
id "com.github.hierynomus.license" version "0.15.0"
} Gradle 1.x/2.0, latest license-gradle-pluginIn your buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:0.15.0"
}
}
apply plugin: "com.github.hierynomus.license" Gradle 1.x/2.0, gradle-license-plugin 0.10.0 (and earlier)In your buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'
}
}
apply plugin: 'license' Source file license applicationcom.github.hierynomus.license-base Pluginplugins {
id "com.github.hierynomus.license-base" version"0.15.0"
} This plugin contains two types of tasks to each source set available in your project: one for checking for consistency and one to apply the header, e.g.
Furthermore this task exposes the com.github.hierynomus.license Pluginplugins {
id "com.github.hierynomus.license" version"0.15.0"
} This plugin will apply the following plugins:
Furthermore it will create the following tasks:
Also it will add the TasksLicenseCheckThis task checks all the configured source files to validate whether the correct header has been applied. It can be configured using the following properties, most of which can also be set on the extension to configure them for all tasks.
LicenseFormatThis task formats all the configured source files to add a header to them if no header has been applied yet. It can be configured using the following properties, most of which can also be set on the extension to configure them for all tasks.
License ExtensionA license extension is added to the project, which can be used to configure all license {
header rootProject.file('codequality/HEADER')
strictCheck true
} Here is a general overview of the options:
File TypesSupported by default: Usage and ConfigurationHeader LocationsThe plugin can load a reference license file from the local file system with the header property. license { header = file('LGPL.txt') } To load a license from a URI directly it can be headerURI property. license { headerURI = new URI("https://www.gnu.org/licenses/lgpl.txt") } The problem with that approach is that we’re requiring a network call to run the task. Another option is to load the license from the classpath. This is most commonly seen from a plugin which is configuring this plugin. First you’d bundle a LICENSE.TXT file into the src/main/resources/META-INF directory. Then you’d configure this plugin like the below code. license { headerURI = myPlugin.class.getResource("/META-INF/LICENSE.TXT").toURI() } In regards to the header, tasks can be configured individually or in bulk also, licenseFormatMain.header = file('APL.txt')
// or
tasks.withType(License) { header = file('LGPL.txt') } Recognizing other file types.An extensive list of formats and mappings are available by default, see the SupportedFormats link above. Occasionally a project might need to add a mapping to a unknown file type to an existing comment style. license {
mapping {
javascript='JAVADOC_STYLE'
}
}
// or
license.mapping 'javascript' 'JAVADOC_STYLE'
// or
license.mapping('javascript', 'JAVADOC_STYLE')
// or directly on the task
licenseMain.mapping 'javascript' 'JAVADOC_STYLE' Defining new comment types is not currently supported, but file a bug and it can be added. Variable substitutionVariables in the format Copyright (C) ${year} ${name} <${email}> Will be completed with this extension block, the key is adding them via extra properties: license {
ext.year = Calendar.getInstance().get(Calendar.YEAR)
ext.name = 'Company'
ext.email = '[email protected]'
}
// or
licenseMain.ext.year = 2012 Creating custom header definitionsWhen the default header definitions can not be used for your specific project, we support the ability to define custom header definitions. Adding a new header definition is done through the license extension. These header definitions can then be assigned to the necessary file types by mapping them to their extensions. license {
headerDefinitions {
custom_definition {
firstLine = "//"
endLine = "//"
firstLineDetectionPattern = "//"
lastLineDetectionPattern = "//"
allowBlankLines = false
skipLinePattern = "//"
isMultiline = false
}
}
} Include/Exclude files from license absence reporting and license applicationBy default all files in the sourceSets configured are required to carry a license. Just like with Gradle The semantics are:
For instance: license {
exclude "**/*.properties"
excludes(["**/*.txt", "**/*.conf"])
} This will exclude all license {
include "**/*.groovy"
includes(["**/*.java", "**/*.properties"])
} This will include only all license {
include "**/*.java"
exclude "**/*Test.java"
} This will include all Running on a non-java projectBy default, applying the plugin will generate license tasks for all source sets defined by the java plugin. You can also run the license task on an arbitrary file tree, if you don’t have the java plugin, or your files are outside a java source tree. task licenseFormatSql(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {
source = fileTree(dir: "source").include("**/*.sql")
}
licenseFormat.dependsOn licenseFormatSql Dependency License ReportingNext to checking for and applying license headers to your source files, this plugin also supports reporting on the licenses that your dependencies are licensed under. com.github.hierynomus.license-reportplugins {
id "com.github.hierynomus.license-report" version"0.15.0"
} This plugin will add a task to manage the downloading and reporting of licenses of your dependencies.
License ReportingThe
A 'license()' method is made available by the License Extension that takes two Strings, the first is the license name, the second is the URL to the license. downloadLicenses {
ext.apacheTwo = license('Apache License, Version 2.0', 'http://opensource.org/licenses/Apache-2.0')
ext.bsd = license('BSD License', 'http://www.opensource.org/licenses/bsd-license.php')
includeProjectDependencies = true
licenses = [
(group('com.myproject.foo')) : license('My Company License'),
'org.apache.james:apache-mime4j:0.6' : apacheTwo,
'org.some-bsd:project:1.0' : bsd
]
aliases = [
(apacheTwo) : ['The Apache Software License, Version 2.0', 'Apache 2', 'Apache License Version 2.0', 'Apache License, Version 2.0', 'Apache License 2.0', license('Apache License', 'http://www.apache.org/licenses/LICENSE-2.0')],
(bsd) : ['BSD', license('New BSD License', 'http://www.opensource.org/licenses/bsd-license.php')]
]
excludeDependencies = [
'com.some-other-project.bar:foobar:1.0'
]
dependencyConfiguration = 'compile'
} Changelogv0.15.0 (2018-11-22)
v0.14.0 (2017-??-??) -→ See Upgrade Notes!v0.13.1 (2016-06-07)v0.12.1 (2015-10-26)
v0.12.0 (2015-10-07)
全部评论
专题导读
上一篇:int128/gradle-ssh-plugin: Gradle SSH Plugin发布时间:2022-06-11下一篇:jasonross/NuwaGradle: gradle plugin wrote for Nuwa发布时间:2022-06-11热门推荐
热门话题
阅读排行榜
|
请发表评论