-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
45947ce
commit 7c43fb9
Showing
17 changed files
with
430 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,100 @@ | ||
# jooq-testcontainers-codegen-maven-plugin | ||
jOOQ code generator using Testcontainers | ||
|
||
## CREDITS: | ||
This plugin is heavily based on official https://github.com/jOOQ/jOOQ/tree/main/jOOQ-codegen-maven. | ||
The `jooq-testcontainers-codegen-maven-plugin` simplifies the jOOQ code generation | ||
by using [Testcontainers](https://www.testcontainers.org/) and applying Flyway database migrations. | ||
|
||
## Supported databases: | ||
* Postgres | ||
* MySQL | ||
* MariaDB | ||
|
||
## How to use? | ||
The plugin is not yet published to maven central. So, you need to first install the plugin locally. | ||
|
||
```shell | ||
$ git clone https://github.com/sivalabs/jooq-testcontainers-codegen-maven-plugin.git | ||
$ cd jooq-testcontainers-codegen-maven-plugin | ||
$ ./mvnw clean install | ||
1. **With PostgreSQL and Flyway migrations** | ||
|
||
```xml | ||
<project> | ||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<testcontainers.version>1.18.0</testcontainers.version> | ||
<jooq-testcontainers-codegen-maven-plugin.version>0.0.2</jooq-testcontainers-codegen-maven-plugin.version> | ||
<jooq.version>3.18.3</jooq.version> | ||
<postgres.version>42.6.0</postgres.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jooq</groupId> | ||
<artifactId>jooq</artifactId> | ||
<version>${jooq.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.github.sivalabs</groupId> | ||
<artifactId>jooq-testcontainers-codegen-maven-plugin</artifactId> | ||
<version>${jooq-testcontainers-codegen-maven-plugin.version}</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<version>${testcontainers.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.postgresql</groupId> | ||
<artifactId>postgresql</artifactId> | ||
<version>${postgres.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<executions> | ||
<execution> | ||
<id>generate-jooq-sources</id> | ||
<goals> | ||
<goal>generate</goal> | ||
</goals> | ||
<phase>generate-sources</phase> | ||
<configuration> | ||
<database> | ||
<type>POSTGRES</type> | ||
<containerImage>postgres:15.2-alpine</containerImage> | ||
</database> | ||
<flyway> | ||
<locations> | ||
filesystem:src/main/resources/db/migration/postgres, | ||
filesystem:src/main/resources/db/migration/postgresql | ||
</locations> | ||
</flyway> | ||
<generator> | ||
<database> | ||
<includes>.*</includes> | ||
<excludes>flyway_schema_history</excludes> | ||
<inputSchema>public</inputSchema> | ||
</database> | ||
<target> | ||
<packageName>org.jooq.codegen.maven.example</packageName> | ||
<directory>target/generated-sources/jooq</directory> | ||
</target> | ||
</generator> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> | ||
``` | ||
|
||
Try with example application | ||
|
||
```shell | ||
$ cd example | ||
$ ./mvnw clean package | ||
$ cd examples/postgres-flyway-example | ||
$ mvn clean package | ||
``` | ||
|
||
The JOOQ code should be generated under example/target/generated-sources/jooq folder. | ||
|
||
## CREDITS: | ||
This plugin is heavily based on official https://github.com/jOOQ/jOOQ/tree/main/jOOQ-codegen-maven. |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.sivalabs.jooqtc</groupId> | ||
<artifactId>mariadb-flyway-example</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<testcontainers.version>1.18.0</testcontainers.version> | ||
<jooq-testcontainers-codegen-maven-plugin.version>0.0.2</jooq-testcontainers-codegen-maven-plugin.version> | ||
<jooq.version>3.18.3</jooq.version> | ||
<mariadb-java-client.version>3.1.2</mariadb-java-client.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jooq</groupId> | ||
<artifactId>jooq</artifactId> | ||
<version>${jooq.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.github.sivalabs</groupId> | ||
<artifactId>jooq-testcontainers-codegen-maven-plugin</artifactId> | ||
<version>${jooq-testcontainers-codegen-maven-plugin.version}</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>mariadb</artifactId> | ||
<version>${testcontainers.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.mariadb.jdbc</groupId> | ||
<artifactId>mariadb-java-client</artifactId> | ||
<version>${mariadb-java-client.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<executions> | ||
<execution> | ||
<id>generate-jooq-sources</id> | ||
<goals> | ||
<goal>generate</goal> | ||
</goals> | ||
<phase>generate-sources</phase> | ||
<configuration> | ||
<database> | ||
<type>MARIADB</type> | ||
<containerImage>mariadb:10.11</containerImage> | ||
</database> | ||
<flyway> | ||
<locations> | ||
filesystem:src/main/resources/db/migration/mariadb | ||
</locations> | ||
</flyway> | ||
<!-- Generator parameters --> | ||
<generator> | ||
<database> | ||
<includes>.*</includes> | ||
<excludes>flyway_schema_history</excludes> | ||
<inputSchema>test</inputSchema> | ||
</database> | ||
<target> | ||
<packageName>org.jooq.codegen.maven.example</packageName> | ||
<directory>target/generated-sources/jooq</directory> | ||
</target> | ||
</generator> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 | ||
http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.sivalabs.jooqtc</groupId> | ||
<artifactId>mysql-flyway-example</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<maven.compiler.source>17</maven.compiler.source> | ||
<maven.compiler.target>17</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
<testcontainers.version>1.18.0</testcontainers.version> | ||
<jooq-testcontainers-codegen-maven-plugin.version>0.0.2</jooq-testcontainers-codegen-maven-plugin.version> | ||
<jooq.version>3.18.3</jooq.version> | ||
<mysql-connector-j.version>8.0.32</mysql-connector-j.version> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.jooq</groupId> | ||
<artifactId>jooq</artifactId> | ||
<version>${jooq.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>io.github.sivalabs</groupId> | ||
<artifactId>jooq-testcontainers-codegen-maven-plugin</artifactId> | ||
<version>${jooq-testcontainers-codegen-maven-plugin.version}</version> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.testcontainers</groupId> | ||
<artifactId>mysql</artifactId> | ||
<version>${testcontainers.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.mysql</groupId> | ||
<artifactId>mysql-connector-j</artifactId> | ||
<version>${mysql-connector-j.version}</version> | ||
</dependency> | ||
</dependencies> | ||
<executions> | ||
<execution> | ||
<id>generate-jooq-sources</id> | ||
<goals> | ||
<goal>generate</goal> | ||
</goals> | ||
<phase>generate-sources</phase> | ||
<configuration> | ||
<database> | ||
<type>MYSQL</type> | ||
<containerImage>mysql:8.0.33</containerImage> | ||
</database> | ||
<flyway> | ||
<locations> | ||
filesystem:src/main/resources/db/migration/mysql | ||
</locations> | ||
</flyway> | ||
<!-- Generator parameters --> | ||
<generator> | ||
<database> | ||
<includes>.*</includes> | ||
<excludes>flyway_schema_history</excludes> | ||
<inputSchema>test</inputSchema> | ||
</database> | ||
<target> | ||
<packageName>org.jooq.codegen.maven.example</packageName> | ||
<directory>target/generated-sources/jooq</directory> | ||
</target> | ||
</generator> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
Oops, something went wrong.