{"id":13646910,"url":"https://github.com/hierynomus/license-gradle-plugin","last_synced_at":"2025-04-04T19:14:36.180Z","repository":{"id":1073385,"uuid":"914632","full_name":"hierynomus/license-gradle-plugin","owner":"hierynomus","description":"Manage your license(s)","archived":false,"fork":false,"pushed_at":"2023-08-26T20:46:58.000Z","size":569,"stargazers_count":408,"open_issues_count":89,"forks_count":114,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-10-14T14:59:17.155Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://www.javadude.nl","language":"Groovy","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hierynomus.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-09-16T06:15:19.000Z","updated_at":"2024-10-10T09:39:03.000Z","dependencies_parsed_at":"2024-08-02T01:25:00.984Z","dependency_job_id":"9705af3d-3025-46c6-b156-21c5c68498ab","html_url":"https://github.com/hierynomus/license-gradle-plugin","commit_stats":{"total_commits":204,"total_committers":34,"mean_commits":6.0,"dds":0.5882352941176471,"last_synced_commit":"09eea5de01db76f154ec806ab613e443f0f02685"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hierynomus%2Flicense-gradle-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hierynomus%2Flicense-gradle-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hierynomus%2Flicense-gradle-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hierynomus%2Flicense-gradle-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hierynomus","download_url":"https://codeload.github.com/hierynomus/license-gradle-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234923,"owners_count":20905854,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:03:14.930Z","updated_at":"2025-04-04T19:14:36.158Z","avatar_url":"https://github.com/hierynomus.png","language":"Groovy","funding_links":[],"categories":["Groovy","Uncategorized"],"sub_categories":["Uncategorized"],"readme":"= License Gradle Plugin\nJeroen van Erp\n:license_plugin_version: 0.15.0\n\nimage:https://travis-ci.org/hierynomus/license-gradle-plugin.svg?branch=master[Build Status,link=https://travis-ci.org/hierynomus/license-gradle-plugin]\n\nThis 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.\n\nThis plugin will also report on the licenses of your dependencies.\n\n== Applying the plugin\nFrom v0.11.0 onwards the `license-gradle-plugin` will be published to http://bintray.com[] and will be available through the http://plugins.gradle.org/[Gradle plugin exchange]. This means that there are a few different usage scenarios listed below.\n\n\n=== Gradle 2.1 and above\nIn your `build.gradle` file add:\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\nplugins {\n    id \"com.github.hierynomus.license\" version \"{license_plugin_version}\"\n}\n----\n\n=== Gradle 1.x/2.0, latest license-gradle-plugin\nIn your `build.gradle` file add:\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\nbuildscript {\n  repositories {\n    maven {\n      url \"https://plugins.gradle.org/m2/\"\n    }\n  }\n  dependencies {\n    classpath \"gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:{license_plugin_version}\"\n  }\n}\n\napply plugin: \"com.github.hierynomus.license\"\n----\n\n=== Gradle 1.x/2.0, gradle-license-plugin 0.10.0 (and earlier)\nIn your `build.gradle` file add:\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\n    buildscript {\n        repositories {\n            mavenCentral()\n        }\n\n        dependencies {\n            classpath 'nl.javadude.gradle.plugins:license-gradle-plugin:0.10.0'\n        }\n    }\n\n    apply plugin: 'license'\n----\n\n== Source file license application\n\n=== com.github.hierynomus.license-base Plugin\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\nplugins {\n  id \"com.github.hierynomus.license-base\" version\"{license_plugin_version}\"\n}\n----\n\nThis 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.\n\n- licenseMain (`LicenseCheck`)        : checks for header consistency in the main source set\n- licenseFormatMain (`LicenseFormat`) : applies the license found in the header file in files missing the header\n- licenseTest (`LicenseCheck`)        : checks for header consistency in the test source set\n- licenseFormatTest (`LicenseFormat`) : applies the license found in the header file in files missing the header in the test source set\n- etc.\n\nFurthermore this task exposes the `license` extension to the project, allowing you to finetune the configuration of the plugin.\n\n=== com.github.hierynomus.license Plugin\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\nplugins {\n  id \"com.github.hierynomus.license\" version\"{license_plugin_version}\"\n}\n----\n\nThis plugin will apply the following plugins:\n\n- `com.github.hierynomus.license-base`\n- `com.github.hierynomus.license-report`\n\nFurthermore it will create the following tasks:\n\n- `licenseCheck`: This task depends on all the available `LicenseCheck` tasks in the project\n- `licenseFormat`: This task depends on all the available `LicenseFormat` tasks in the project\n\nAlso it will add the `licenseCheck` task to the `check` lifecycle task dependencies, so that during a regular build any missing headers are flagged.\n\n=== Tasks\n\n==== LicenseCheck\nThis task checks all the configured source files to validate whether the correct header has been applied. It can be configured using the following properties,\nmost of which can also be set on the extension to configure them for all tasks.\n\n[cols=\"h,d\"]\n|====\n|header |Specify location of header to use in comparisons, default to project.file('LICENSE')\n|headerURI |Specify location of header as a URI, see section below on Header Locations for examples\n|ignoreFailures |Prevent tasks from stopping the build, defaults to false\n|dryRun |Show what would happen if the task was run, defaults to false but also inherits from `--dryRun`\n|skipExistingHeaders |Skip over files that have some header already, which might not be the one specified in the header parameter, defaults to false\n|useDefaultMappings |Use a long list of standard mapping, defaults to true. See http://code.mycila.com/license-maven-plugin/#supported-comment-types[] for the complete list\n|strictCheck |Be extra strict in the formatting of existing headers, defaults to false\n|mapping(String ext, String style) |Adds a mapping between a file extension and a style type\n|mapping(Map\u003cString,String\u003e mappings) |Adds mappings between file extensions and style types\n|mapping(Closure) |Adds mappings between file extensions and a style types, see example below\n|exclude(String pattern) |Add an ANT style pattern to exclude files from license absence reporting and license application\n|excludes(Collection\u003cString\u003e patterns) |Add ANT style patterns to exclude files from license absence reporting and license application\n|include(String pattern) |Add an ANT style pattern to include files into license absence reporting and license application\n|includes(Collection\u003cString\u003e patterns) |Add ANT style patterns to include files into license absence reporting and license application\n|====\n\n==== LicenseFormat\nThis 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,\nmost of which can also be set on the extension to configure them for all tasks.\n\n[cols=\"h,d\"]\n|====\n|header |Specify location of header to use in comparisons, default to project.file('LICENSE')\n|headerURI |Specify location of header as a URI, see section below on Header Locations for examples\n|ignoreFailures |Prevent tasks from stopping the build, defaults to false\n|dryRun |Show what would happen if the task was run, defaults to false but also inherits from `--dryRun`\n|skipExistingHeaders |Skip over files that have some header already, which might not be the one specified in the header parameter, defaults to false\n|useDefaultMappings |Use a long list of standard mapping, defaults to true. See http://code.mycila.com/license-maven-plugin/#supported-comment-types[] for the complete list\n|strictCheck |Be extra strict in the formatting of existing headers, defaults to false\n|mapping(String ext, String style) |Adds a mapping between a file extension and a style type\n|mapping(Map\u003cString,String\u003e mappings) |Adds mappings between file extensions and style types\n|mapping(Closure) |Adds mappings between file extensions and a style types, see example below\n|exclude(String pattern) |Add an ANT style pattern to exclude files from license absence reporting and license application\n|excludes(Collection\u003cString\u003e patterns) |Add ANT style patterns to exclude files from license absence reporting and license application\n|include(String pattern) |Add an ANT style pattern to include files into license absence reporting and license application\n|includes(Collection\u003cString\u003e patterns) |Add ANT style patterns to include files into license absence reporting and license application\n|====\n\n=== License Extension\nA license extension is added to the project, which can be used to configure all `LicenseCheck` and `LicenseFormat` tasks. E.g.\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\nlicense {\n    header rootProject.file('codequality/HEADER')\n    strictCheck true\n}\n----\n\nHere is a general overview of the options:\n\n[cols=\"h,d\"]\n|====\n|header |Specify location of header to use in comparisons, default to `project.file('LICENSE')`\n|headerURI |Specify location of header as a URI.\n|ignoreFailures |Prevent tasks from stopping the build, defaults to false\n|dryRun |Show what would happen if the task was run, defaults to false but also inherits from `--dryRun`\n|skipExistingHeaders |Skip over files that have some header already, which might not be the one specified in the header parameter, defaults to false\n|useDefaultMappings |Use a long list of standard mapping, defaults to true. See http://code.mycila.com/license-maven-plugin/#supported-comment-types[] for the complete list\n|strictCheck |Be extra strict in the formatting of existing headers, defaults to false\n|mapping(String ext, String style) |Adds a mapping between a file extension and a style type\n|mapping(Map\u003cString,String\u003e mappings) |Adds mappings between file extensions and style types\n|mapping(Closure) |Adds mappings between file extensions and a style types, see example below\n|exclude(String pattern) |Add an ANT style pattern to exclude files from license absence reporting and license application\n|excludes(Collection\u003cString\u003e patterns) |Add ANT style patterns to exclude files from license absence reporting and license application\n|include(String pattern) |Add an ANT style pattern to include files into license absence reporting and license application\n|includes(Collection\u003cString\u003e patterns) |Add ANT style patterns to include files into license absence reporting and license application\n|headerDefinition(HeaderDefinitionBuilder headerDefinition) |Add a custom header definition that will be added to the defaults.\n|headerDefinitions(Closure) | Add a custom header definition that will be added to the defaults.\n|====\n\n[[supported-file-types]]\n=== File Types\nSupported by default: `java`, `groovy`, `js`, `css`, `xml`, `dtd`, `xsd`, `html`, `htm`, `xsl`, `fml`, `apt`, `properties`, `sh`, `txt`, `bat`, `cmd`, `sql`, `jsp`, `ftl`, `xhtml`, `vm`, `jspx`, `gsp`, `json`. Complete list can be found in the parent project at http://code.mycila.com/license-maven-plugin/#supported-comment-types.\n\n=== Usage and Configuration\n==== Header Locations\nThe plugin can load a reference license file from the local file system with the _header_ property.\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\n    license { header = file('LGPL.txt') }\n----\n\nTo load a license from a URI directly it can be _headerURI_ property.\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\n    license { headerURI = new URI(\"https://www.gnu.org/licenses/lgpl.txt\") }\n----\n\nThe problem with that approach is that we're requiring a network call to run the task. Another option is\nto load the license from the classpath. This is most commonly seen from a plugin which is configuring this\nplugin. First you'd bundle a _LICENSE.TXT_ file into the _src/main/resources/META-INF_ directory. Then you'd\nconfigure this plugin like the below code.\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\n    license { headerURI = myPlugin.class.getResource(\"/META-INF/LICENSE.TXT\").toURI() }\n----\n\nIn regards to the header, tasks can be configured individually or in bulk also,\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\n    licenseFormatMain.header = file('APL.txt')\n    // or\n    tasks.withType(License) { header = file('LGPL.txt') }\n----\n\n==== Recognizing other file types.\nAn extensive list of formats and mappings are available by default, see the \u003c\u003csupported-file-types,SupportedFormats\u003e\u003e link above. Occasionally a project might need to add a mapping to a unknown file type to an existing comment style.\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\nlicense {\n    mapping {\n        javascript='JAVADOC_STYLE'\n    }\n}\n// or\nlicense.mapping 'javascript' 'JAVADOC_STYLE'\n// or\nlicense.mapping('javascript', 'JAVADOC_STYLE')\n// or directly on the task\nlicenseMain.mapping 'javascript' 'JAVADOC_STYLE'\n----\n\nDefining new comment types is not currently supported, but file a bug and it can be added.\n\n==== Variable substitution\nVariables in the format `${}` format will be substituted, as long as their values are provided in the extension or the task.\n\n----\n    Copyright (C) ${year} ${name} \u003c${email}\u003e\n----\n\nWill be completed with this extension block, the key is adding them via extra properties:\n\n[source,groovy]\n----\nlicense {\n    ext.year = Calendar.getInstance().get(Calendar.YEAR)\n    ext.name = 'Company'\n    ext.email = 'support@company.com'\n}\n// or\nlicenseMain.ext.year = 2012\n----\n\n==== Creating custom header definitions\nWhen the default header definitions can not be used for your specific project, we support the ability to define custom header definitions.\n\nAdding 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.\n\n[source,groovy]\n----\nlicense {\n    headerDefinitions {\n        custom_definition {\n          firstLine = \"//\"\n          endLine   = \"//\"\n          firstLineDetectionPattern = \"//\"\n          lastLineDetectionPattern  = \"//\"\n          allowBlankLines = false\n          skipLinePattern = \"//\"\n          isMultiline = false\n        }\n    }\n}\n----\n\n==== Include/Exclude files from license absence reporting and license application\nBy default all files in the sourceSets configured are required to carry a license. Just like with Gradle `SourceSet` you can use include/exclude patterns to control this behaviour.\n\nThe semantics are:\n\n- no `includes` or `excludes`: All files in the sourceSets will be included\n- `excludes` provided: All files except those matching the exclude patterns are included\n- `includes` provided: Only the files matching the include patterns are included\n- both `includes` and `excludes` provided: All files matching the include patterns, except those matching the exclude patterns are included.\n\nFor instance:\n\n[source,groovy]\n----\nlicense {\n    exclude \"**/*.properties\"\n    excludes([\"**/*.txt\", \"**/*.conf\"])\n}\n----\n\nThis will exclude all `*.properties`, `*.txt` and `*.conf` files.\n\n[source,groovy]\n----\nlicense {\n    include \"**/*.groovy\"\n    includes([\"**/*.java\", \"**/*.properties\"])\n}\n----\n\nThis will include only all `*.groovy`, `*.java` and `*.properties` files.\n\n[source,groovy]\n----\nlicense {\n    include \"**/*.java\"\n    exclude \"**/*Test.java\"\n}\n----\n\nThis will include all `*.java` files, except the `*Test.java` files.\n\n==== Running on a non-java project\nBy 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.\n\n[source,groovy]\n----\ntask licenseFormatSql(type: com.hierynomus.gradle.license.tasks.LicenseFormat) {\n    source = fileTree(dir: \"source\").include(\"**/*.sql\")\n}\nlicenseFormat.dependsOn licenseFormatSql\n----\n\n\n== Dependency License Reporting\nNext 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.\n\n== com.github.hierynomus.license-report\n\n[source,groovy,subs=\"verbatim,attributes\"]\n----\nplugins {\n  id \"com.github.hierynomus.license-report\" version\"{license_plugin_version}\"\n}\n----\n\nThis plugin will add a task to manage the downloading and reporting of licenses of your dependencies.\n\n- `downloadLicenses`   : generates reports on your runtime dependencies\n\n== License Reporting\nThe `downloadLicenses` task has a set of properties, most can be set in the extension:\n\n[cols=\"h,d\"]\n|====\n|includeProjectDependencies |true if you want to include the transitive dependencies of your project dependencies\n|ignoreFatalParseErrors |true if you want to ignore fatal errors when parsing POMs of transitive dependencies\n|licenses |a pre-defined mapping of a dependency to a license; useful if the external repositories do not have license information available\n|aliases |a mapping between licenses; useful to consolidate the various POM definitions of different spelled/named licenses\n|excludeDependencies |a List of dependencies that are to be excluded from reporting\n|dependencyConfiguration |Gradle dependency configuration to report on (defaults to \"runtime\").\n|====\n\nA '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.\n\n[source,groovy]\n----\ndownloadLicenses {\n    ext.apacheTwo = license('Apache License, Version 2.0', 'http://opensource.org/licenses/Apache-2.0')\n    ext.bsd = license('BSD License', 'http://www.opensource.org/licenses/bsd-license.php')\n\n    includeProjectDependencies = true\n    licenses = [\n        (group('com.myproject.foo')) : license('My Company License'),\n        'org.apache.james:apache-mime4j:0.6' : apacheTwo,\n        'org.some-bsd:project:1.0' : bsd\n    ]\n\n    aliases = [\n        (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')],\n        (bsd) : ['BSD', license('New BSD License', 'http://www.opensource.org/licenses/bsd-license.php')]\n    ]\n\n    excludeDependencies = [\n        'com.some-other-project.bar:foobar:1.0'\n    ]\n\n    dependencyConfiguration = 'compile'\n}\n----\n\n== Changelog\n\n=== v0.15.0 (2018-11-22)\n- Correctly published the split-up plugins (I hope..)\n\n=== v0.14.0 (2017-??-??) --\u003e See Upgrade Notes!\n- Upgraded to com.mycila:license-maven-plugin:3.0\n- Split up plugin into smaller parts (`license-base`, `license-report`, `license`)\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/134[#134]: Fixed build on Gradle 3.4.+\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/132[#132]: Added custom header definitions\n- Fixed https://github.com/hierynomus/license-gradle-plugin/issues/127[#127]: Made reporting target directory lazy\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/112[#112]: Added JSON license reporting\n\n=== v0.13.1 (2016-06-07)\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/109[#109]: Fixed compatibility with older Android plugins\n=== v0.13.0 (2016-06-06)\n- Upgraded Gradle build version to 2.13\n- Upgraded Android Tools version to 2.0+\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/106[#106]: Added boolean parameter to ignore broken poms while searching for licenses\n\n=== v0.12.1 (2015-10-26)\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/87[#87]: Fix downloadLicenses fails with `module notation '::' is invalid`\n\n=== v0.12.0 (2015-10-07)\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/56[#56]: Added Android support\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/72[#72]: Fix SAX parser to ignore namespaces\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/82[#82]: Also now works for Android LibraryPlugin\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/83[#83]: Fix for Android plugin detection\n- Merged https://github.com/hierynomus/license-gradle-plugin/pull/84[#84]: Support for unified license reports in multi-module builds (Fixes https://github.com/hierynomus/license-gradle-plugin/issues/40[#40] and https://github.com/hierynomus/license-gradle-plugin/issues/50[#50])\n- Fixed https://github.com/hierynomus/license-gradle-plugin/issues/48[#48]: Added '.gradle' as standard extension\n- Fixed https://github.com/hierynomus/license-gradle-plugin/issues/70[#70]: Added '.yaml' and '.yml' as standard extension\n- Fixed https://github.com/hierynomus/license-gradle-plugin/issues/85[#85]: Removed source dependency on (optional) Android plugin.\n\n=== v0.11.0\n- Added support for uploading to bintray (Fixes https://github.com/hierynomus/license-gradle-plugin/issues/46[#46] and https://github.com/hierynomus/license-gradle-plugin/issues/47[#47])\n- Upgraded to Gradle 2.0\n\n=== v0.10.0\n- Fixed build to enforce Java6 only for local builds, not on BuildHive\n- Added `exclude` / `excludes` to extension (Fixes https://github.com/hierynomus/license-gradle-plugin/issues/39[#39])\n- Added `include` / `includes` to extension (Fixes https://github.com/hierynomus/license-gradle-plugin/issues/45[#45])\n\n=== v0.9.0\n- Fixed build to force Java6 (Fixes https://github.com/hierynomus/license-gradle-plugin/issues/35[#35])\n- Added example test for https://github.com/hierynomus/license-gradle-plugin/issues/38[#38]\n\n=== v0.8.0\n- Merged pull-requests https://github.com/hierynomus/license-gradle-plugin/pull/31[#31], https://github.com/hierynomus/license-gradle-plugin/pull/33[#33], https://github.com/hierynomus/license-gradle-plugin/pull/42[#42]\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhierynomus%2Flicense-gradle-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhierynomus%2Flicense-gradle-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhierynomus%2Flicense-gradle-plugin/lists"}