in exposed-gradle-plugin/plugin-build/plugin/src/main/kotlin/com/jetbrains/exposed/gradle/plugin/ExposedGenerateCodeTask.kt [115:155]
fun generateExposedCode() {
val metadataGetter = if (connectionURL.orNull != null) {
MetadataGetter({ connectionURL.get() }, user.orNull, password.orNull, connectionProperties.orNull)
} else {
MetadataGetter(
databaseDriver.get(),
databaseName.get(),
user.orNull,
password.orNull,
host.orNull,
port.orNull,
ipv6Host.orNull,
connectionProperties.orNull
)
}
val tables = metadataGetter.getTables().filterUtilTables()
val exposedCodeGenerator = if (configFilename.orNull != null) {
ExposedCodeGenerator(tables, configFilename.get())
} else {
val config = ExposedCodeGeneratorConfiguration(
packageName.getOrElse(""),
// TODO
true,
generatedFileName.orNull,
collate.orNull,
columnMappings.getOrElse(emptyMap())
)
ExposedCodeGenerator(tables, config)
}
val files = exposedCodeGenerator.generateExposedTables()
files.forEach {
val directory = outputDirectory.get()
it.writeTo(directory.asFile)
val generatedFile = directory.file(it.toJavaFileObject().name).asFile
val generatedContent = generatedFile.readText()
generatedFile.writeText(ExposedCodeGenerator.postProcessOutput(generatedContent))
}
}