Scripts/convention/src/main/kotlin/jf.java.gradle.kts

32 lines
1.0 KiB
Plaintext
Raw Normal View History

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`
}
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()
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)
}
}
codeGenerators = null
2023-07-19 19:12:47 +02:00
}
}
tasks.compileJava { dependsOn(jfCodegen) }
tasks.processResources { dependsOn(jfCodegen) }