Add ShadowJar compatibility and Query file can be define name with comment

Add Migration and Query definition class
Add Docker DB for tests
This commit is contained in:
2020-05-10 21:45:50 +02:00
parent df99bf4743
commit 377459f430
19 changed files with 950 additions and 98 deletions

View File

@@ -1,11 +1,38 @@
package fr.postgresjson.definition
import java.io.File
import java.net.URL
import java.nio.file.Path
interface Resource {
val name: String
val script: String
var source: File?
var source: Path?
open class ParseException(message: String, cause: Throwable? = null) : Exception(message, cause)
companion object {
fun build(file: File): Resource =
build(file.readText(), Path.of(file.toURI()))
fun build(url: URL): Resource =
build(url.readText(), Path.of(url.toURI()))
fun build(resource: String, path: Path): Resource =
try {
Function(resource, path)
} catch (e: ParseException) {
try {
Migration(resource, path)
} catch (e: ParseException) {
try {
Query(resource, path)
} catch (e: ParseException) {
throw ParseException("No SQL resource found")
}
}
}
}
}
interface ResourceCollection {