jOOQ plugin for sbt 1.0+
Add the following to your project/plugins.sbt
:
addSbtPlugin("com.github.kxbmap" % "sbt-jooq" % "0.4.1")
Then in your build.sbt
:
// Enable the plugin
enablePlugins(JooqCodegen)
// Add your database driver dependency to `jooq` scope
libraryDependencies += "com.h2database" % "h2" % "1.4.197" % "jooq"
Version of jOOQ library.
Default: "3.11.5"
jooqVersion := "3.11.5"
jOOQ organization/group ID.
If you want to use commercial version of jOOQ, set appropriate one. For details, please refer to the jOOQ manual.
Default: "org.jooq"
jooqOrganization := "org.jooq"
Add jOOQ dependencies automatically if true.
If you want to manage jOOQ dependencies manually, set this flag to false.
Default: true
autoJooqLibrary := true
jOOQ-codegen configuration. Set file or classpath resource or XML directly.
// Set file path
jooqCodegenConfig := baseDirectory.value / "jooq-codegen.xml"
// Set classpath resource using String prefixed by `classpath:`
jooqCodegenConfig := "classpath:jooq-codegen.xml"
// Set XML configuration
jooqCodegenConfig :=
<configuration>
<!-- Your configurations -->
</configuration>
jOOQ-codegen auto execution strategy.
Value | Description |
---|---|
IfAbsent |
Execute if absent files in jOOQ-codegen target directory |
Always |
Always execute |
Never |
Never execute |
Default: CodegenStrategy.IfAbsent
jooqCodegenStrategy := CodegenStrategy.IfAbsent
Keys for jOOQ-codegen configuration text substitution.
For details, please refer the below section.
Default: sys.env ++ Seq(baseDirectory, sourceManaged in Compile)
jooqCodegenKeys ++= Seq[CodegenKey](
scalaVersion, // Setting key
skip in publish, // Task key
"Answer" -> 42 // constant
)
You can confirm substitution values using jooqCodegenSubstitutions
.
> show jooqCodegenSubstitutions
* ...Env vars...
* (baseDirectory, /path/to/base-directory)
* (compile:sourceManaged, /path/to/source-managed)
* (sourceManaged, /path/to/source-managed)
* (scalaVersion, 2.12.6)
* (publish::skip, false)
* (Answer, 42)
You can substitute text using placeholder(${KEY}
) in configuration file.
e.g. Configuration file contains some placeholders:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
<jdbc>
<!-- ...snip... -->
<user>${DB_USER}</user>
<password>${DB_PASSWORD}</password>
</jdbc>
<generator>
<!-- ...snip... -->
<target>
<packageName>com.example</packageName>
<directory>${sourceManaged}</directory>
</target>
</generator>
</configuration>
Plugin replace placeholders to substitution values:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
<jdbc>
<!-- ...snip... -->
<user>your-user</user>
<password>your-password</password>
</jdbc>
<generator>
<!-- ...snip... -->
<target>
<packageName>com.example</packageName>
<directory>/path/to/source-managed</directory>
</target>
</generator>
</configuration>
Copyright 2015-2018 Tsukasa Kitachi
Apache License, Version 2.0