-
-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
optimizing configuring project (#181)
- Loading branch information
1 parent
8fd380d
commit 6ae74a2
Showing
3 changed files
with
86 additions
and
99 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/main/kotlin/com/jaredsburrows/license/BaseLicenseReportTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package com.jaredsburrows.license | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.OutputFile | ||
import java.io.File | ||
|
||
/** A [org.gradle.api.Task] that is common for both Java and Android projects. */ | ||
open class BaseLicenseReportTask : DefaultTask() { | ||
|
||
// Task annotations cannot be internal | ||
@OutputFile var csvFile: File | ||
@OutputFile var htmlFile: File | ||
@OutputFile var jsonFile: File | ||
@Input var generateCsvReport = false | ||
@Input var generateHtmlReport = false | ||
@Input var generateJsonReport = false | ||
@Input var copyCsvReportToAssets = false | ||
@Input var copyHtmlReportToAssets = false | ||
@Input var copyJsonReportToAssets = false | ||
private var outputPath: String | ||
|
||
init { | ||
// From DefaultTask | ||
description = "Outputs licenses report for $name." | ||
group = "Reporting" | ||
|
||
// Customizing internal task options | ||
outputPath = "${project.buildDir}/reports/licenses/".replace('/', File.separatorChar) | ||
csvFile = File(outputPath, "$name$CSV_EXT") | ||
htmlFile = File(outputPath, "$name$HTML_EXT") | ||
jsonFile = File(outputPath, "$name$JSON_EXT") | ||
|
||
// Customizing internal task options from extension | ||
val extension = project.extensions.getByType(LicenseReportExtension::class.java) | ||
generateCsvReport = extension.generateCsvReport | ||
generateHtmlReport = extension.generateHtmlReport | ||
generateJsonReport = extension.generateJsonReport | ||
copyCsvReportToAssets = extension.copyCsvReportToAssets | ||
copyHtmlReportToAssets = extension.copyHtmlReportToAssets | ||
copyJsonReportToAssets = extension.copyJsonReportToAssets | ||
} | ||
|
||
internal companion object { | ||
const val CSV_EXT = ".csv" | ||
const val HTML_EXT = ".html" | ||
const val JSON_EXT = ".json" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters