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

    <parent>
        <groupId>io.github.o2alexanderfedin.javafv</groupId>
        <artifactId>java-fv-parent</artifactId>
        <version>1.2.0</version>
    </parent>

    <artifactId>java-fv-yices</artifactId>
    <packaging>jar</packaging>

    <name>Java-FV Yices Solver</name>
    <description>Yices2 SMT solver backend for Java-FV (GPLv3 licensed)</description>

    <licenses>
        <license>
            <name>GNU General Public License, Version 3</name>
            <url>https://www.gnu.org/licenses/gpl-3.0.html</url>
        </license>
    </licenses>

    <dependencies>
        <!-- Compile dependency on verifier for SolverBackend interface -->
        <dependency>
            <groupId>io.github.o2alexanderfedin.javafv</groupId>
            <artifactId>verifier</artifactId>
            <version>${project.version}</version>
        </dependency>

        <!-- Checker Framework nullability annotations -->
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>checker-qual</artifactId>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>ch.qos.logback</groupId>
            <artifactId>logback-classic</artifactId>
        </dependency>

        <!-- Testing -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <executions>
                    <!-- Yices2 Linux x86_64 (static-gmp build) -->
                    <execution>
                        <id>download-yices-linux-x86_64</id>
                        <phase>generate-resources</phase>
                        <goals><goal>wget</goal></goals>
                        <configuration>
                            <url>https://github.com/SRI-CSL/yices2/releases/download/yices-${yices.version}/yices-${yices.version}-x86_64-pc-linux-gnu-static-gmp.tar.gz</url>
                            <unpack>true</unpack>
                            <outputDirectory>${project.build.directory}/yices-downloads/linux-x86_64</outputDirectory>
                            <outputFileName>yices-linux-x86_64.tar.gz</outputFileName>
                            <skipCache>false</skipCache>
                            <overwrite>false</overwrite>
                        </configuration>
                    </execution>
                    <!-- Yices2 macOS x86_64 (static-gmp build) -->
                    <execution>
                        <id>download-yices-macos-x86_64</id>
                        <phase>generate-resources</phase>
                        <goals><goal>wget</goal></goals>
                        <configuration>
                            <url>https://github.com/SRI-CSL/yices2/releases/download/yices-${yices.version}/yices-${yices.version}-x86_64-apple-darwin21.6.0-static-gmp.tar.gz</url>
                            <unpack>true</unpack>
                            <outputDirectory>${project.build.directory}/yices-downloads/macos-x86_64</outputDirectory>
                            <outputFileName>yices-macos-x86_64.tar.gz</outputFileName>
                            <skipCache>false</skipCache>
                            <overwrite>false</overwrite>
                        </configuration>
                    </execution>
                    <!-- Yices2 macOS ARM64 (static-gmp build) -->
                    <execution>
                        <id>download-yices-macos-arm64</id>
                        <phase>generate-resources</phase>
                        <goals><goal>wget</goal></goals>
                        <configuration>
                            <url>https://github.com/SRI-CSL/yices2/releases/download/yices-${yices.version}/yices-${yices.version}-arm-apple-darwin24.5.0-static-gmp.tar.gz</url>
                            <unpack>true</unpack>
                            <outputDirectory>${project.build.directory}/yices-downloads/macos-arm64</outputDirectory>
                            <outputFileName>yices-macos-arm64.tar.gz</outputFileName>
                            <skipCache>false</skipCache>
                            <overwrite>false</overwrite>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Copy Yices2 binaries from download location to classpath resource paths -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>copy-yices-binaries</id>
                        <phase>process-resources</phase>
                        <goals><goal>run</goal></goals>
                        <configuration>
                            <target>
                                <!-- Linux x86_64 -->
                                <copy todir="${project.build.outputDirectory}/yices/linux-x86_64"
                                      flatten="true" failonerror="true">
                                    <fileset dir="${project.build.directory}/yices-downloads/linux-x86_64">
                                        <include name="**/bin/yices-smt2"/>
                                    </fileset>
                                </copy>
                                <!-- macOS x86_64 -->
                                <copy todir="${project.build.outputDirectory}/yices/macos-x86_64"
                                      flatten="true" failonerror="true">
                                    <fileset dir="${project.build.directory}/yices-downloads/macos-x86_64">
                                        <include name="**/bin/yices-smt2"/>
                                    </fileset>
                                </copy>
                                <!-- macOS ARM64 -->
                                <copy todir="${project.build.outputDirectory}/yices/macos-arm64"
                                      flatten="true" failonerror="true">
                                    <fileset dir="${project.build.directory}/yices-downloads/macos-arm64">
                                        <include name="**/bin/yices-smt2"/>
                                    </fileset>
                                </copy>
                                <!-- Make binaries executable -->
                                <chmod file="${project.build.outputDirectory}/yices/linux-x86_64/yices-smt2"
                                       perm="755" failonerror="true"/>
                                <chmod file="${project.build.outputDirectory}/yices/macos-x86_64/yices-smt2"
                                       perm="755" failonerror="true"/>
                                <chmod file="${project.build.outputDirectory}/yices/macos-arm64/yices-smt2"
                                       perm="755" failonerror="true"/>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
