<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>ph.extremelogic</groupId>
    <artifactId>extremelogic-common-log</artifactId>
    <version>0.0.1</version>
    <packaging>jar</packaging>

    <name>Extreme Logic Common Log</name>
    <url>https://www.extremelogic.ph</url>
    <description>Logger</description>

    <!-- SCM (Source Code Management) configuration -->
    <scm>
        <connection>scm:git:https://github.com/extremelogic-ph/common_log.git</connection>
        <developerConnection>scm:git:ssh://github.com/extremelogic-ph/common_log.git</developerConnection>
        <url>https://github.com/extremelogic-ph/common_log</url>
    </scm>

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <junit.jupiter.version>5.10.0</junit.jupiter.version>
    </properties>

    <dependencies>
        <!-- JUnit 5 -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.10.0</version>
            <scope>test</scope>
        </dependency>

        <!-- Mockito for mocking -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.5.0</version>
            <scope>test</scope>
        </dependency>

        <!-- AssertJ for fluent assertions -->
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>3.24.2</version>
            <scope>test</scope>
        </dependency>

    </dependencies>

    <build>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${maven.compiler.source}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>

            <!-- Surefire plugin to run JUnit tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.22.2</version>
                <configuration>
                    <includes>
                        <include>**/*Test.java</include>
                    </includes>
                </configuration>
            </plugin>

            <!-- Creates a "fat JAR" that includes your code plus all dependencies -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <!--
                                Explicitly control what goes into the fat JAR.
                                If you want to include everything, omit the <includes> section entirely.
                                -->
                                <includes>
                                    <!-- Include other dependencies as needed -->
                                </includes>
                            </artifactSet>
                            <transformers>
                                <!-- Ensures the Apache license file is included in the final JAR -->
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ApacheLicenseResourceTransformer"/>

                                <!-- Merges all META-INF/services entries from dependencies into one, preserving service loader functionality -->
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>

                                <!-- Modifies the JAR's MANIFEST.MF to specify the main class, enabling it to be executable -->
                                <!--
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>ph.extremelogic.common.core.config.encrypt.DefaultPropertyEncryptor</mainClass>
                                </transformer>
                                -->
                            </transformers>

                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <includes>
                                        <include>ph/extremelogic/common/core/log/**</include>
                                        <include>resources/**</include>
                                    </includes>
                                </filter>
                            </filters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--
            Signs the artifacts (jar, pom, source, javadoc) before they are deployed.
            Uses your GPG key that must already be configured on your system.
            Maven looks for the GPG passphrase from:
              an environment variable (GPG_PASSPHRASE)
              or via settings.xml
            You must have a published GPG key in a public key server (e.g. keyserver.ubuntu.com)
            and synced with your Sonatype account.

            May need to specify passphrase if there are multiple entries:
              mvn deploy -Dgpg.passphrase=your-secret
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-gpg-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <id>sign-artifacts</id>
                        <phase>verify</phase>
                        <goals>
                            <goal>sign</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <!-- Optional: only include if using a specific key -->
                    <!-- <keyname>90299062AC585F84083965CA498B7972198A6A95</keyname> -->
                </configuration>
            </plugin>

            <!--
            Uploads artifacts to a repository (e.g. Sonatype OSSRH).
            Uses settings.xml:

            It looks for server credentials (username/password) under the <servers> section
            in settings.xml, matching the <id> defined in your <distributionManagement>
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>3.1.1</version>
            </plugin>

            <!--
                Maven Central requires both source JARs to be published alongside the main artifact.
                These are used by consumers to browse source code and read documentation in IDEs or via search.maven.org.
                Without them, deployment will fail with "Sources must be provided" and "Javadocs must be provided" errors.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>3.2.1</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
                Maven Central requires Javadoc JARs to be published alongside the main artifact.
                These are used by consumers to browse source code and read documentation in IDEs or via search.maven.org.
                Without them, deployment will fail with "Sources must be provided" and "Javadocs must be provided" errors.
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>3.4.1</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.sonatype.central</groupId>
                <artifactId>central-publishing-maven-plugin</artifactId>
                <version>0.8.0</version>
                <extensions>true</extensions>
                <configuration>
                    <publishingServerId>ossrh</publishingServerId>
                </configuration>
            </plugin>

            <!--
            Publish a standard library JAR.
            No need to include dependencies.
            -->
            <!--plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.2.0</version>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <classpathPrefix>lib/</classpathPrefix>
                            <mainClass>ph.extremelogic.common.core.config.encrypt.DefaultPropertyEncryptor</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin-->
        </plugins>
    </build>
    <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>Virgilio "Jan" So</name>
            <email>virgilio.so@extremelogic.ph</email>
            <organization>Extreme Logic</organization>
            <organizationUrl>https://www.extremelogic.ph</organizationUrl>
            <timezone>UTC+08:00</timezone>
        </developer>
    </developers>
</project>
