<?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>uk.co.matbooth.flatpak</groupId>
  <artifactId>flatpak-dev-shim</artifactId>
  <version>0.0.1</version>

  <name>Flatpak Development Shim</name>
  <url>https://github.com/mbooth101/flatpak-dev-shim</url>
  <description>Allows Java applications to launch processes on the sandbox host instead of inside the sandbox.</description>
  <inceptionYear>2018</inceptionYear>

  <developers>
    <developer>
      <name>Mat Booth</name>
      <email>mat.booth@redhat.com</email>
    </developer>
  </developers>

  <scm>
    <url>https://github.com/mbooth101/flatpak-dev-shim</url>
    <connection>
      scm:git:git://github.com/mbooth101/flatpak-dev-shim.git
    </connection>
    <developerConnection>
      scm:git:git@github.com:mbooth101/flatpak-dev-shim.git
    </developerConnection>
    <tag>flatpak-dev-shim-0.0.1</tag>
  </scm>

  <licenses>
    <license>
      <name>Eclipse Public License - Version 2.0</name>
      <url>http://www.eclipse.org/legal/epl-2.0</url>
      <distribution>repo</distribution>
    </license>
    <license>
      <name>GPLv2 with classpath exception</name>
      <url>https://openjdk.java.net/legal/gplv2+ce.html</url>
      <distribution>repo</distribution>
      <comments>
        The java.lang.ProcessBuilder class is a slightly modified version of that found in the OpenJDK.
        The nested classes ProcessPipeOutputStream and ProcessPipeInputStream found in the java.lang.FlatpakProcessImpl class are slightly modified versions of those found nested in the OpenJDK class java.lang.ProcessImpl.
      </comments>
    </license>
  </licenses>

  <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>

  <properties>
    <java.version>11</java.version>
    <maven.version>3.5.4</maven.version>
    <junit.jupiter.version>5.3.2</junit.jupiter.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <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>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>3.8.0</version>
          <configuration>
            <source>${java.version}</source>
            <target>${java.version}</target>
            <compilerArgs>
              <arg>-h</arg>
              <arg>${project.basedir}/jni</arg>
              <arg>--patch-module=java.base=src/main/java</arg>
            </compilerArgs>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <version>3.1.0</version>
        </plugin>
        <plugin>
          <artifactId>maven-source-plugin</artifactId>
          <version>3.0.1</version>
        </plugin>
        <plugin>
          <artifactId>maven-install-plugin</artifactId>
          <version>3.0.0-M1</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
          <configuration>
            <mavenExecutorId>forked-path</mavenExecutorId>
            <useReleaseProfile>false</useReleaseProfile>
            <arguments>-Prelease</arguments>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-deploy-plugin</artifactId>
          <version>3.0.0-M1</version>
        </plugin>
        <plugin>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>2.22.1</version>
          <configuration>
            <!-- sun.boot.library.path system property must be set in the 
              argument line and not later -->
            <argLine>--patch-module=java.base=${project.build.outputDirectory}
              -Dsun.boot.library.path=${sun.boot.library.path}:${project.build.directory}</argLine>
            <environmentVariables>
              <PATH>${env.PATH}:${project.build.directory}</PATH>
            </environmentVariables>
            <systemPropertyVariables>
              <flatpak.hostcommandrunner.debug>true</flatpak.hostcommandrunner.debug>
            </systemPropertyVariables>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>1.6.0</version>
        <executions>
          <execution>
            <id>build-natives</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <executable>make</executable>
              <workingDirectory>${project.basedir}/jni</workingDirectory>
              <arguments>
                <argument>all</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>clean-natives</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>clean</phase>
            <configuration>
              <executable>make</executable>
              <workingDirectory>${project.basedir}/jni</workingDirectory>
              <arguments>
                <argument>clean</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>attach-natives</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>${project.build.directory}/libflatpakdevshim.so</file>
                  <type>so</type>
                </artifact>
                <artifact>
                  <file>${project.build.directory}/hostcommandrunner</file>
                  <type>exe</type>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <!-- the standard maven javadoc plug-in won't generate an empty 
              jar, so for the purposes of deploying to maven central, we generate a jar 
              containing only a link to the official javadoc for java.lang.ProcessBuilder -->
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
                <configuration>
                  <classifier>javadoc</classifier>
                  <classesDirectory>${project.basedir}/src/main/javadoc</classesDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <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>
</project>
