com.vgaidarji.dependencies.overview.writer.MarkdownWriter.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dependencies-overview Show documentation
Show all versions of dependencies-overview Show documentation
Generates project dependencies overview report (JSON, Markdown, etc.) from project dependencies
package com.vgaidarji.dependencies.overview.writer
import net.steppschuh.markdowngenerator.table.Table
import org.gradle.api.artifacts.ResolvedModuleVersion
open class MarkdownWriter : DependenciesWriter> {
companion object {
const val OUTPUT_FILE_NAME = "DEPENDENCIES-OVERVIEW.md"
const val GROUP = "Group"
const val NAME = "Name"
const val VERSION = "Version"
}
override fun write(artifacts: List) {
// TODO parametrize task and print to console conditionally
writeToFile(OUTPUT_FILE_NAME, artifactsToMarkdownTable(artifacts).toString())
}
override fun write(folder: String?, artifacts: List) {
writeToFile(folder, OUTPUT_FILE_NAME, artifactsToMarkdownTable(artifacts).toString())
}
private fun artifactsToMarkdownTable(artifacts: List): Table {
val builder = Table.Builder()
.withAlignments(Table.ALIGN_LEFT, Table.ALIGN_LEFT)
.addRow(GROUP, NAME, VERSION)
artifacts.forEach {
builder.addRow(it.id.group, it.id.name, it.id.version)
}
return builder.build()
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy