<?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>
        <groupId>org.mule.services</groupId>
        <artifactId>mule-core-services-parent</artifactId>
        <version>1.10.3</version>
        <relativePath />
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <name>HTTP Service Implementation</name>
    <description>Netty based implementation of the HTTP Service</description>

    <artifactId>mule-netty-http-service</artifactId>
    <version>0.3.3</version>
    <packaging>mule-service</packaging>

    <properties>
        <surefire.args>
            -XX:+IgnoreUnrecognizedVMOptions
            --add-exports=org.mule.service.http.netty/org.mule.service.http.test.common=ALL-UNNAMED
            --add-exports=org.mule.service.http.netty/org.mule.service.http.test.netty.tck=ALL-UNNAMED
            --add-exports=org.mule.service.http.netty/org.mule.service.http.netty.impl.service=ALL-UNNAMED
              --add-opens=org.eclipse.angus.mail/org.eclipse.angus.mail.util=org.mule.service.http.netty
              --add-reads=org.mule.service.http.netty=org.eclipse.angus.mail
              --add-reads=org.mule.service.http.netty=org.apache.logging.log4j
              --add-reads=org.mule.service.http.netty=org.bouncycastle.provider
              --add-opens=org.mule.service.http.netty/org.mule.service.http.common.message.sse=ALL-UNNAMED
            --add-opens=org.mule.service.http.netty/org.mule.service.http.test.common.client=ALL-UNNAMED
            --add-opens=org.mule.service.http.netty/org.mule.service.http.test.common.server=ALL-UNNAMED
            ${surefire.args.base}
        </surefire.args>

        <javaModuleName>org.mule.service.http.netty</javaModuleName>
        <skipExportTests>false</skipExportTests>

        <licensePath>LICENSE_HEADER.txt</licensePath>
    </properties>

    <scm>
        <connection>scm:git:git://github.com/mulesoft-labs/mule-http-netty-service.git</connection>
        <developerConnection>scm:git:git@github.com:mulesoft-labs/mule-http-netty-service.git</developerConnection>
        <url>https://github.com/mulesoft-labs/mule-http-netty-service</url>
    </scm>

    <build>
        <plugins>
            <plugin>
                <groupId>org.mule.runtime.plugins</groupId>
                <artifactId>mule-service-maven-plugin</artifactId>
                <extensions>true</extensions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-test-jar</id>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <java.net.preferIPv4Stack>true</java.net.preferIPv4Stack>
                        <testClasspathDir>${project.build.testOutputDirectory}</testClasspathDir>

                        <!-- This must be a host with at least 2 different IP addresses -->
                        <domainNameResolver.test.host>salesforce.com</domainNameResolver.test.host>
                        <!-- This must be a host that cannot be resolved -->
                        <domainNameResolver.test.unknownHost>unknown.mulesoft.unknown</domainNameResolver.test.unknownHost>

                        <io.netty.handler.codec.http.defaultStrictLineParsing>false</io.netty.handler.codec.http.defaultStrictLineParsing>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <!-- Runtime dependencies -->
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-service-http-api</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.runtime</groupId>
            <artifactId>mule-module-tls</artifactId>
            <version>${mule.version}</version>
            <scope>provided</scope>
        </dependency>

        <!-- Netty dependencies -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-http2</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-buffer</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler-proxy</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-resolver-dns</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport-native-epoll</artifactId>
        </dependency>

        <!-- Reactor HTTPClient -->
        <dependency>
            <groupId>io.projectreactor.netty</groupId>
            <artifactId>reactor-netty-core</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-resolver-dns-native-macos</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.projectreactor.netty</groupId>
            <artifactId>reactor-netty-http</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.netty</groupId>
                    <artifactId>netty-resolver-dns-native-macos</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
        </dependency>

        <dependency>
            <groupId>com.github.ben-manes.caffeine</groupId>
            <artifactId>caffeine</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
        </dependency>

        <dependency>
            <groupId>org.codelibs</groupId>
            <artifactId>jcifs</artifactId>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.mule.tests</groupId>
            <artifactId>mule-tests-unit</artifactId>
            <version>${mule.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mule.services</groupId>
            <artifactId>mule-service-weave</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-util</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-server</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-security</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-proxy</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5-fluent</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents.client5</groupId>
            <artifactId>httpclient5</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcprov-jdk18on</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bctls-jdk18on</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-tcnative-boringssl-static</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.bouncycastle</groupId>
            <artifactId>bcpkix-jdk18on</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>nl.jqno.equalsverifier</groupId>
            <artifactId>equalsverifier</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.github.peterwippermann.junit4</groupId>
            <artifactId>parameterized-suite</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.wiremock</groupId>
            <artifactId>wiremock</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.openjdk.jmh</groupId>
            <artifactId>jmh-generator-annprocess</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.mule</groupId>
                <artifactId>mule-javaee-runtime-bom</artifactId>
                <version>${muleBomVersion}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <distributionManagement>
        <downloadUrl>https://www.mulesoft.com/mule-esb-enterprise-trial-download</downloadUrl>
        <repository>
            <id>mule-releases</id>
            <name>Mule Release Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases</url>
        </repository>
        <snapshotRepository>
            <id>mule-snapshots</id>
            <name>Mule Snapshot Repository</name>
            <url>https://repository-master.mulesoft.org/nexus/content/repositories/snapshots</url>
            <uniqueVersion>false</uniqueVersion>
        </snapshotRepository>
    </distributionManagement>

    <repositories>
        <repository>
            <id>mule</id>
            <name>Mule Repository</name>
            <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>mule-plugin</id>
            <name>Mule Repository</name>
            <url>https://repository.mulesoft.org/nexus/content/repositories/public/</url>
        </pluginRepository>
    </pluginRepositories>

    <profiles>
        <profile>
            <id>micro-benchmark</id>
            <activation>
                <property>
                    <name>micro.benchmark</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>default-testCompile</id>
                                <configuration>
                                    <proc>full</proc>
                                    <annotationProcessorPaths>
                                        <path>
                                            <groupId>org.openjdk.jmh</groupId>
                                            <artifactId>jmh-generator-annprocess</artifactId>
                                        </path>
                                    </annotationProcessorPaths>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>reserve-network-port</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>reserve-network-port</goal>
                                </goals>
                                <configuration>
                                    <portNames>
                                        <portName>mock.server.port</portName>
                                    </portNames>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>run-benchmarks</id>
                                <phase>integration-test</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <classpathScope>test</classpathScope>
                                    <executable>java</executable>
                                    <workingDirectory>${basedir}/target</workingDirectory>
                                    <arguments>
                                        <!-- Uncomment this and set the forks count to 0 to debug -->
                                        <!-- <argument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005</argument>-->

                                        <argument>-Dmock.server.port=${mock.server.port}</argument>

                                        <argument>-classpath</argument>
                                        <classpath/>
                                        <mainClass>org.openjdk.jmh.Main</mainClass>
                                        <!--Run only a certain class-->
                                        <argument>${jmh.benchmark}</argument>
                                        <!--Create json report-->
                                        <argument>-rf</argument>
                                        <argument>json</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
