<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright (C) 2018 Universal Character/Graphics display library
  ~
  ~ This program is free software: you can redistribute it and/or modify
  ~ it under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation, either version 3 of the
  ~ License, or (at your option) any later version.
  ~
  ~ This program is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  ~ GNU General Lesser Public License for more details.
  ~
  ~ You should have received a copy of the GNU General Lesser Public
  ~ License along with this program.  If not, see
  ~ <http://www.gnu.org/licenses/lgpl-3.0.html>.
  -->
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <parent>
    <groupId>com.ibasco.ucgdisplay</groupId>
    <artifactId>ucgd-parent</artifactId>
    <version>2.0.0-alpha</version>
    <relativePath>../../../pom.xml</relativePath>
  </parent>
  <groupId>com.ibasco.ucgdisplay</groupId>
  <artifactId>ucgd-native-graphics</artifactId>
  <version>2.0.0-alpha</version>
  <name>${project.prefix} Native :: Graphics</name>
  <licenses>
    <license>
      <name>GNU General Lesser Public License (LGPL) version 3.0</name>
      <url>http://www.gnu.org/licenses/lgpl.txt</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <properties>
    <main.basedir>${project.parent.basedir}</main.basedir>
    <build.type>Debug</build.type>
    <compile.native>false</compile.native>
    <skip.native.build>true</skip.native.build>
  </properties>
  <dependencies>
    <dependency>
      <groupId>com.ibasco.ucgdisplay</groupId>
      <artifactId>ucgd-common</artifactId>
    </dependency>
    <dependency>
      <groupId>org.scijava</groupId>
      <artifactId>native-lib-loader</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.commons</groupId>
      <artifactId>commons-lang3</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.ant</groupId>
      <artifactId>ant</artifactId>
    </dependency>
    <dependency>
      <groupId>commons-io</groupId>
      <artifactId>commons-io</artifactId>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <skip>${skip.native.build}</skip>
              <target>
                <echo>Building native GRAPHICS library (OS: ${current-os}, ARCH: ${current-arch}, BUILD
                                    TARGET: ${graphics.target}, BUILD TYPE: ${build.type})</echo>
                <property name="root.dir" location="../../.." />
                <ant antfile="${root.dir}/scripts/build-graphics.xml" target="${graphics.target}">
                  <property name="cpp.build.type" value="${build.type}" />
                </ant>
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <configuration>
          <filesets>
            <fileset>
              <directory>src/main/cpp/build</directory>
              <followSymlinks>false</followSymlinks>
            </fileset>
            <fileset>
              <directory>src/main/cpp/utils/build</directory>
              <followSymlinks>false</followSymlinks>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-source-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/UpdateControllerHeader.java</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <excludes>
            <exclude>**/utils/codegen/**</exclude>
          </excludes>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>${project.groupId}.ucgd.nativ.graphics</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>generate-native-headers</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <executions>
              <execution>
                <id>generate-headers</id>
                <phase>compile</phase>
                <goals>
                  <goal>compile</goal>
                </goals>
                <configuration>
                  <compilerArgs>
                    <arg>-h</arg>
                    <arg>${project.build.directory}/native-headers</arg>
                  </compilerArgs>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>build-linux-x86_64</id>
      <activation>
        <os>
          <name>linux</name>
          <family>unix</family>
          <arch>amd64</arch>
        </os>
        <property>
          <name>compile.native</name>
          <value>true</value>
        </property>
      </activation>
      <properties>
        <graphics.target>native-build-linux-x86_64</graphics.target>
        <current-os>linux</current-os>
        <current-arch>amd64</current-arch>
        <skip.native.build>false</skip.native.build>
      </properties>
    </profile>
    <profile>
      <id>build-linux-arm</id>
      <activation>
        <os>
          <name>linux</name>
          <family>unix</family>
          <arch>arm</arch>
        </os>
        <property>
          <name>compile.native</name>
          <value>true</value>
        </property>
      </activation>
      <properties>
        <graphics.target>native-build-linux-arm32</graphics.target>
        <current-os>linux</current-os>
        <current-arch>arm</current-arch>
        <skip.native.build>false</skip.native.build>
      </properties>
    </profile>
    <profile>
      <id>build-windows-x86_64</id>
      <activation>
        <os>
          <family>windows</family>
          <arch>amd64</arch>
        </os>
        <property>
          <name>compile.native</name>
          <value>true</value>
        </property>
      </activation>
      <properties>
        <graphics.target>native-build-windows-x86_64</graphics.target>
        <current-os>windows</current-os>
        <current-arch>amd64</current-arch>
        <skip.native.build>false</skip.native.build>
      </properties>
    </profile>
    <profile>
      <id>build-mac-x86_64</id>
      <activation>
        <os>
          <name>mac os x</name>
          <family>unix</family>
          <arch>x86_64</arch>
        </os>
        <property>
          <name>compile.native</name>
          <value>true</value>
        </property>
      </activation>
      <properties>
        <graphics.target>native-build-macosx-x86_64</graphics.target>
        <current-os>macosx</current-os>
        <current-arch>amd64</current-arch>
        <skip.native.build>false</skip.native.build>
      </properties>
    </profile>
  </profiles>
</project>
