<?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">
    <parent>
        <artifactId>hyperfoil-all</artifactId>
        <groupId>io.hyperfoil</groupId>
        <version>0.24.2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>hyperfoil-hotrod</artifactId>
    <name>Hyperfoil Hot Rod Client</name>

    <dependencies>
        <dependency>
            <groupId>io.hyperfoil</groupId>
            <artifactId>hyperfoil-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.kohsuke.metainf-services</groupId>
            <artifactId>metainf-services</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-client-hotrod</artifactId>
            <version>${version.infinispan}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.logging</groupId>
                    <artifactId>jboss-logging</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.github.ben-manes.caffeine</groupId>
                    <artifactId>caffeine</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.sshd</groupId>
                    <artifactId>sshd-common</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.reactivex.rxjava3</groupId>
                    <artifactId>rxjava</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.reactivex.rxjava2</groupId>
                    <artifactId>rxjava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.hyperfoil</groupId>
            <artifactId>hyperfoil-core</artifactId>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-server-hotrod</artifactId>
            <version>${version.infinispan}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.logging</groupId>
                    <artifactId>jboss-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-server-hotrod</artifactId>
            <version>${version.infinispan}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-server-core</artifactId>
            <version>${version.infinispan}</version>
            <type>test-jar</type>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.logging</groupId>
                    <artifactId>jboss-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-core</artifactId>
            <version>${version.infinispan}</version>
            <scope>test</scope>
            <type>test-jar</type>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.logging</groupId>
                    <artifactId>jboss-logging</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.wildfly.common</groupId>
                    <artifactId>wildfly-common</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-client-hotrod</artifactId>
            <version>${version.infinispan}</version>
            <type>test-jar</type>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.logging</groupId>
                    <artifactId>jboss-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.infinispan</groupId>
            <artifactId>infinispan-commons-test</artifactId>
            <version>${version.infinispan}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.jboss.logging</groupId>
                    <artifactId>jboss-logging</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.reactivex.rxjava3</groupId>
                    <artifactId>rxjava</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>io.reactivex.rxjava2</groupId>
                    <artifactId>rxjava</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-unit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.vertx</groupId>
            <artifactId>vertx-web</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${version.maven-surefire-plugin}</version>
                <configuration>
                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
                    <trimStackTrace>false</trimStackTrace>
                    <includes>
                        <include>**/*TestCase.java</include>
                        <include>**/*Test.java</include>
                        <include>**/*.yaml</include>
                    </includes>
                    <argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <!-- The output jar contains shaded resources as well, and shade would try to combine
                         this module's JAR with the shaded dependencies and error due to duplicates. -->
                    <forceCreation>true</forceCreation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <includes>
                                    <include>com.github.ben-manes.caffeine:*</include>
                                    <include>org.infinispan:*</include>
                                    <include>org.infinispan.protostream:*</include>
                                    <include>org.wildfly.common:*</include>
                                    <include>org.wildfly.security:*</include>
                                </includes>
                            </artifactSet>
                            <relocations>
                                <relocation>
                                    <pattern>org.infinispan</pattern>
                                    <shadedPattern>shaded.org.infinispan</shadedPattern>
                                </relocation>
                            </relocations>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>org/infinispan/client/hotrod/impl/transport/netty/TransportHelper.class</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <!-- Maven Shade did relocate classes in META-INF/versions/11 but it did not place them
                                 to the correct folder within the JAR. We're going to fix it up in the Ant tasks below. -->
                            <finalName>hyperfoil-hotrod-shaded</finalName>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <configuration>
                            <tasks>
                                <!-- We will just take the JDK11-specific classes and move them to regular locations
                                     as Hyperfoil is JDK11+ only anyway. We won't need to mess with multi-release JAR then -->
                                <unzip src="${project.build.directory}/hyperfoil-hotrod-shaded.jar" dest="${project.build.directory}/shaded" />
                                <move todir="${project.build.directory}/shaded/shaded">
                                    <fileset dir="${project.build.directory}/shaded/META-INF/versions/11/" />
                                </move>
                                <jar destfile="${project.build.directory}/${project.build.finalName}.jar">
                                    <fileset dir="${project.build.directory}/shaded" />
                                </jar>
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-checkstyle-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <skip>${module.skipCopyDependencies}</skip>
                            <includeScope>runtime</includeScope>
                            <excludeScope>test</excludeScope>
                            <excludeGroupIds>com.github.ben-manes.caffeine,org.infinispan,org.infinispan.protostream,org.wildfly</excludeGroupIds>
                            <silent>true</silent>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
