<?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>7.0.0</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <artifactId>mockserver-netty-no-dependencies</artifactId>

    <name>MockServer &amp; Proxy Netty (No Dependencies)</name>
    <description>MockServer Netty with all dependencies shaded</description>
    <url>https://www.mock-server.com</url>

    <properties>
        <module.name>org.mockserver.netty</module.name>
        <maven-invoker-parallel-threads>2</maven-invoker-parallel-threads>
    </properties>

    <dependencies>
        <!-- optional: shade bundles the source module's classes into this
             self-contained jar, so consumers of this no-dependencies artifact
             must not also receive the unshaded source module (and its
             transitive dependencies) on their classpath. Shade still bundles a
             module's own optional dependencies. -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-netty</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- AsyncAPI messaging module — declared optional in mockserver-netty,
             so not transitive. Explicitly included here so the shade plugin
             bundles it into the standalone jar and the Docker image. -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-async</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- This shaded jar is a standalone runnable artifact — the CLI and the
             Docker image both run it directly — so unlike the mockserver-netty
             library it must bundle an SLF4J logging backend. mockserver-netty
             declares slf4j-jdk14 optional, and optional dependencies are not
             transitive, so the binding never reached this module's shade
             classpath and the jar shipped with no SLF4J provider — logging
             silently fell back to a no-op logger (issue #2097). Declaring it
             directly here puts it on the shade classpath so the provider is
             bundled into the uber jar. It stays optional: the shade plugin
             bundles a module's own optional dependencies anyway, and optional
             keeps slf4j-jdk14 from leaking onto the classpath of anything that
             consumes this artifact as a Maven dependency. -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <optional>true</optional>
        </dependency>

        <!-- test scope only: junit drives ExtendedNoDependenciesJarMockingIntegrationTest.
             The smoke test deliberately uses only the JDK (java.net.http.HttpClient)
             and ProcessBuilder so it cannot accidentally load mockserver-* classes
             from both the unshaded mockserver-core and this module's shaded jar at
             once — see NoDependenciesJarRunner javadoc.
             mockserver-testing is included so the parent pom's failsafe listener
             (org.mockserver.test.PrintOutCurrentTestRunListener) is resolvable. It
             pulls in only junit + hamcrest, no mockserver-core, so no conflict. -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>mockserver-testing</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <!-- inherits the shared shade configuration from the parent pom's
                     pluginManagement; overrides the transformers (to set the
                     executable jar's Main-Class) and replaces the inherited filter
                     list (combine.self="override") to add a filter that strips the
                     bundled netty-tcnative native libraries — the other
                     no-dependencies modules ship those libraries, but this
                     standalone server jar deliberately excludes them. Because the
                     override replaces rather than appends, the shared filters are
                     repeated here verbatim. -->
                <executions>
                    <execution>
                        <id>shade-no-dependencies</id>
                        <configuration>
                            <transformers combine.self="override">
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>org.mockserver.cli.Main</mainClass>
                                    <manifestEntries>
                                        <Automatic-Module-Name>${module.name}</Automatic-Module-Name>
                                    </manifestEntries>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer" />
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
                                <transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">
                                    <resource>META-INF/LICENSE</resource>
                                </transformer>
                            </transformers>
                            <filters combine.self="override">
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <artifact>com.github.java-json-tools:json-schema-validator</artifact>
                                    <excludes>
                                        <exclude>draftv3/**</exclude>
                                        <exclude>draftv4/**</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <artifact>io.netty:netty-tcnative-boringssl-static</artifact>
                                    <excludes>
                                        <exclude>META-INF/native/**</exclude>
                                    </excludes>
                                </filter>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.txt</exclude>
                                        <exclude>META-INF/*.md</exclude>
                                        <exclude>META-INF/**/module-info.class</exclude>
                                        <exclude>META-INF/io.netty.versions.properties</exclude>
                                        <exclude>META-INF/**/pom.properties</exclude>
                                        <exclude>META-INF/**/pom.xml</exclude>
                                        <exclude>META-INF/MANIFEST.MF</exclude>
                                        <exclude>META-INF/LICENSE</exclude>
                                        <exclude>META-INF/NOTICE</exclude>
                                        <exclude>META-INF/license/**</exclude>
                                        <exclude>META-INF/DEPENDENCIES</exclude>
                                        <exclude>META-INF/versions/**</exclude>
                                        <exclude>module-info.java</exclude>
                                        <exclude>LGPL-3.0.txt</exclude>
                                        <exclude>LICENSE-ClassGraph.txt</exclude>
                                        <exclude>hamcrest-core-is-deprecated.txt</exclude>
                                        <exclude>THIRD-PARTY.txt</exclude>
                                        <exclude>ASL-2.0.txt</exclude>
                                        <exclude>samples/**</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.12.0</version>
                <configuration>
                    <failOnError>false</failOnError>
                    <doclint>none</doclint>
                </configuration>
            </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>
                    <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>
            <!-- shaded dependency gradle integration tests -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.6.3</version>
                <inherited>false</inherited>
                <configuration>
                    <skip>${skipTests}</skip>
                    <workingDirectory>${basedir}</workingDirectory>
                </configuration>
                <executions>
                    <execution>
                        <id>gradle_integration_tests</id>
                        <phase>install</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>src/integration-tests/gradle_integration_tests.sh</executable>
                            <arguments>${project.version}</arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- The parent pom's release profile attaches a -javadoc.jar via
             maven-javadoc-plugin, but these no-dependencies modules have no
             sources of their own, so nothing is produced and Maven Central
             rejects the deployment. Build the javadoc jar from the
             org.mock-server dependency sources that this module shades. -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <includeDependencySources>true</includeDependencySources>
                                    <dependencySourceIncludes>
                                        <dependencySourceInclude>org.mock-server:*</dependencySourceInclude>
                                    </dependencySourceIncludes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
