<?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.ustermetrics</groupId>
    <artifactId>scip4j-native</artifactId>
    <version>0.0.1-9.1.0</version>

    <properties>
        <java.version>22</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <git.repository>https://github.com/atraplet/${project.artifactId}</git.repository>
        <natives.dir>src/main/resources/natives</natives.dir>
        <natives.lib.version>910</natives.lib.version>
        <natives.download.url>https://github.com/atraplet/scip/releases/download</natives.download.url>
    </properties>

    <name>${project.groupId}:${project.artifactId}</name>
    <description>SCIP Solver for Java Native Libraries</description>
    <url>${git.repository}</url>

    <licenses>
        <license>
            <name>Apache License Version 2.0</name>
            <url>https://www.apache.org/licenses/LICENSE-2.0</url>
        </license>
    </licenses>

    <developers>
        <developer>
            <name>Adrian Trapletti</name>
            <email>a.trapletti@ustermetrics.com</email>
            <organization>Uster Metrics GmbH</organization>
            <organizationUrl>https://www.ustermetrics.com</organizationUrl>
        </developer>
    </developers>

    <scm>
        <connection>scm:git:${git.repository}.git</connection>
        <developerConnection>scm:git:${git.repository}.git</developerConnection>
        <url>${git.repository}/tree/master</url>
    </scm>

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

    <dependencies>
        <dependency>
            <groupId>org.scijava</groupId>
            <artifactId>native-lib-loader</artifactId>
            <version>2.5.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.10.3</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.4.0</version>
                <configuration>
                    <filesets>
                        <fileset>
                            <directory>${natives.dir}</directory>
                            <includes>
                                <include>linux_64/*</include>
                                <include>windows_64/*</include>
                            </includes>
                        </fileset>
                    </filesets>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>3.6.0</version>
                <executions>
                    <execution>
                        <id>regex-property</id>
                        <goals>
                            <goal>regex-property</goal>
                        </goals>
                        <configuration>
                            <name>module.name</name>
                            <value>${project.artifactId}</value>
                            <regex>-</regex>
                            <replacement>_</replacement>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>1.9.0</version>
                <executions>
                    <execution>
                        <id>download libscip.so</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>${natives.download.url}/v${natives.lib.version}/libscip.so</url>
                            <outputDirectory>${project.basedir}/${natives.dir}/linux_64</outputDirectory>
                            <md5>3f5abf0ad6a746d890f23e112b8ef337</md5>
                        </configuration>
                    </execution>
                    <execution>
                        <id>download libtbb.so</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>${natives.download.url}/v${natives.lib.version}/libtbb.so</url>
                            <outputDirectory>${project.basedir}/${natives.dir}/linux_64</outputDirectory>
                            <md5>5275c2fe02bcd0b03782ceee69b9c3cb</md5>
                        </configuration>
                    </execution>
                    <execution>
                        <id>download scip.dll</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>${natives.download.url}/v${natives.lib.version}/scip.dll</url>
                            <outputDirectory>${project.basedir}/${natives.dir}/windows_64</outputDirectory>
                            <md5>0cc1295b11d857a74a5721e7917c7a41</md5>
                        </configuration>
                    </execution>
                    <execution>
                        <id>download tbb.dll</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>${natives.download.url}/v${natives.lib.version}/tbb.dll</url>
                            <outputDirectory>${project.basedir}/${natives.dir}/windows_64</outputDirectory>
                            <md5>fabd8f26efd2f4e941c262ea86074be3</md5>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>3.4.2</version>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <!--suppress UnresolvedMavenProperty -->
                            <Automatic-Module-Name>${project.groupId}.${module.name}</Automatic-Module-Name>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>3.3.0</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>3.3.1</version>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <goals>
                                    <goal>jar-no-fork</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.7.0</version>
                        <executions>
                            <execution>
                                <id>attach-javadocs</id>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>3.2.4</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                                <configuration>
                                    <gpgArguments>
                                        <arg>--pinentry-mode</arg>
                                        <arg>loopback</arg>
                                    </gpgArguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.sonatype.plugins</groupId>
                        <artifactId>nexus-staging-maven-plugin</artifactId>
                        <version>1.7.0</version>
                        <extensions>true</extensions>
                        <configuration>
                            <serverId>ossrh</serverId>
                            <nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
                            <autoReleaseAfterClose>true</autoReleaseAfterClose>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
