<?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/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>onl.mdw</groupId>
        <artifactId>mathcat4j-jni-parent</artifactId>
        <version>0.7.6-beta.9-1</version>
    </parent>

    <artifactId>mathcat4j-jni-libs</artifactId>
    <packaging>jar</packaging>

    <name>MathCAT4j JNI native libraries</name>
    <description>Native libraries for the mathcat4j-jni module.</description>
    <url>https://github.com/mwhapples/MathCAT4J-JNI</url>

    <properties>
        <mathcat4j.jni.lib.directory>${project.build.directory}/classes/onl/mdw/mathcat4j/jni/libs</mathcat4j.jni.lib.directory>
    </properties>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                        <configuration>
                            <attach>true</attach>
                        </configuration>
                    </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>
                        <configuration>
                            <attach>true</attach>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>build-current-platform</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.questdb</groupId>
                        <artifactId>rust-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>mathcat4j-jni</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <copyTo>${mathcat4j.jni.lib.directory}/</copyTo>
                                    <copyWithPlatformDir>true</copyWithPlatformDir>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>build-all-platforms</id>
            <activation>
                <activeByDefault>false</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.questdb</groupId>
                        <artifactId>rust-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>build-mathcat-jni-win32-x86-64</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <extraArgs>
                                        <extraArg>--target=x86_64-pc-windows-gnu</extraArg>
                                    </extraArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>build-mathcat-jni-win32-x86</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <extraArgs>
                                        <extraArg>--target=i686-pc-windows-gnu</extraArg>
                                    </extraArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>build-mathcat-jni-linux-x86-64</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <extraArgs>
                                        <extraArg>--target=x86_64-unknown-linux-gnu</extraArg>
                                    </extraArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>build-mathcat-jni-linux-x86</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <extraArgs>
                                        <extraArg>&#45;&#45;target=i686-unknown-linux-gnu</extraArg>
                                    </extraArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>build-mathcat-jni-linux-aarch64</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <extraArgs>
                                        <extraArg>--target=aarch64-unknown-linux-gnu</extraArg>
                                    </extraArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>build-mathcat-jni-linux-arm</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <extraArgs>
                                        <extraArg>--target=arm-unknown-linux-gnueabihf</extraArg>
                                    </extraArgs>
                                </configuration>
                            </execution>
                            <execution>
                                <id>build-mathcat-jni-darwin-x86-64</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <extraArgs>
                                        <extraArg>--target=x86_64-apple-darwin</extraArg>
                                    </extraArgs>
                                    <environmentVariables>
                                        <CC>o64-clang</CC>
                                        <CXX>o64-clang++</CXX>
                                    </environmentVariables>
                                </configuration>
                            </execution>
                            <execution>
                                <id>build-mathcat-jni-darwin-aarch64</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <configuration>
                                    <path>src/main/rust/mathcat4j</path>
                                    <release>true</release>
                                    <extraArgs>
                                        <extraArg>--target=aarch64-apple-darwin</extraArg>
                                    </extraArgs>
                                    <environmentVariables>
                                        <CC>oa64-clang</CC>
                                        <CXX>oa64-clang++</CXX>
                                    </environmentVariables>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-mathcat-jni-win32-x86-64</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/rust-maven-plugin/mathcat4j/x86_64-pc-windows-gnu/release/</directory>
                                            <includes>
                                                <include>mathcat4j.dll</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${mathcat4j.jni.lib.directory}/win32-x86-64</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-mathcat-jni-win32-x86</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/rust-maven-plugin/mathcat4j/i686-pc-windows-gnu/release/</directory>
                                            <includes>
                                                <include>mathcat4j.dll</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${mathcat4j.jni.lib.directory}/win32-x86</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-mathcat-jni-linux-x86-64</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/rust-maven-plugin/mathcat4j/x86_64-unknown-linux-gnu/release/</directory>
                                            <includes>
                                                <include>libmathcat4j.so</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${mathcat4j.jni.lib.directory}/linux-x86-64</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-mathcat-jni-linux-x86</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/rust-maven-plugin/mathcat4j/i686-unknown-linux-gnu/release/</directory>
                                            <includes>
                                                <include>libmathcat4j.so</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${mathcat4j.jni.lib.directory}/linux-x86</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-mathcat-jni-linux-aarch64</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/rust-maven-plugin/mathcat4j/aarch64-unknown-linux-gnu/release/</directory>
                                            <includes>
                                                <include>libmathcat4j.so</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${mathcat4j.jni.lib.directory}/linux-aarch64</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-mathcat-jni-linux-arm</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/rust-maven-plugin/mathcat4j/arm-unknown-linux-gnueabihf/release/</directory>
                                            <includes>
                                                <include>libmathcat4j.so</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${mathcat4j.jni.lib.directory}/linux-arm</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-mathcat-jni-darwin-x86-64</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/rust-maven-plugin/mathcat4j/x86_64-apple-darwin/release/</directory>
                                            <includes>
                                                <include>libmathcat4j.dylib</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${mathcat4j.jni.lib.directory}/darwin-x86-64</outputDirectory>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-mathcat-jni-darwin-aarch64</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>process-classes</phase>
                                <configuration>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/rust-maven-plugin/mathcat4j/aarch64-apple-darwin/release/</directory>
                                            <includes>
                                                <include>libmathcat4j.dylib</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <outputDirectory>${mathcat4j.jni.lib.directory}/darwin-aarch64</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
