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

com.github.squirrelgrip.plugin.AbstractDoxiaReport.kt Maven / Gradle / Ivy

There is a newer version: 2.0.0
Show newest version
package com.github.squirrelgrip.plugin

import com.fasterxml.jackson.databind.module.SimpleModule
import com.github.squirrelgrip.extension.xml.Xml
import com.github.squirrelgrip.plugin.model.Version
import com.github.squirrelgrip.plugin.serial.VersionDeserializer
import org.apache.maven.reporting.AbstractMavenReport
import org.apache.maven.reporting.MavenReportException
import java.util.*

abstract class AbstractDoxiaReport : AbstractMavenReport() {
    abstract val reportHeading: String

    abstract fun body(locale: Locale)

    abstract fun logParameters()

    override fun executeReport(locale: Locale) {
        logParameters()
        if (sink == null) {
            throw MavenReportException("Could not get the Doxia sink")
        }

        sink.head()
        sink.title()
        sink.text(reportHeading)
        sink.title_()
        sink.head_()
        sink.body()
        sink.section1()
        sink.sectionTitle1()
        sink.text(reportHeading)
        sink.sectionTitle1_()

        body(locale)

        sink.section1_()
        sink.body_()
        sink.footer()
        sink.footer_()
    }

    init {
        Xml.xmlMapper.registerModule(
            SimpleModule().apply {
                addDeserializer(
                    Version::class.java,
                    VersionDeserializer()
                )
            }
        )
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy