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

    <modelVersion>4.0.0</modelVersion>

    <artifactId>mockserver-junit-jupiter-no-dependencies</artifactId>

    <name>MockServer JUnit Jupiter Integration (No Dependencies)</name>
    <description>A JUnit5 Extension for MockServer with all dependencies shaded</description>
    <url>https://www.mock-server.com</url>

    <properties>
        <module.name>org.mockserver.junit.jupiter</module.name>
    </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-junit-jupiter</artifactId>
            <optional>true</optional>
        </dependency>
        <!-- provided: JUnit Jupiter is the API this integration is written against, and the project using it
             already has it. Bundled, it clashed with the project's own copy (issue #2772), so the shade
             leaves it out; provided is not passed on to consumers, so they still inherit no dependencies. -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <id>shade-no-dependencies</id>
                        <configuration>
                            <artifactSet>
                                <excludes>
                                    <exclude>org.junit.jupiter:*</exclude>
                                    <exclude>org.junit.platform:*</exclude>
                                    <exclude>org.apiguardian:*</exclude>
                                </excludes>
                            </artifactSet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <!-- Fail the build if a bundled dependency is left unrelocated (issue #2772); the script
                 holds the shared allow-list and why each entry stays. -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.6.4</version>
                <executions>
                    <execution>
                        <id>assert-only-relocated-classes</id>
                        <phase>package</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>${project.basedir}/../mockserver-netty-no-dependencies/src/packaging/assert-only-relocated-classes.sh</executable>
                            <arguments>
                                <argument>${project.build.directory}/${project.build.finalName}.jar</argument>
                            </arguments>
                        </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>
        </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>
