<?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>
    <parent>
        <groupId>fr.ght1pc9kc</groupId>
        <artifactId>testy-box</artifactId>
        <version>2.0.2</version>
    </parent>

    <artifactId>testy-jooq-box</artifactId>

    <name>Testy jOOQ Box</name>

    <dependencies>
        <dependency>
            <groupId>fr.ght1pc9kc</groupId>
            <artifactId>testy-core-box</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.inject</groupId>
            <artifactId>jakarta.inject-api</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>


        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains</groupId>
            <artifactId>annotations</artifactId>
        </dependency>

        <!--SQL-->
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jooq</groupId>
            <artifactId>jooq</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>

        <!--TEST-->
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <db.driver>org.h2.Driver</db.driver>
        <db.url>jdbc:h2:file:${project.build.directory}/jooq_testy.db</db.url>
        <db.username>security</db.username>
        <db.password>security</db.password>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.flywaydb</groupId>
                <artifactId>flyway-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>flyway-jooq</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>migrate</goal>
                        </goals>
                        <configuration>
                            <url>${db.url}</url>
                            <user>${db.username}</user>
                            <password>${db.password}</password>
                            <placeholderReplacement>false</placeholderReplacement>
                            <locations>
                                <location>filesystem:${project.basedir}/src/test/resources/db/migration/dummy</location>
                            </locations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jooq</groupId>
                <artifactId>jooq-codegen-maven</artifactId>
                <executions>
                    <execution>
                        <id>jooq-codegen</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <logging>ERROR</logging>
                            <jdbc>
                                <driver>${db.driver}</driver>
                                <url>${db.url}</url>
                                <user>${db.username}</user>
                                <password>${db.password}</password>
                            </jdbc>
                            <generator>
                                <database>
                                    <name>org.jooq.meta.h2.H2Database</name>
                                    <includes>.*</includes>
                                    <excludes>FLYWAY_SCHEMA_HISTORY</excludes>
                                    <outputSchemaToDefault>false</outputSchemaToDefault>
                                </database>
                                <generate>
                                    <generatedAnnotation>true</generatedAnnotation>
                                    <records>true</records>
                                    <fluentSetters>true</fluentSetters>
                                </generate>
                                <target>
                                    <packageName>fr.ght1pc9kc.testy.dsl</packageName>
                                    <directory>target/generated-test-sources</directory>
                                </target>
                            </generator>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-test-resource</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${project.build.directory}/generated-test-sources</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>