All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.vgaidarji.dependencies.overview.writer.MarkdownWriter.kt Maven / Gradle / Ivy

Go to download

Generates project dependencies overview report (JSON, Markdown, etc.) from project dependencies

There is a newer version: 1.0.1
Show newest version
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