Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 3 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 (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-24T09:50:34.000Z (5 months ago)
- Last Synced: 2024-08-24T10:51:10.428Z (5 months ago)
- Topics: android, gradle, gradle-plugin, gradle-task, java, kotlin, license, license-management
- Language: Kotlin
- Homepage:
- Size: 799 KB
- Stars: 14
- Watchers: 1
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Gradle Licenses Plugin [![Build & Test](https://github.com/chrimaeon/gradle-licenses-plugin/actions/workflows/main.yml/badge.svg)](https://github.com/chrimaeon/gradle-licenses-plugin/actions/workflows/main.yml) [![codecov](https://codecov.io/gh/chrimaeon/gradle-licenses-plugin/branch/master/graph/badge.svg?token=XY0G488B3B)](https://codecov.io/gh/chrimaeon/gradle-licenses-plugin)
[![License](https://img.shields.io/badge/license-Apache%202.0-brightgreen.svg?style=for-the-badge)](http://www.apache.org/licenses/LICENSE-2.0)
[![Gradle Plugin](https://img.shields.io/badge/Gradle-7.2%2B-%2302303A.svg?style=for-the-badge&logo=Gradle)](https://gradle.org/)
[![MavenCentral](https://img.shields.io/maven-central/v/com.cmgapps/gradle-licenses-plugin?style=for-the-badge&logo=Apache%20Maven)](https://repo1.maven.org/maven2/com/cmgapps/gradle-licenses-plugin/)
[![gradlePluginPortal](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/com/cmgapps/licenses/com.cmgapps.licenses.gradle.plugin/maven-metadata.xml.svg?label=Gradle%20Plugin%20Portal&style=for-the-badge&logo=Gradle)](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 "4.8.0"
}
```Groovy
```groovy
plugins {
id 'com.cmgapps.licenses' version '4.8.0'
}
```#### Using legacy plugin application
Kotlin
```kotlin
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("com.cmgapps:gradle-licenses-plugin:4.8.0")
}
}apply(plugin = "com.cmgapps.licenses")
```Groovy
```groovy
buildscript {
repositories {
maven {
url 'https://plugins.gradle.org/m2/'
}
}
dependencies {
classpath 'com.cmgapps:gradle-licenses-plugin:4.8.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 = false // html is enabled by default
xml {
enabled = true
destination = file("$buildDir/reports/licenses.xml")
}
}
}
```The plugin can output different formats.
* `HTML`
generates a formatted HTML website
* StylingFor 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(file("$projectDir/styles/licenses.css"))
}
}
```
* On 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 = true
destination = buildDir.resolve("reports").resolve("licenses.txt")
generate { list -> list.map { it.name }.joinToString() }
}
}
```
Groovy
```groovy
licenses {
custom {
enabled = true
destination = file("$buildDir/reports/licenses/licenses.txt")
generate { list -> list.collect { it.name }.join(', ') }
}
}
```
#### 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. Christian GrachSPDX-License-Identifier: Apache-2.0
```[TextResource]: https://docs.gradle.org/current/dsl/org.gradle.api.resources.TextResource.html