Created
June 19, 2014 10:32
-
-
Save schoenobates/20aa086813595892b31a to your computer and use it in GitHub Desktop.
JOOQ Generator Gradle
This file contains hidden or 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
import org.jooq.util.jaxb.* | |
import org.jooq.util.* | |
ext.db = [ | |
url: 'jdbc:postgresql://host/db', | |
user: 'user', | |
password: 'user', | |
schema: 'schema' | |
] | |
ext.genpath = new File("${projectDir}/src/main/java/com/example/db") | |
buildscript { | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
classpath group: 'org.jooq', name: 'jooq', version: '3.3.+' | |
classpath group: 'org.jooq', name: 'jooq-meta', version: '3.3.+' | |
classpath group: 'org.jooq', name: 'jooq-codegen', version: '3.3.+' | |
classpath group: 'postgresql', name: 'postgresql', version: '9.1-901.jdbc4' | |
} | |
} | |
task gencode() { | |
if (!genpath.exists()) { | |
genpath.mkdirs() | |
} | |
Configuration configuration = new Configuration() | |
.withJdbc(new Jdbc() | |
.withDriver("org.postgresql.Driver") | |
.withUrl(db.url) | |
.withUser(db.user) | |
.withPassword(db.password) | |
) | |
.withGenerator(new Generator() | |
.withName("org.jooq.util.DefaultGenerator") | |
.withDatabase(new Database() | |
.withName("org.jooq.util.postgres.PostgresDatabase") | |
.withIncludes(".*") | |
.withExcludes("") | |
.withInputSchema(db.schema) | |
) | |
.withTarget(new Target() | |
.withPackageName("com.example.db") | |
.withDirectory("${projectDir}/src/main/java") | |
) | |
); | |
GenerationTool.main(configuration); | |
} | |
task delgencode(type: Delete) { | |
delete genpath | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
good