Created
December 3, 2015 17:08
-
-
Save danhyun/683caf30146910d81d64 to your computer and use it in GitHub Desktop.
jOOQ code gen from properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
classpath 'org.postgresql:postgresql:9.4-1206-jdbc42' | |
classpath 'org.jooq:jooq-codegen:3.7.1' | |
classpath 'org.jyaml:jyaml:1.3' | |
} | |
} | |
import org.jooq.util.jaxb.* | |
import org.jooq.util.* | |
import org.ho.yaml.Yaml | |
task jooqCodegen { | |
doLast { | |
def config = Yaml.load(file('src/ratpack/db.yaml')).db | |
def dsProps = config.dataSourceProperties | |
Configuration configuration = new Configuration() | |
.withJdbc(new Jdbc() | |
.withDriver("org.postgresql.Driver") | |
.withUrl("jdbc:postgresql://$dsProps.serverName:$dsProps.portNumber/$dsProps.databaseName") | |
.withUser(config.username) | |
.withPassword(config.password)) | |
.withGenerator(new Generator() | |
.withDatabase(new Database() | |
.withName("org.jooq.util.postgres.PostgresDatabase") | |
.withIncludes(".*") | |
.withExcludes("") | |
.withInputSchema("public")) | |
.withTarget(new Target() | |
.withPackageName("jooq") | |
.withDirectory("src/main/java"))) | |
GenerationTool.generate(configuration) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
db: | |
dataSourceClassName: org.postgresql.ds.PGSimpleDataSource | |
username: postgres | |
password: password | |
dataSourceProperties: | |
databaseName: modern | |
portNumber: 5432 | |
serverName: 192.168.99.101 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, Dan.
If we
We'll get warning
To get rid of that, simply