kxbmap / sbt-jooq

jOOQ plugin for SBT 1.0+

Version Matrix


Build Status

jOOQ plugin for sbt 1.0+



Add the following to your project/plugins.sbt:

addSbtPlugin("com.github.kxbmap" % "sbt-jooq-codegen" % "0.5.1")

Then in your build.sbt:

// Enable the plugin

// Add your database driver dependency to `jooq-codegen` scope
libraryDependencies += "com.h2database" % "h2" % "1.4.200" % JooqCodegen



Version of jOOQ library.

Default: "3.13.2"

jooqVersion := "3.13.2"


jOOQ organization/group ID.

If you want to use a 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. This is empty by default and must be set. You can set a file, classpath resource, or XML directly.

// Set file path
jooqCodegenConfig := file("jooq-codegen.xml")
// Set URI of classpath resource
jooqCodegenConfig := uri("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.13.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.13.0.xsd">
        <!-- ...snip... -->
        <!-- ...snip... -->


Copyright 2015-2018 Tsukasa Kitachi

Apache License, Version 2.0