<?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.mock-server</groupId>
        <artifactId>mockserver</artifactId>
        <version>6.0.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <name>MockServer &amp; Proxy Netty</name>
    <artifactId>mockserver-netty</artifactId>
    <url>https://www.mock-server.com</url>

    <properties>
        <maven-invoker-parallel-threads>2</maven-invoker-parallel-threads>
    </properties>

    <dependencies>
        <!-- mockserver -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-client-java</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-core</artifactId>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-integration-testing</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-testing</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- Netty -->
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-buffer</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec</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-common</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-handler</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-transport</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-codec-dns</artifactId>
        </dependency>
        <dependency>
            <groupId>io.netty</groupId>
            <artifactId>netty-tcnative-boringssl-static</artifactId>
        </dependency>

        <!-- commons & guava -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>

        <!-- logging -->
        <dependency> <!-- will map to any underlying logging framework -->
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <optional>true</optional> <!-- do not impose on project importing mock-server -->
        </dependency>

        <!-- test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- make jar executable -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.5.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>org.mockserver.cli.Main</mainClass>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <!-- generate single runnable jar (assembly:single) -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <skipAssembly>${skipAssembly}</skipAssembly>
                    <tarLongFileMode>posix</tarLongFileMode>
                    <archive>
                        <manifest>
                            <mainClass>org.mockserver.cli.Main</mainClass>
                        </manifest>
                    </archive>
                    <descriptors>
                        <descriptor>src/main/assembly/jar-with-dependencies/jar-with-dependencies.xml</descriptor>
                        <descriptor>src/main/assembly/brew-tar/brew-tar.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!-- shaded dependency maven integration tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-invoker-plugin</artifactId>
                <version>3.10.1</version>
                <configuration>
                    <skipInvocation>${skipTests}</skipInvocation>
                    <debug>false</debug>
                    <!-- only stream the invoked child Maven build log on
                         failure (invoker 3.3+) — passing builds stay quiet so
                         the CI log is not flooded with per-invoker child output. -->
                    <streamLogs>false</streamLogs>
                    <streamLogsOnFailures>true</streamLogsOnFailures>
                    <showErrors>true</showErrors>
                    <showVersion>true</showVersion>
                    <disableReports>true</disableReports>
                    <parallelThreads>${maven-invoker-parallel-threads}</parallelThreads>
                    <projectsDirectory>${basedir}/src/integration-tests/</projectsDirectory>
                    <cloneProjectsTo>${project.build.directory}/integration-tests/</cloneProjectsTo>
                    <reportsDirectory>${project.build.directory}</reportsDirectory>
                    <cloneClean>true</cloneClean>
                    <ignoreFailures>false</ignoreFailures>
                    <addTestClassPath>true</addTestClassPath>
                    <properties>
                        <property>
                            <name>mockserver.version</name>
                            <value>${project.version}</value>
                        </property>
                    </properties>
                    <environmentVariables>
                        <mockserver.logLevel>DEBUG</mockserver.logLevel>
                    </environmentVariables>
                    <filterProperties>
                        <mockserver.version>${project.version}</mockserver.version>
                    </filterProperties>
                    <settingsFile>src/integration-tests/settings.xml</settingsFile>
                    <!--<mavenOpts>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005</mavenOpts>-->
                    <pomIncludes>
                        <pomInclude>maven-**/pom.xml</pomInclude>
                    </pomIncludes>
                    <goals>
                        <goal>test</goal>
                    </goals>
                </configuration>
                <executions>
                    <execution>
                        <id>integration-test</id>
                        <goals>
                            <goal>install</goal>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>build-ui</id>
            <activation>
                <file>
                    <exists>../../mockserver-ui/package.json</exists>
                </file>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.eirslett</groupId>
                        <artifactId>frontend-maven-plugin</artifactId>
                        <version>1.15.4</version>
                        <dependencies>
                            <dependency>
                                <groupId>org.apache.commons</groupId>
                                <artifactId>commons-compress</artifactId>
                                <version>1.28.0</version>
                            </dependency>
                        </dependencies>
                        <configuration>
                            <workingDirectory>${project.basedir}/../../mockserver-ui</workingDirectory>
                            <installDirectory>${project.build.directory}/frontend</installDirectory>
                        </configuration>
                        <executions>
                            <execution>
                                <id>install-node-and-npm</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>install-node-and-npm</goal>
                                </goals>
                                <configuration>
                                    <nodeVersion>v22.14.0</nodeVersion>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm-ci</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>ci</arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>npm-build</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>npm</goal>
                                </goals>
                                <configuration>
                                    <arguments>run build</arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>3.5.0</version>
                        <executions>
                            <execution>
                                <id>copy-ui-build</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <overwrite>true</overwrite>
                                    <resources>
                                        <resource>
                                            <directory>${project.basedir}/../../mockserver-ui/build</directory>
                                            <filtering>false</filtering>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${project.build.outputDirectory}/org/mockserver/dashboard</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
