<?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.rm5248</groupId>
    <artifactId>dbus-java-nativefd</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>DBus-java NativeFD</name>
    <url>https://github.com/rm5248/dbus-java-nativefd</url>
    <description>Allows you to send and receive FileDescriptors with com.github.hypfvieh:dbus-java</description>
    
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>

    <profiles>
        <profile>
            <id>linux-x86_64-release</id>
            <activation>
                <os>
                    <family>linux</family>
                    <arch>amd64</arch>
                </os>
            </activation>
            <properties>
                <platform>linux-x86_64</platform>
                <build.type>release</build.type>
                <cmake.classifier>linux-x86_64</cmake.classifier>
            </properties>
        </profile>

        <profile>
            <id>releaseProfile</id>

            <build>
                <plugins>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.6.8</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>

        </profile>
    </profiles>


    <dependencies>
        <dependency>
            <groupId>com.github.hypfvieh</groupId>
            <artifactId>dbus-java</artifactId>
            <version>[3.2.1,)</version>
        </dependency>

        <!-- JUnit testing framework. -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <version>5.5.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-params</artifactId>
            <version>5.5.2</version>
            <scope>test</scope>
        </dependency>

        <!-- needed for IDE support -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <version>5.5.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.junit.platform</groupId>
            <artifactId>junit-platform-launcher</artifactId>
            <version>1.5.2</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
            <version>1.2.3</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-core</artifactId>
            <version>1.2.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArgs>
                        <arg>-h</arg>
                        <arg>target/headers</arg>
                    </compilerArgs>
                </configuration>

                <executions>
                    <execution>
                        <id>generate-jni-headers</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            
            <plugin>
                <groupId>com.googlecode.cmake-maven-project</groupId>
                <artifactId>cmake-maven-plugin</artifactId>
                <version>3.16.3-b1</version>

                <executions>
                    <execution>
                        <id>cmake-generate</id>
                        <goals>
                            <goal>generate</goal>
                        </goals>

                        <configuration>
                            <sourcePath>${project.basedir}/src/main/jni</sourcePath>
                            <targetPath>${project.build.directory}/${platform}</targetPath>
                            <classifier>${cmake.classifier}</classifier>
                            <options>${cmake.options}</options>
                            <environmentVariables>
                                <CMAKE_CLASSIFIER>${cmake.classifier}</CMAKE_CLASSIFIER>
                            </environmentVariables>
                            <downloadBinaries>${download.cmake}</downloadBinaries>
                        </configuration>
                    </execution>

                    <execution>
                        <id>cmake-compile</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>

                        <configuration>
                            <projectDirectory>${project.build.directory}/${platform}</projectDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.0.0-M3</version>
                <configuration>
                    <forkCount>1</forkCount>
                    <reuseForks>false</reuseForks>
                    <systemPropertyVariables>
                        <logback.configurationFile>${basedir}/src/test/resources/logback.xml</logback.configurationFile>

                        <!-- Run the tests with the (newly compiled) library instead of extracting from the JAR -->
                        <com.rm5248.dbusnative.lib.path>${project.build.directory}/${platform}</com.rm5248.dbusnative.lib.path>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

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

    <scm>
        <url>https://github.com/rm5248/dbus-java-nativefd</url>
        <connection>scm:git:https://github.com/rm5248/dbus-java-nativefd.git</connection>
        <developerConnection>scm:git:git@github.com:rm5248/dbus-java-nativefd.git</developerConnection>
        <tag>dbus-java-nativefd-1.0</tag>
    </scm>

    <issueManagement>
        <url>https://github.com/rm5248/dbus-java-nativefd/issues</url>
    </issueManagement>

    <developers>
        <developer>
            <email>robert.middleton@rm5248.com</email>
            <id>rm5248</id>
            <name>Robert Middleton</name>
            <url>http://www.rm5248.com</url>
            <roles>
                <role>Main Developer</role>
            </roles>
        </developer>
    </developers>

</project>