<?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>com.pi4j</groupId>
    <artifactId>pi4j-drivers</artifactId>
    <name>Pi4J :: DRIVERS</name>
    <description>Pi4J drivers for various electronic components</description>
    <url>https://github.com/Pi4J/pi4j-drivers</url>
    <version>1.0.0</version>

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

    <developers>
        <developer>
            <id>pi4j</id>
            <name>Pi4J Contributors</name>
            <url>https://github.com/Pi4J</url>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:https://github.com/Pi4J/pi4j-drivers.git</connection>
        <developerConnection>scm:git:ssh://git@github.com/Pi4J/pi4j-drivers.git</developerConnection>
        <url>https://github.com/Pi4J/pi4j-drivers</url>
        <tag>HEAD</tag>
    </scm>

    <!-- BUILD PROPERTIES -->
    <properties>
        <!-- PROJECT ENCODING PROPERTIES -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

        <!-- JAVA COMPILER VERSIONS -->
        <java.version>25</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>

        <!-- DEPENDENCIES VERSIONS -->
        <slf4j.version>2.0.16</slf4j.version>
        <pi4j.version>4.0.1</pi4j.version>

        <!-- TEST DEPENDENCIES VERSIONS -->
        <junit.jupiter.version>5.12.1</junit.jupiter.version>

        <!-- BUILD PLUGIN VERSIONS -->
        <maven-checkstyle-plugin.version>3.6.0</maven-checkstyle-plugin.version>
        <maven-source-plugin.version>3.3.1</maven-source-plugin.version>
        <maven-javadoc-plugin.version>3.11.1</maven-javadoc-plugin.version>
        <maven-surefire-plugin.version>3.2.5</maven-surefire-plugin.version>
        <central-publishing-maven-plugin.version>0.8.0</central-publishing-maven-plugin.version>
        <jreleaser-maven-plugin.version>1.15.0</jreleaser-maven-plugin.version>
    </properties>

    <dependencies>
        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${slf4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>${slf4j.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Pi4J Core -->
        <dependency>
            <groupId>com.pi4j</groupId>
            <artifactId>pi4j-core</artifactId>
            <version>${pi4j.version}</version>
        </dependency>

        <!-- Pi4J Plugins (Platform and I/O Provider), only included for testing -->
        <dependency>
            <groupId>com.pi4j</groupId>
            <artifactId>pi4j-plugin-raspberrypi</artifactId>
            <version>${pi4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.pi4j</groupId>
            <artifactId>pi4j-plugin-ffm</artifactId>
            <version>${pi4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.pi4j</groupId>
            <artifactId>pi4j-plugin-gpiod</artifactId>
            <version>${pi4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.pi4j</groupId>
            <artifactId>pi4j-plugin-linuxfs</artifactId>
            <version>${pi4j.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.pi4j</groupId>
            <artifactId>pi4j-plugin-pigpio</artifactId>
            <version>${pi4j.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>${junit.jupiter.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Maven Surefire Plugin for running tests -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>${maven-surefire-plugin.version}</version>
            </plugin>
        </plugins>
    </build>

    <!-- DISTRIBUTION REPOSITORIES -->
    <distributionManagement>
        <!-- Releases are handled by JReleaser via local staging; this entry is a fallback only -->
        <repository>
            <id>central</id>
            <name>Maven Central Portal</name>
            <url>https://central.sonatype.com/api/v1/publisher</url>
        </repository>
        <snapshotRepository>
            <id>sonatype-oss-snapshots</id>
            <name>Sonatype Open Source Maven Snapshots Repository</name>
            <url>https://central.sonatype.com/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>

    <profiles>
        <!-- DEFAULT PROFILE -->
        <profile>
            <id>default-profile</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
            <plugins>
                <!-- CHECKSTYLE -->
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-checkstyle-plugin</artifactId>
                    <version>${maven-checkstyle-plugin.version}</version>
                    <executions>
                        <execution>
                            <id>checkstyle-check</id>
                            <goals>
                                <goal>check</goal>
                            </goals>
                            <phase>validate</phase>
                        </execution>
                    </executions>
                    <configuration>
                        <failsOnError>true</failsOnError>
                        <configLocation>config/checkstyle/checkstyle.xml</configLocation>
                        <excludes>**/module-info.java</excludes>
                        <outputFileFormat>plain</outputFileFormat>
                        <consoleOutput>true</consoleOutput>
                    </configuration>
                </plugin>
            </plugins>
            </build>
        </profile>

        <!-- BUILD & INCLUDE JAVA SOURCES JAR  -->
        <profile>
            <id>sources</id>
            <activation>
                <property>
                    <name>release-build</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- INCLUDE SOURCE JAR -->
                    <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</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- BUILD & INCLUDE JAVADOC JAR  -->
        <profile>
            <id>javadoc</id>
            <activation>
                <property>
                    <name>release-build</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <!-- INCLUDE JAVADOC -->
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>${maven-javadoc-plugin.version}</version>
                        <configuration>
                            <additionalOptions>
                            </additionalOptions>
                        </configuration>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Profile to deploy to sonatype nexus -->
        <profile>
            <id>deploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.central</groupId>
                        <artifactId>central-publishing-maven-plugin</artifactId>
                        <version>${central-publishing-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <publishingServerId>central</publishingServerId>
                            <!--                            <autoPublish>true</autoPublish>-->
                            <!--                            <waitUntil>published</waitUntil>-->
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Profile to stage artifacts locally and release via JReleaser -->
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <!-- Generate sources JAR -->
                    <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>
                    <!-- Generate javadoc JAR -->
                    <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>
                            </execution>
                        </executions>
                    </plugin>
                    <!-- JReleaser: signs, publishes to Maven Central, creates GitHub Release -->
                    <plugin>
                        <groupId>org.jreleaser</groupId>
                        <artifactId>jreleaser-maven-plugin</artifactId>
                        <version>${jreleaser-maven-plugin.version}</version>
                        <configuration>
                            <jreleaser>
                                <!-- inherits project details (name, version, etc.) from Maven -->
                            </jreleaser>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
