0.9.0 #11

Merged
altavir merged 18 commits from dev into master 2021-03-07 09:59:51 +03:00
2 changed files with 9 additions and 8 deletions
Showing only changes of commit a871db0c15 - Show all commits

View File

@ -128,7 +128,7 @@ open class KScienceProjectPlugin : Plugin<Project> {
} }
val rootReadmeProperties: Map<String, Any?> = val rootReadmeProperties: Map<String, Any?> =
rootReadmeExtension.properties + ("modules" to modulesString) rootReadmeExtension.actualizedProperties + ("modules" to modulesString)
readmeFile.writeText( readmeFile.writeText(
SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate) SimpleTemplateEngine().createTemplate(rootReadmeExtension.readmeTemplate)

View File

@ -46,30 +46,31 @@ class KScienceReadmeExtension(val project: Project) {
features.add(Feature(id, description(), ref, name)) features.add(Feature(id, description(), ref, name))
} }
val properties: MutableMap<String, () -> Any?> = mutableMapOf( private val properties: MutableMap<String, () -> Any?> = mutableMapOf(
"name" to { project.name }, "name" to { project.name },
"group" to { project.group }, "group" to { project.group },
"version" to { project.version }, "version" to { project.version },
"features" to { featuresString() } "features" to { featuresString() }
) )
private fun getActualizedProperties() = properties.mapValues { (_, value) -> val actualizedProperties
value.invoke() get() = properties.mapValues { (_, value) ->
} value.invoke()
}
fun property(key: String, value: Any?) { fun property(key: String, value: Any?) {
properties[key] = { value } properties[key] = { value }
} }
fun propertyByTemplate(key: String, template: String) { fun propertyByTemplate(key: String, template: String) {
val actual = getActualizedProperties() val actual = actualizedProperties
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() } properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
} }
internal val additionalFiles = ArrayList<File>() internal val additionalFiles = ArrayList<File>()
fun propertyByTemplate(key: String, template: File) { fun propertyByTemplate(key: String, template: File) {
val actual = getActualizedProperties() val actual = actualizedProperties
properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() } properties[key] = { SimpleTemplateEngine().createTemplate(template).make(actual).toString() }
additionalFiles.add(template) additionalFiles.add(template)
} }
@ -88,7 +89,7 @@ class KScienceReadmeExtension(val project: Project) {
*/ */
fun readmeString(): String? { fun readmeString(): String? {
return if (readmeTemplate.exists()) { return if (readmeTemplate.exists()) {
val actual = getActualizedProperties() val actual = actualizedProperties
SimpleTemplateEngine().createTemplate(readmeTemplate).make(actual).toString() SimpleTemplateEngine().createTemplate(readmeTemplate).make(actual).toString()
} else { } else {
null null