https://github.com/chrimaeon/gradle-licenses-plugin
This Gradle plugin provides tasks to generate a HTML / XML / Json file with the licenses used from the libraries.
https://github.com/chrimaeon/gradle-licenses-plugin
android gradle gradle-plugin gradle-task java kotlin license license-management
Last synced: 5 months ago
JSON representation
This Gradle plugin provides tasks to generate a HTML / XML / Json file with the licenses used from the libraries.
- Host: GitHub
- URL: https://github.com/chrimaeon/gradle-licenses-plugin
- Owner: chrimaeon
- License: apache-2.0
- Created: 2019-02-25T15:29:37.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2026-02-15T09:50:46.000Z (5 months ago)
- Last Synced: 2026-02-15T15:52:03.969Z (5 months ago)
- Topics: android, gradle, gradle-plugin, gradle-task, java, kotlin, license, license-management
- Language: Kotlin
- Homepage:
- Size: 1.05 MB
- Stars: 17
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Notice: NOTICE
Awesome Lists containing this project
README
# Gradle Licenses Plugin [](https://github.com/chrimaeon/gradle-licenses-plugin/actions/workflows/main.yml) [](https://codecov.io/gh/chrimaeon/gradle-licenses-plugin)
[](http://www.apache.org/licenses/LICENSE-2.0)
[](https://gradle.org/)
[](https://plugins.gradle.org/plugin/com.cmgapps.licenses)
This Gradle plugin provides tasks to generate a file with the licenses used from the project's dependencies.
## Usage
### Integration
#### Using the plugins DSL
Kotlin
```kotlin
plugins {
id("com.cmgapps.licenses") version "6.0.0"
}
```
Groovy
```groovy
plugins {
id 'com.cmgapps.licenses' version '6.0.0'
}
```
#### Using the legacy plugin application
Kotlin
```kotlin
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.cmgapps:gradle-licenses-plugin:6.0.0")
}
}
apply(plugin = "com.cmgapps.licenses")
```
Groovy
```groovy
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.cmgapps:gradle-licenses-plugin:6.0.0'
}
}
apply plugin: 'com.cmgapps.licenses'
```
### Tasks
Applying the plugin will create tasks to generate the license report
For `"java"` and `"java-library"`
* `licenseReport`
For `"com.android.application"`, `"com.android.library"`, `"com.android.feature"` and `"com.android.dynamic-feature"`
* `licenseReport`
For `"org.jetbrains.kotlin.multiplatform"`
* `licenseMultiplatformReport` collects licenses from all targets
* `licenseMultiplatformReport` collects licenses from `common` and the specified ``
### Configuration
#### Output Format
Example:
```kotlin
licenses {
reports {
html.enabled.set(false) // html is enabled by default
xml {
enabled.set(true)
outputFile.set(file("$buildDir/reports/licenses.xml"))
}
}
}
```
The plugin can output different formats.
* `HTML`
generates a formatted HTML website
* Styling
For an HTML report you can define custom stylesheet using a `File` or `String`:
```kotlin
licenses {
reports {
html.stylesheet("body {background: #FAFAFA}")
}
}
```
or
```kotlin
licenses {
reports {
html.stylesheet.set(file("$projectDir/styles/licenses.css"))
}
}
```
* In the default CSS style, Dark Mode for supported browsers is also enabled by default. It adds a `` and a custom css theme.
It can be disabled via
```kotlin
licenses {
reports {
html.useDarkMode.set(false)
}
}
```
* `JSON`
generates a JSON file
* `XML`
generates a valid XML version 1.0 file
* `Text`
generates a plain text report file
* `Mardown`
generates a Markdown file
* `Custom`
add your own reporter as a lambda function
Kotlin
```kotlin
licenses {
custom {
enabled.set(true)
outputFile.set(buildDir.resolve("reports").resolve("licenses.txt"))
generateor.set { list -> list.map { it.name }.joinToString() }
}
}
```
Groovy
```groovy
licenses {
custom {
enabled.set(true)
outputFile.set(file("$buildDir/reports/licenses/licenses.txt"))
def builder = { list -> list.collect { it.name }.join(', ') } as com.cmgapps.license.reporter.CustomReportGenerator
generator.set(builder)
}
}
```
#### Multi-project Builds
For multi-project build, you can add projects you want to collect license information from in the main project.
Kotlin
```kotlin
licenses {
additionalProjects(":module2", ":module3")
}
```
Groovy
```groovy
licenses {
additionalProjects ':module2', ':module3'
}
```
## License
```text
Copyright (c) 2018-2024. Christian Grach
SPDX-License-Identifier: Apache-2.0
```
[TextResource]: https://docs.gradle.org/current/dsl/org.gradle.api.resources.TextResource.html