com.datadog.gradle.plugin.licenses.tasks.UpdateDependencyLicensesTask.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependency-license Show documentation
Show all versions of dependency-license Show documentation
This plugin generates the OSS licenses csv file for all dependencies.
The newest version!
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2016-Present Datadog, Inc.
*/
package com.datadog.gradle.plugin.licenses.tasks
import com.datadog.gradle.plugin.licenses.DependencyLicensesExtension
import com.datadog.gradle.plugin.licenses.internal.DependenciesLicenseProvider
import org.gradle.api.DefaultTask
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.TaskAction
/**
* Task overwriting the target CSV file with information about the dependency licenses
* found in all the modules of the project.
*/
open class UpdateDependencyLicensesTask : DefaultTask() {
@get: Input
internal var extension: DependencyLicensesExtension =
DependencyLicensesExtension()
private val provider: DependenciesLicenseProvider =
DependenciesLicenseProvider()
init {
group = "datadog"
description = "Lists Third Party Licenses in a csv file"
}
// region Task
/**
* Overwrites the LICENSE-3rdparty.csv file at the root of the project.
*/
@TaskAction
fun applyTask() {
val dependencies = provider.getThirdPartyDependencies(
project,
extension.transitiveDependencies,
extension.listDependencyOnce,
)
extension.csvFile.printWriter().use { writer ->
writer.println("Component,Origin,License,Copyright")
dependencies
.forEach {
writer.println(it.toCSV())
}
}
}
// endregion
}