<?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">
    <modelVersion>4.0.0</modelVersion>

    <groupId>io.github.manoelcampos</groupId>
    <artifactId>dtogen</artifactId>
    <version>2.1.5</version>
    <name>DTOGen</name>

    <description>
        A Java 21+ annotation-based, validation-aware DTO generation library following DRY and avoiding boilerplate code.
    </description>
    <url>https://manoelcampos.github.io/dtogen</url>

    <inceptionYear>2024</inceptionYear>

    <licenses>
        <license>
            <name>GPLv3</name>
            <url>http://www.gnu.org/licenses/gpl-3.0.txt</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Manoel Campos da Silva Filho</name>
            <email>manoelcampos@gmail.com</email>
            <organization>IFTO</organization>
            <organizationUrl>http://www.ifto.edu.br</organizationUrl>
        </developer>
    </developers>

    <profiles>
        <profile>
            <!--
             A profile used to execute all goals required to deploy
             the project to the Maven Central.
             To execute use: mvn clean deploy -P sonatype

             To check the deployed artifact and probably release it to maven central
             you should visit https://oss.sonatype.org.
             MAKE SURE YOU ARE LOGGED IN TO SEE YOUR DEPLOYMENTS.
             -->
            <id>sonatype</id>

            <!--
            URLs to deploy the project at the Maven Central (http://mvnrepository.com)
            using a Sonatype account (http://central.sonatype.org)
            See the "all" profile in this pom for deployment information.
            -->
            <distributionManagement>
                <snapshotRepository>
                    <id>manoelcampos-ossrh</id>
                    <url>https://oss.sonatype.org/content/repositories/snapshots</url>
                </snapshotRepository>
                <repository>
                    <id>manoelcampos-ossrh</id>
                    <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
                </repository>
            </distributionManagement>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <!-- Forking the process was causing runtime exceptions when running tests with Java 10+ -->
                            <forkCount>0</forkCount>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.3.0</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <failOnError>false</failOnError>
                        </configuration>
                    </plugin>

                    <!--
                     Signs the generated jar using GPG, as required for deploying at the Maven Central.
                     Configurations are defined into the local repo settings.xml
                    -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.1.0</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <!-- Prevent `gpg` from using pinentry programs
                                    and avoid "gpg: signing failed: Inappropriate ioctl for device" error. -->
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <!--
                    Plugin to deploy to the maven central using a Sonatype account.
                    Credentials are defined into the local repo settings.xml
                    -->
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.7.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>manoelcampos-ossrh</serverId>
                            <!-- URL for administration of deployed artifacts -->
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <!--If the artifact will be automatically released to maven central after the upload to sonatype.-->
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <scm>
        <connection>scm:git@github.com:manoelcampos/dtogen.git</connection>
        <developerConnection>scm:git@github.com:manoelcampos/dtogen.git</developerConnection>
        <url>https://github.com/manoelcampos/dtogen</url>
    </scm>

    <issueManagement>
        <url>https://github.com/manoelcampos/dtogen/issues</url>
        <system>GitHub Issues</system>
    </issueManagement>

    <properties>
        <maven.compiler.release>21</maven.compiler.release>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.google.auto.service</groupId>
            <artifactId>auto-service</artifactId>
            <version>1.0.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.11.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <!-- Required by com.karuslabs.elementary -->
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>5.11.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.15.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.karuslabs</groupId>
            <artifactId>elementary</artifactId>
            <version>3.0.0</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.13.0</version>
                <configuration>
                    <!--
                    Disable annotation processing for ourselves.
                    Avoids "Bad service configuration file, or exception thrown while constructing Processor object".
                    -->
                    <compilerArgument>-proc:none</compilerArgument>
                    <showWarnings>true</showWarnings>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>3.3.1</version>

                <executions>
                    <execution>
                        <id>copy-java-to-resources</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>

                        <!--
                        Include the DTORecord.java source file inside the generated jar file.
                        Check the class documentation for more details.
                        -->
                        <configuration>
                            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/java</directory>
                                    <includes>
                                        <include>io/github/manoelcampos/dtogen/DTORecord.java</include>
                                    </includes>
                                    <!-- Subdirectory inside the target dir to copy the files to -->
                                    <targetPath>.</targetPath>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.jacoco</groupId>
                <artifactId>jacoco-maven-plugin</artifactId>
                <version>0.8.12</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>prepare-agent</goal>
                            <goal>report</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
