2019-07-17 14:21:37 +03:00
|
|
|
plugins {
|
2020-09-20 22:25:50 +03:00
|
|
|
id("ru.mipt.npm.base")
|
2020-09-14 22:48:02 +03:00
|
|
|
id("org.jetbrains.changelog") version "0.4.0"
|
2019-07-17 14:21:37 +03:00
|
|
|
}
|
|
|
|
|
2020-09-20 22:25:50 +03:00
|
|
|
val kmathVersion by extra("0.2.0-dev-1")
|
|
|
|
val bintrayRepo by extra("kscience")
|
2019-07-17 14:21:37 +03:00
|
|
|
val githubProject by extra("kmath")
|
2018-11-20 22:09:07 +03:00
|
|
|
|
2019-02-22 13:52:35 +03:00
|
|
|
allprojects {
|
2019-01-04 18:12:28 +03:00
|
|
|
repositories {
|
2018-12-24 15:19:35 +03:00
|
|
|
jcenter()
|
2019-07-17 14:21:37 +03:00
|
|
|
maven("https://dl.bintray.com/kotlin/kotlinx")
|
2020-07-26 07:17:47 +03:00
|
|
|
maven("https://dl.bintray.com/hotkeytlt/maven")
|
2018-12-24 15:19:35 +03:00
|
|
|
}
|
2019-06-08 16:25:51 +03:00
|
|
|
|
2020-09-12 14:59:12 +03:00
|
|
|
group = "kscience.kmath"
|
2019-04-07 09:18:06 +03:00
|
|
|
version = kmathVersion
|
|
|
|
}
|
2019-01-31 18:19:02 +03:00
|
|
|
|
2020-09-21 15:47:47 +03:00
|
|
|
subprojects {
|
|
|
|
if (name.startsWith("kmath")) apply<ru.mipt.npm.gradle.KSciencePublishPlugin>()
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* TODO move to base plugin
|
|
|
|
*/
|
|
|
|
val generateReadme by tasks.creating {
|
|
|
|
group = "documentation"
|
|
|
|
|
|
|
|
fun List<Map<String, Any?>>.generateFeatureString(pathPrefix: String): String = buildString {
|
|
|
|
this@generateFeatureString.forEach { feature ->
|
|
|
|
val id by feature
|
|
|
|
val description by feature
|
|
|
|
val ref by feature
|
|
|
|
appendln(" - [$id]($pathPrefix$ref) : $description")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
doLast {
|
|
|
|
val reader = groovy.json.JsonSlurper()
|
|
|
|
val projects = HashMap<String, Map<String, Any?>>()
|
|
|
|
|
|
|
|
project.subprojects {
|
|
|
|
var properties: Map<String, Any?> = mapOf(
|
|
|
|
"name" to this.name,
|
|
|
|
"group" to this.group,
|
|
|
|
"version" to this.version
|
|
|
|
)
|
|
|
|
|
|
|
|
val projectProperties = this.file("docs/kscience-module.json")
|
|
|
|
|
|
|
|
@Suppress("UNCHECKED_CAST")
|
|
|
|
if (projectProperties.exists()) {
|
|
|
|
val customProperties: Map<String, Any?> =
|
|
|
|
(reader.parse(projectProperties) as? Map<String, Any?> ?: emptyMap()).withDefault { null }
|
|
|
|
val features: List<Map<String, Any?>>? by customProperties
|
|
|
|
val featureString = features?.generateFeatureString("")
|
|
|
|
properties = customProperties + properties + ("featuresString" to featureString)
|
|
|
|
}
|
|
|
|
|
|
|
|
projects[name] = properties.withDefault { null }
|
|
|
|
|
|
|
|
val readmeStub = this.file("docs/README-STUB.md")
|
|
|
|
if (readmeStub.exists()) {
|
|
|
|
val readmeFile = this.file("README.md")
|
|
|
|
readmeFile.writeText(
|
|
|
|
groovy.text.SimpleTemplateEngine().createTemplate(readmeStub).make(properties).toString()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val rootReadmeStub = project.file("docs/README-STUB.md")
|
|
|
|
|
|
|
|
val modulesString = buildString {
|
|
|
|
projects.filter { it.key.startsWith("kmath") }.forEach { (name, properties) ->
|
|
|
|
appendln("### [$name]($name)")
|
|
|
|
val features: List<Map<String, Any?>>? by properties
|
|
|
|
if (features != null) {
|
|
|
|
appendln(features!!.generateFeatureString("$name/"))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
val rootReadmeProperties: Map<String, Any> = mapOf(
|
|
|
|
"name" to project.name,
|
|
|
|
"group" to project.group,
|
|
|
|
"version" to project.version,
|
|
|
|
"modulesString" to modulesString
|
|
|
|
)
|
|
|
|
|
|
|
|
if (rootReadmeStub.exists()) {
|
|
|
|
val readmeFile = project.file("README.md")
|
|
|
|
readmeFile.writeText(
|
|
|
|
groovy.text.SimpleTemplateEngine().createTemplate(rootReadmeStub).make(rootReadmeProperties).toString()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|