Skip to content

Commit

Permalink
[#1] Use PostgreSQL instead
Browse files Browse the repository at this point in the history
- The demo now uses PostgreSQL instead of CRDB (might be restored later)
- We're using testcontainers and Flyway to be independent of an actual installation
- The Sakila database has been added
- Code was re-generated
  • Loading branch information
lukaseder committed May 25, 2022
1 parent 94db77c commit b4bc48a
Show file tree
Hide file tree
Showing 447 changed files with 105,525 additions and 706 deletions.
336 changes: 336 additions & 0 deletions jOOQ-oss/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,336 @@
<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>${jooq.edition}</groupId>
<artifactId>jooq-demo-oss</artifactId>
<version>3.17.0-SNAPSHOT</version>
<name>jOOQ Demo (Open Source Edition)</name>

<licenses>
<license>
<name>Apache License, Version 2.0</name>
<url>http://www.jooq.org/inc/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jooq.edition>org.jooq</jooq.edition>
<jooq.version>3.17.0-SNAPSHOT</jooq.version>
<flyway.version>8.5.11</flyway.version>
<postgres.version>42.3.4</postgres.version>
<log4j.version>2.17.1</log4j.version>
<junit.version>4.13.2</junit.version>
<kotlin.version>1.6.21</kotlin.version>
<testcontainers.version>1.16.3</testcontainers.version>
<jetbrains.annotations.version>23.0.0</jetbrains.annotations.version>

<db.username>postgres</db.username>
<db.password>postgres</db.password>
</properties>

<dependencies>

<!-- Database access -->
<dependency>
<groupId>${jooq.edition}</groupId>
<artifactId>jooq</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgres.version}</version>
</dependency>
<dependency>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-core</artifactId>
<version>${flyway.version}</version>
</dependency>

<!-- Logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j18-impl</artifactId>
<version>${log4j.version}</version>
</dependency>

<!-- Some optional transitive dependencies -->
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>${jetbrains.annotations.version}</version>
</dependency>

<!-- Testing -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<type>jar</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
</dependency>

<!-- Kotlin -->
<dependency>
<groupId>${jooq.edition}</groupId>
<artifactId>jooq-kotlin</artifactId>
<version>${jooq.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>add-sources</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/main/kotlin</source>
</sources>
</configuration>
</execution>
<execution>
<id>add-test-sources</id>
<phase>generate-test-sources</phase>
<goals>
<goal>add-test-source</goal>
</goals>
<configuration>
<sources>
<source>src/test/kotlin</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
<source>src/main/kotlin</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/src/test/java</source>
<source>src/src/test/kotlin</source>
</sourceDirs>
</configuration>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
<configuration>
<release>17</release>
<source>17</source>
<target>17</target>
</configuration>
</plugin>

<!-- Much better if there was a testcontainers lifecycle management plugin!
Upvote here if you like the idea: https://github.com/testcontainers/testcontainers-java/issues/4397 -->
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<version>2.1.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
db = new org.testcontainers.containers.PostgreSQLContainer("postgres:latest")
.withUsername("${db.username}")
.withDatabaseName("postgres")
.withPassword("${db.password}")
db.start()
project.properties.setProperty('db.url', db.getJdbcUrl())
</source>
</configuration>
</execution>
</executions>

<dependencies>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
</dependency>
</dependencies>
</plugin>

<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>${flyway.version}</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>migrate</goal>
</goals>
<configuration>
<!-- This URL is exported by testcontainers above -->
<url>${db.url}</url>
<user>${db.username}</user>
<password>${db.password}</password>
<locations>
<location>filesystem:../sakila/postgres</location>
</locations>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>${jooq.edition}</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>${jooq.version}</version>

<configuration>
<jdbc>
<driver>org.postgresql.Driver</driver>
<!-- This URL is exported by testcontainers above -->
<url>${db.url}</url>
<user>${db.username}</user>
<password>${db.password}</password>
</jdbc>
<generator>
<database>
<inputSchema>public</inputSchema>
<excludes>flyway_.*</excludes>
</database>
<generate>
<pojos>true</pojos>
<pojosToString>false</pojosToString>
<pojosEqualsAndHashCode>false</pojosEqualsAndHashCode>
<daos>true</daos>
</generate>
</generator>
</configuration>

<executions>
<execution>
<id>generate-demo-java</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generator>
<generate>
<pojosAsJavaRecordClasses>true</pojosAsJavaRecordClasses>
</generate>
<target>
<packageName>org.jooq.demo.java.db</packageName>

<!-- We're version controlling the source code for better documentation on github, etc.
This isn't necessary, though, see also:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-version-control/ -->
<directory>src/main/java</directory>
</target>
</generator>
</configuration>
</execution>

<execution>
<id>generate-demo-kotlin</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<generator>
<name>org.jooq.codegen.KotlinGenerator</name>
<target>
<packageName>org.jooq.demo.kotlin.db</packageName>

<!-- We're version controlling the source code for better documentation on github, etc.
This isn't necessary, though, see also:
https://www.jooq.org/doc/latest/manual/code-generation/codegen-version-control/ -->
<directory>src/main/kotlin</directory>
</target>
</generator>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
54 changes: 54 additions & 0 deletions jOOQ-oss/src/main/java/org/jooq/demo/java/db/DefaultCatalog.java

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b4bc48a

Please sign in to comment.