<?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>ski.gagar.vxutil</groupId>
        <artifactId>vxutil-bom-internal</artifactId>
        <version>0.4.0</version>
        <relativePath>../vxutil-bom-internal</relativePath>
    </parent>

    <artifactId>vxutil-parent-base</artifactId>
    <packaging>pom</packaging>


    <name>Vxutil parent </name>
    <description>Parent POM for Vxutil which includes internal plugin configurations. Not to be used by external projects.</description>

    <properties>
        <compiler-plugin.version>3.8.1</compiler-plugin.version>
        <kotlin.plugin.version>1.6.0</kotlin.plugin.version>

        <java.version.kotlin>1.8</java.version.kotlin>
        <java.version>17</java.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <vxutil-jooq.db.driver>org.postgresql.Driver</vxutil-jooq.db.driver>
        <!--        <vxutil-jooq.db.url>jdbc:postgresql://localhost/vxuj</vxutil-jooq.db.url>-->
        <!--        <vxutil-jooq.db.username>vxuj</vxutil-jooq.db.username>-->
        <!--        <vxutil-jooq.db.password/>-->

        <vxutil-jooq.jooq.db-name>org.jooq.meta.postgres.PostgresDatabase</vxutil-jooq.jooq.db-name>
        <vxutil-jooq.jooq.generated-dir>${project.basedir}/target/generated-sources/jooq</vxutil-jooq.jooq.generated-dir>
        <vxutil-jooq.jooq.generated-package>ski.gagar.vxutil.jooq.db.model</vxutil-jooq.jooq.generated-package>
        <vxutil-jooq.jooq.schema>public</vxutil-jooq.jooq.schema>

    </properties>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${compiler-plugin.version}</version>
                    <configuration>
                        <source>${java.version}</source>
                        <target>${java.version}</target>
                        <testSource>${java.version}</testSource>
                        <testTarget>${java.version}</testTarget>
                    </configuration>
                    <executions>
                        <!-- Replacing default-compile as it is treated specially by maven -->
                        <execution>
                            <id>default-compile</id>
                            <phase>none</phase>
                        </execution>
                        <!-- Replacing default-testCompile as it is treated specially by maven -->
                        <execution>
                            <id>default-testCompile</id>
                            <phase>none</phase>
                        </execution>
                        <execution>
                            <id>java-compile</id>
                            <phase>compile</phase>
                            <goals> <goal>compile</goal> </goals>
                        </execution>
                        <execution>
                            <id>java-test-compile</id>
                            <phase>test-compile</phase>
                            <goals> <goal>testCompile</goal> </goals>
                        </execution>
                    </executions>
                </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>
                        </execution>
                    </executions>
                    <configuration>
                        <url>${vxutil-jooq.db.url}</url>
                        <user>${vxutil-jooq.db.username}</user>
                        <password>${vxutil-jooq.db.password}</password>
                        <locations>
                            <location>filesystem:src/main/resources/db/migration</location>
                        </locations>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.jetbrains.kotlin</groupId>
                    <artifactId>kotlin-maven-plugin</artifactId>
                    <version>${kotlin.plugin.version}</version>
                    <configuration>
                        <args>
                            <arg>-jvm-target</arg>
                            <arg>${java.version.kotlin}</arg>
                        </args>
                    </configuration>
                    <executions>
                        <execution>
                            <id>compile</id>
                            <phase>compile</phase>
                            <goals>
                                <goal>compile</goal>
                            </goals>
                            <configuration>
                                <sourceDirs>
                                    <sourceDir>${project.basedir}/src/main/kotlin</sourceDir>
                                    <sourceDir>${vxutil-jooq.jooq.generated-dir}</sourceDir>
                                </sourceDirs>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.jooq</groupId>
                    <artifactId>jooq-codegen-maven</artifactId>
                    <version>${jooq.version}</version>
                    <executions>
                        <execution>
                            <id>jooq-codegen</id>
                            <phase>generate-sources</phase>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                            <configuration>
                                <jdbc>
                                    <driver>${vxutil-jooq.db.driver}</driver>
                                    <url>${vxutil-jooq.db.url}</url>
                                    <user>${vxutil-jooq.db.username}</user>
                                    <password>${vxutil-jooq.db.password}</password>
                                </jdbc>
                                <generator>
                                    <database>
                                        <name>${vxutil-jooq.jooq.db-name}</name>
                                        <includes>.*</includes>
                                        <excludes />
                                        <inputSchema>${vxutil-jooq.jooq.schema}</inputSchema>
                                    </database>
                                    <generate />
                                    <target>
                                        <packageName>${vxutil-jooq.jooq.generated-package}</packageName>
                                        <directory>${vxutil-jooq.jooq.generated-dir}</directory>
                                    </target>
                                </generator>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
