<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright 2025 Daniel Felix Ferber
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~     http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<!--
  To update the Maven wrapper, run the following command in the terminal:
  mvn org.apache.maven.plugins:maven-wrapper-plugin:3.2.0:wrapper -Dmaven=3.9.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">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.usefultoys</groupId>
    <artifactId>slf4j-test-mock</artifactId>
    <version>0.0.8</version>
    <name>SLF4J Test Mock Implementation</name>


    <description>A comprehensive mock implementation of the SLF4J logging framework designed specifically for unit testing.</description>
    <url>https://github.com/useful-toys/slf4j-test-mock</url>
    <inceptionYear>2025</inceptionYear>

    <licenses>
        <license>
            <name>The Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Daniel Felix Ferber</name>
            <email>danielferber@gmail.com</email>
            <organization>None</organization>
            <organizationUrl>https://github.com/danielferber</organizationUrl>
            <roles>
                <role>Lead Developer</role>
            </roles>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:git@github.com/useful-toys/slf4j-test-mock.git</connection>
        <developerConnection>scm:git:git@github.com/useful-toys/slf4j-test-mock.git</developerConnection>
        <url>git@github.com/useful-toys/slf4j-test-mock.git</url>
    </scm>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

        <!-- Defaults to SLF4J 2.0.x (can be overridden by profiles) -->
        <slf4j.version>2.0.16</slf4j.version>
        <lombok.version>1.18.42</lombok.version>
        <junit5.version>5.14.1</junit5.version>
        <jacoco-maven-plugin.version>0.8.14</jacoco-maven-plugin.version>
        <versions-maven-plugin.version>2.20.1</versions-maven-plugin.version>
        <maven-surefire-plugin.version>3.5.4</maven-surefire-plugin.version>
        <maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>
        <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
        <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
    </properties>


    <dependencies>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${lombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit5.version}</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>

    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>versions-maven-plugin</artifactId>
                    <version>${versions-maven-plugin.version}</version>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <!-- Configures compiler to create Java 8 compatible classes. -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <release>8</release>
                    <compilerArgs>
                        <!-- Enable all warnings except 'options' (which warns about obsolete source/target values) -->
                        <arg>-Xlint:all</arg>
                        <arg>-Xlint:-options</arg>
                        <!-- Suppress deprecation warnings for intentional use of SLF4J 1.7 deprecated APIs -->
                        <arg>-Xlint:-deprecation</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
            </plugin>
            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>${jacoco-maven-plugin.version}</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>report</id>
                        <phase>test</phase>
                        <goals>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Enforces Maven and Java version requirements. -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.3.0</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>[3.9.8,3.10)</version>
                                </requireMavenVersion>
                                <requireJavaVersion>
                                    <version>[21,22)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>

        <profile>
            <!-- SLF4J 1.7 Profile - uses SLF4J 1.7.x API for testing compatibility.
                 
                 Design Decision:
                 - MockServiceProvider.java is excluded from compilation because it only exists in SLF4J 2.0.
                 - However, a JAR compiled with SLF4J 2.0 (including MockServiceProvider) works fine with SLF4J 1.7 runtime.
                 - Javadoc generation is also configured to skip org.slf4j.* packages to prevent:
                   1. Trying to generate docs for SLF4J 2.0-only classes when SLF4J 1.7 is active
                   2. Polluting the public API documentation with internal implementation classes
                 - This ensures clean, focused public API documentation that only includes org.usefultoys.slf4jtestmock. -->
            <id>slf4j-1.7</id>
            <properties>
                <slf4j.version>1.7.36</slf4j.version>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>${maven-compiler-plugin.version}</version>
                        <configuration>
                            <excludes>
                                <!-- Exclude SLF4J 2.0 specific files that cannot compile with SLF4J 1.7 API -->
                                <exclude>**/MockServiceProvider.java</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <configuration>
                            <excludePackageNames>org.slf4j</excludePackageNames>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- SLF4J 2.0 Profile - uses SLF4J 2.0.x (this is also the default configuration) -->
        <profile>
            <id>slf4j-2.0</id>
            <properties>
                <slf4j.version>2.0.16</slf4j.version>
            </properties>
        </profile>

        <!-- Javadoc Validation Profile - validates Javadoc syntax when explicitly requested.
             Activate with: mvn clean verify -P javadoc-validation -->
        <profile>
            <id>javadoc-validation</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>validate-javadoc</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>javadoc</goal>
                                </goals>
                                <configuration>
                                    <!-- Fails the build if Javadoc generation fails. -->
                                    <failOnError>true</failOnError>
                                    <!-- Matches compiler release 8 sources to avoid doclint differences. -->
                                    <source>8</source>
                                    <!-- Only generate docs for public API, exclude internal SLF4J implementation -->
                                    <excludePackageNames>org.slf4j</excludePackageNames>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- SLF4J Activation Tests Profile - runs only SLF4J activation tests from org.slf4j.impl package. -->
        <profile>
            <id>slf4j-activation-tests-only</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>${maven-surefire-plugin.version}</version>
                        <configuration>
                            <includes>
                                <include>**/org/slf4j/impl/**/*Test.java</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Release Profile - creates source and javadoc artifacts, signs artifacts and deploys to Maven Central. -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>${maven-source-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                                <configuration>
                                    <!-- Only generate docs for public API, exclude internal SLF4J implementation -->
                                    <excludePackageNames>org.slf4j</excludePackageNames>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>${maven-gpg-plugin.version}</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>0.9.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>maven-central</publishingServerId>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>