kxbmap / sbt-jooq

jOOQ plugin for SBT 1.0+



Build Status

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

// 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 :=
    <!-- Your configurations -->


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)

jOOQ-codegen configuration text substitution

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">
        <!-- ...snip... -->
        <!-- ...snip... -->

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">
        <!-- ...snip... -->
        <!-- ...snip... -->


Copyright 2015-2018 Tsukasa Kitachi

Apache License, Version 2.0