<?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>io.smallrye.reactive</groupId>
        <artifactId>vertx-mutiny-clients</artifactId>
        <version>4.0.0</version>
    </parent>


    <artifactId>smallrye-mutiny-vertx-sql-client</artifactId>
    <name>SmallRye Mutiny - Vert.x SQL Client</name>

    <properties>
        <gen-source-groupId>io.vertx</gen-source-groupId>
        <gen-source-artifactId>vertx-sql-client</gen-source-artifactId>
        <gen.output>${project.build.directory}/sources/java</gen.output>
        <gen-module>vertx-sql-client</gen-module>
    </properties>

    <dependencies>
        <!-- Generation source -->
        <dependency>
            <groupId>${gen-source-groupId}</groupId>
            <artifactId>${gen-source-artifactId}</artifactId>
            <version>${vertx.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Vert.x mutiny Core -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>smallrye-mutiny-vertx-core</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>${testcontainers.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <configuration>
                    <includeGroupIds>${gen-source-groupId}</includeGroupIds>
                    <includeArtifactIds>${gen-source-artifactId}</includeArtifactIds>
                    <classifier>sources</classifier>
                    <includeTypes>jar</includeTypes>
                </configuration>
                <executions>
                    <!-- Unpack java sources to target/java-sources -->
                    <execution>
                        <id>unpack-java</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includes>io/vertx/**/*.java</includes>
                            <excludes>**/impl/**/*.java</excludes>
                            <outputDirectory>${gen.output}</outputDirectory>
                        </configuration>
                    </execution>

                    <execution>
                        <id>unpack-vertx-core</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includes>io/vertx/**/*.java</includes>
                            <excludes>**/impl/**/*.java</excludes>
                            <includeArtifactIds>vertx-core</includeArtifactIds>
                            <outputDirectory>${project.basedir}/target/additional-sources/vertx-core</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Automatic-Module-Name>io.smallrye.mutiny.vertx.sql.client</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>${exec-maven-plugin.version}</version>
                <configuration>

                </configuration>
                <executions>
                    <execution>
                        <id>generate</id>
                        <phase>
                            generate-sources
                        </phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>io.smallrye.mutiny.vertx.apigenerator.Main</mainClass>
                            <arguments>
                                <arg>--module-name=${gen-module}</arg>
                                <arg>--source=${project.basedir}/target/sources</arg>
                                <arg>--output=${project.basedir}/target/generated-sources/codegen</arg>
                                <arg>--additional-source=${project.basedir}/target/additional-sources/vertx-core</arg>
                            </arguments>
                            <includePluginDependencies>true</includePluginDependencies>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>io.smallrye.reactive</groupId>
                        <artifactId>vertx-mutiny-code-generator</artifactId>
                        <version>${project.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>${build-helper-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <id>add-source</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>target/generated-sources/codegen</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>Windows</family>
                </os>
            </activation>
            <properties>
                <maven.test.skip>true</maven.test.skip>
            </properties>
        </profile>
    </profiles>
</project>