All Projects → revolut-engineering → jooq-plugin

revolut-engineering / jooq-plugin

Licence: Apache-2.0 License
Plugin for generating jOOQ classes using dockerized databases

Programming Languages

groovy
2714 projects
java
68154 projects - #9 most used programming language
kotlin
9241 projects

Projects that are alternatives of or similar to jooq-plugin

gradle-localization-plugin
Gradle plugin for automating the download process of localization files.
Stars: ✭ 19 (-65.45%)
Mutual labels:  gradle, gradle-plugin, gradle-kotlin-dsl
gradle-cleaner-intellij-plugin
Force clear delaying & no longer needed Gradle tasks.
Stars: ✭ 26 (-52.73%)
Mutual labels:  gradle, gradle-plugin
kosogor
Defaults and simplified Kotlins-DSL interfaces for Gradle
Stars: ✭ 18 (-67.27%)
Mutual labels:  gradle-plugin, gradle-kotlin-dsl
gradle-libraries-plugin
No description or website provided.
Stars: ✭ 29 (-47.27%)
Mutual labels:  gradle, gradle-plugin
Maven Git Versioning Extension
This extension will virtually set project versions, based on current git branch or tag.
Stars: ✭ 178 (+223.64%)
Mutual labels:  gradle, gradle-plugin
Gradle Testsets Plugin
A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
Stars: ✭ 182 (+230.91%)
Mutual labels:  gradle, gradle-plugin
sphinx-gradle-plugin
Sphinx site generation plugin for Gradle
Stars: ✭ 19 (-65.45%)
Mutual labels:  gradle, gradle-plugin
Gradle Android Plugin
[Deprecated] Gradle Android Plugin 中文版使用手册,如有纰漏,望斧正
Stars: ✭ 155 (+181.82%)
Mutual labels:  gradle, gradle-plugin
gatling-gradle-plugin-demo
Showcase of the Gatling Plugin for Gradle
Stars: ✭ 17 (-69.09%)
Mutual labels:  gradle, gradle-plugin
gradle-helm-plugin
A Gradle plugin for building, publishing and managing Helm charts.
Stars: ✭ 42 (-23.64%)
Mutual labels:  gradle, gradle-plugin
RocketXPlugin
🔥🔥 android 端编译加速插件🚀 自动识别未改动 module 并在编译流程中替换为 aar ,只编译改动模块,加速 Android apk 的编译速度。
Stars: ✭ 408 (+641.82%)
Mutual labels:  gradle, gradle-plugin
Gradle Launch4j
A gradle-plugin to create windows executables with launch4j
Stars: ✭ 177 (+221.82%)
Mutual labels:  gradle, gradle-plugin
Click Debounce
Using ASM to handle Android's click debounce, specially a quick double click.
Stars: ✭ 175 (+218.18%)
Mutual labels:  gradle, gradle-plugin
Badass Jlink Plugin
Create a custom runtime image of your modular application
Stars: ✭ 216 (+292.73%)
Mutual labels:  gradle, gradle-plugin
Versioning
Gradle plug-in to generate version information from the SCM branch (Git or Svn)
Stars: ✭ 157 (+185.45%)
Mutual labels:  gradle, gradle-plugin
sonatype-publish-plugin
Gradle Plugin for publishing artifacts to Sonatype and Nexus
Stars: ✭ 17 (-69.09%)
Mutual labels:  gradle, gradle-plugin
Gradle Pitest Plugin
Gradle plugin for PIT Mutation Testing
Stars: ✭ 144 (+161.82%)
Mutual labels:  gradle, gradle-plugin
Gradle Aem Plugin
Swiss army knife for Adobe Experience Manager related automation. Environment setup & incremental AEM application build which takes seconds, not minutes.
Stars: ✭ 145 (+163.64%)
Mutual labels:  gradle, gradle-plugin
gradle-build-info-plugin
Gradle plugin to include build information such as Git commit ID to your JAR. It can be used to show Git commit information with Spring Boot Actuator.
Stars: ✭ 33 (-40%)
Mutual labels:  gradle, gradle-plugin
SetupBuilder
Gradle plugin for building setups for different platforms.
Stars: ✭ 75 (+36.36%)
Mutual labels:  gradle, gradle-plugin

Gradle Docker jOOQ Plugin

Build Status codecov Gradle Plugins Release

This repository contains Gradle plugin for generating jOOQ classes in dockerized databases. Plugin registers task generateJooqClasses that does following steps:

  • pulls docker image
  • starts database container
  • runs migrations using Flyway
  • generates jOOQ classes

Use:

  • 0.3.x and later for jOOQ versions 3.12.x and later
  • 0.2.x and later releases for jOOQ versions 3.11.x and later
  • For earlier versions use 0.1.x release

Examples

By default plugin is configured to work with PostgreSQL, so the following minimal config is enough:

plugins {
  id("com.revolut.jooq-docker")
}

repositories {
  mavenCentral()
}

dependencies {
  implementation("org.jooq:jooq:3.14.8")
  jdbc("org.postgresql:postgresql:42.2.5")
}

It will look for migration files in src/main/resources/db/migration and will output generated classes to build/generated-jooq in package org.jooq.generated. All of that details can be configured on the task itself as shown in examples below.

Configuring schema names and other parameters of the task:

plugins {
  id("com.revolut.jooq-docker")
}

repositories {
  mavenCentral()
}

tasks {
  generateJooqClasses {
    schemas = arrayOf("public", "other_schema")
    basePackageName = "org.jooq.generated"
    inputDirectory.setFrom(project.files("src/main/resources/db/migration"))
    outputDirectory.set(project.layout.buildDirectory.dir("generated-jooq"))
    flywayProperties = mapOf("flyway.placeholderReplacement" to "false")
    excludeFlywayTable = true
    outputSchemaToDefault = setOf("public")
    schemaToPackageMapping = mapOf("public" to "fancy_name")
    customizeGenerator {
      /* "this" here is the org.jooq.meta.jaxb.Generator configure it as you please */
    }
  }
}

dependencies {
  implementation("org.jooq:jooq:3.14.8")
  jdbc("org.postgresql:postgresql:42.2.5")
}

To configure the plugin to work with another DB like MySQL following config can be applied:

plugins {
  id("com.revolut.jooq-docker")
}

repositories {
  mavenCentral()
}

jooq {
  image {
      repository = "mysql"
      tag = "8.0.15"
      envVars = mapOf(
          "MYSQL_ROOT_PASSWORD" to "mysql",
          "MYSQL_DATABASE" to "mysql")
      containerName = "uniqueMySqlContainerName"
      readinessProbe = { host: String, port: Int ->
          arrayOf("sh", "-c", "until mysqladmin -h$host -P$port -uroot -pmysql ping; do echo wait; sleep 1; done;")
      }
  }
  
  db {
      username = "root"
      password = "mysql"
      name = "mysql"
      port = 3306
  }
  
  jdbc {
      schema = "jdbc:mysql"
      driverClassName = "com.mysql.cj.jdbc.Driver"
      jooqMetaName = "org.jooq.meta.mysql.MySQLDatabase"
      urlQueryParams = "?useSSL=false"
  }
}

dependencies {
  implementation("org.jooq:jooq:3.14.8")
  jdbc("mysql:mysql-connector-java:8.0.15")
}

To register custom types:

plugins {
  id("com.revolut.jooq-docker")
}

repositories {
  mavenCentral()
}

tasks {
  generateJooqClasses {
    customizeGenerator {
      database.withForcedTypes(
              ForcedType()
                      .withUserType("com.google.gson.JsonElement")
                      .withBinding("com.example.PostgresJSONGsonBinding")
                      .withTypes("JSONB")
      )
    }    
  }
}

dependencies {
  implementation("org.jooq:jooq:3.14.8")
  jdbc("org.postgresql:postgresql:42.2.5")
}

To exclude flyway schema history table from generated classes:

plugins {
  id("com.revolut.jooq-docker")
}

repositories {
  mavenCentral()
}

tasks {
  generateJooqClasses {
    schemas = arrayOf("other")
    customizeGenerator {
      database.withExcludes("flyway_schema_history")
    }
  }
}

dependencies {
  implementation("org.jooq:jooq:3.14.8")
  jdbc("org.postgresql:postgresql:42.2.5")
}

To enforce version of the plugin dependencies:

plugins {
  id("com.revolut.jooq-docker")
}

buildscript {
  repositories {
    mavenCentral()
  }

  dependencies {
    classpath("org.jooq:jooq-codegen:3.12.0") {
      isForce = true
    }
  }
}

repositories {
  mavenCentral()
}

dependencies {
  implementation("org.jooq:jooq:3.12.0")
  jdbc("org.postgresql:postgresql:42.2.5")
}

Remote docker setup

The library plugin uses to communicate with docker daemon will pick up your environment variables like DOCKER_HOST and use them for connection (all config options here). Plugin then, based on this config, will try to figure out the host on which database is exposed, if it fail you can override it the following way:

plugins {
  id("com.revolut.jooq-docker")
}


jooq {
    db {
        hostOverride = "localhost"
    }
}

For the readiness probe plugin will always use localhost 127.0.0.1 as it's a command run within the database container. If for whatever reason you need to override this you can do that by specifying it as follows:

 plugins {
   id("com.revolut.jooq-docker")
 }
 
 
 jooq {
    image {
        readinessProbeHost = "someHost"
    }
 }
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].