Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12

This documentation is for the unreleased development version of jOOQ. Click on the above version links to get this documentation for a supported version of jOOQ.

Whitespace (newlines and indentation)

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

By default, jOOQ's code generator produces unix newline characters (\n) and 4 space indentation (Java) or 2 space indentation (Scala). This can be overridden by using the below configuration flags. Depending on how you're loading the configuration, whitespace characters may get lost, which is why you may need to escape the backslash \ to \\. Supported escape sequences include:

  • Indentation: \t (tab) and \s (whitespace)
  • Newline: \r (carriage return) and \n (newline)
XML (standalone and maven)
Programmatic
Gradle (Kotlin)
Gradle (Groovy)
Gradle (third party)
<configuration>
  <generator>
    <generate>
      <indentation>\s\t</indentation>
      <newline>\r\n</newline>

      <!-- The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping. -->
      <printMarginForBlockComment>80</printMarginForBlockComment>
    </generate>
  </generator>
</configuration>

See the configuration XSD, standalone code generation, and maven code generation for more details.

new org.jooq.meta.jaxb.Configuration()
  .withGenerator(
    new Generate()
      .withIndentation("\\s\\t")
      .withNewline("\\r\\n")

      // The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping.
      .withPrintMarginForBlockComment(80)
  )

See the configuration XSD and programmatic code generation for more details.

import org.jooq.meta.jaxb.*


configuration {
  generator {
    generate {
      indentation = "\\s\\t"
      newline = "\\r\\n"

      // The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping.
      printMarginForBlockComment = 80
    }
  }
}

See the configuration XSD and gradle code generation for more details.

configuration {
  generator {
    generate {
      indentation = "\\s\\t"
      newline = "\\r\\n"

      // The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping.
      printMarginForBlockComment = 80
    }
  }
}

See the configuration XSD and gradle code generation for more details.

generationTool {
  generator {
    generate {
      indentation = "\\s\\t"
      newline = "\\r\\n"

      // The number of characters after which Javadoc is line-wrapped. 0 to turn off line wrapping.
      printMarginForBlockComment = 80
    }
  }
}

See the configuration XSD and gradle code generation for more details.

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo