2023-07-19 19:12:47 +02:00
|
|
|
import io.gitlab.jfronny.scripts.ContentGenerator
|
|
|
|
import io.gitlab.jfronny.scripts.codegenDir
|
|
|
|
|
|
|
|
plugins {
|
|
|
|
id("jf.base")
|
|
|
|
`java-library`
|
|
|
|
}
|
|
|
|
|
2024-02-19 14:32:14 +01:00
|
|
|
var codeGenerators: MutableMap<String, ContentGenerator.Generated>? by extra(LinkedHashMap())
|
2023-07-19 19:12:47 +02:00
|
|
|
|
|
|
|
val jfCodegen by tasks.registering {
|
|
|
|
doLast {
|
|
|
|
if (codegenDir.exists()) codegenDir.deleteRecursively()
|
2024-02-19 14:32:14 +01:00
|
|
|
codeGenerators!!.forEach { (name, generated) ->
|
2023-07-19 19:12:47 +02:00
|
|
|
generated.classes.forEach { (filePath, content) ->
|
|
|
|
val path = codegenDir.resolve("java").resolve(name).resolve(filePath)
|
|
|
|
path.parentFile.mkdirs()
|
|
|
|
path.writeText(content)
|
|
|
|
}
|
|
|
|
generated.resources.forEach { (filePath, content) ->
|
|
|
|
val path = codegenDir.resolve("resources").resolve(name).resolve(filePath)
|
|
|
|
path.parentFile.mkdirs()
|
|
|
|
path.writeBytes(content)
|
|
|
|
}
|
|
|
|
}
|
2024-02-19 14:32:14 +01:00
|
|
|
codeGenerators = null
|
2023-07-19 19:12:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.compileJava { dependsOn(jfCodegen) }
|
|
|
|
|
|
|
|
tasks.processResources { dependsOn(jfCodegen) }
|