Add readme task validation

This commit is contained in:
Alexander Nozik 2024-08-26 16:40:46 +03:00
parent 5c7dc3c729
commit 37e5603389
3 changed files with 49 additions and 12 deletions

View File

@ -2,7 +2,7 @@
# @pin # @pin
kotlin = "2.0.20" kotlin = "2.0.20"
# @pin # @pin
tools = "0.15.6-kotlin-2.0.20" tools = "0.15.7-kotlin-2.0.20"
atomicfu = "0.25.0" atomicfu = "0.25.0"
changelog = "2.2.1" changelog = "2.2.1"
compose = "1.6.11" compose = "1.6.11"

View File

@ -126,6 +126,8 @@ public open class KScienceProjectPlugin : Plugin<Project> {
group = "documentation" group = "documentation"
description = "Generate a README file if stub is present" description = "Generate a README file if stub is present"
inputs.property("extension", readmeExtension)
if (readmeExtension.readmeTemplate.exists()) { if (readmeExtension.readmeTemplate.exists()) {
inputs.file(readmeExtension.readmeTemplate) inputs.file(readmeExtension.readmeTemplate)
} }
@ -161,6 +163,8 @@ public open class KScienceProjectPlugin : Plugin<Project> {
} }
} }
inputs.property("extension", rootReadmeExtension)
if (rootReadmeExtension.readmeTemplate.exists()) { if (rootReadmeExtension.readmeTemplate.exists()) {
inputs.file(rootReadmeExtension.readmeTemplate) inputs.file(rootReadmeExtension.readmeTemplate)
} }
@ -185,18 +189,17 @@ public open class KScienceProjectPlugin : Plugin<Project> {
val modulesString = buildString { val modulesString = buildString {
subprojects.forEach { subproject -> subprojects.forEach { subproject ->
// val name = subproject.name // val name = subproject.name
subproject.extensions.findByType<KScienceReadmeExtension>() subproject.extensions.findByType<KScienceReadmeExtension>()?.let { ext ->
?.let { ext: KScienceReadmeExtension -> val path = subproject.path.replaceFirst(":", "").replace(":", "/")
val path = subproject.path.replaceFirst(":", "").replace(":", "/") appendLine("\n### [$path]($path)")
appendLine("\n### [$path]($path)") ext.description?.let { appendLine("> ${ext.description}") }
ext.description?.let { appendLine("> ${ext.description}") } appendLine(">\n> **Maturity**: ${ext.maturity}")
appendLine(">\n> **Maturity**: ${ext.maturity}") val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/")
val featureString = ext.featuresString(itemPrefix = "> - ", pathPrefix = "$path/") if (featureString.isNotBlank()) {
if (featureString.isNotBlank()) { appendLine(">\n> **Features:**")
appendLine(">\n> **Features:**") appendLine(featureString)
appendLine(featureString)
}
} }
}
} }
} }

View File

@ -190,4 +190,38 @@ public class KScienceReadmeExtension(public val project: Project) {
project.logger.warn("Template with name ${ex.templateName} not found in ${project.name}") project.logger.warn("Template with name ${ex.templateName} not found in ${project.name}")
null null
} }
override fun equals(other: Any?): Boolean {
if (this === other) return true
if (javaClass != other?.javaClass) return false
other as KScienceReadmeExtension
if (project != other.project) return false
if (maturity != other.maturity) return false
if (useDefaultReadmeTemplate != other.useDefaultReadmeTemplate) return false
if (readmeTemplate != other.readmeTemplate) return false
if (fmLoader != other.fmLoader) return false
if (fmCfg != other.fmCfg) return false
if (features != other.features) return false
if (properties != other.properties) return false
if (inputFiles != other.inputFiles) return false
return true
}
override fun hashCode(): Int {
var result = project.hashCode()
result = 31 * result + maturity.hashCode()
result = 31 * result + useDefaultReadmeTemplate.hashCode()
result = 31 * result + readmeTemplate.hashCode()
result = 31 * result + fmLoader.hashCode()
result = 31 * result + fmCfg.hashCode()
result = 31 * result + features.hashCode()
result = 31 * result + properties.hashCode()
result = 31 * result + inputFiles.hashCode()
return result
}
} }