<?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.dropchop</groupId>
  <artifactId>snakejar</artifactId>
  <version>1.0.2</version>
  <name>SnakeJar</name>
  <url>https://github.com/ivlcic/snakejar</url>
  <description>A Java library with embedded Python (CPython) which supports native image compile and usage
    in Java Application Servers, targeting native Python Machine Learning frameworks and libraries.</description>

  <properties>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.scm.id>github</project.scm.id>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <version.slf4j>1.7.32</version.slf4j>
    <build.executable>./build.sh</build.executable>
  </properties>

  <licenses>
    <license>
      <name>The Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <developers>
    <developer>
      <id>ivlcic</id>
      <name>Nikola Ivačič</name>
      <email>nikola.ivacic@dropchop.com</email>
    </developer>
  </developers>

  <scm>
    <connection>scm:git:https://github.com/ivlcic/snakejar.git</connection>
    <developerConnection>scm:git:https://github.com/ivlcic/snakejar.git</developerConnection>
    <url>https://github.com/ivlcic/snakejar</url>
    <tag>snakejar-1.0.2</tag>
  </scm>

  <profiles>
    <profile>
      <id>maven-central</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>https://repo1.maven.org/maven2</url>
        </repository>
        <repository>
          <id>ossrh</id>
          <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url>
        </repository>
        <repository>
          <id>ossrh-snap</id>
          <url>https://oss.sonatype.org/content/repositories/snapshots</url>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
      <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>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.0.1</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>verify</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
                <configuration>
                  <!-- Prevent gpg from using pinentry programs. Fixes: gpg: signing failed: Inappropriate ioctl for device -->
                  <gpgArguments>
                    <arg>--pinentry-mode</arg>
                    <arg>loopback</arg>
                  </gpgArguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <dependencies>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>5.7.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${version.slf4j}</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <!-- copy all dependencies to target/dependencies -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>copy-dependencies</id>
            <phase>generate-resources</phase>
            <goals>
              <goal>copy-dependencies</goal>
            </goals>
            <inherited>false</inherited>
            <configuration>
              <useBaseVersion>true</useBaseVersion>
              <addParentPoms>true</addParentPoms>
              <copyPom>true</copyPom>
              <useRepositoryLayout>true</useRepositoryLayout>
              <outputDirectory>${project.build.directory}/dependencies</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- execute Gradle command -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.0.0</version>
        <executions>
          <execution>
            <id>build</id>
            <phase>prepare-package</phase>
            <configuration>
              <executable>${build.executable}</executable>
              <arguments>
                <argument>${project.groupId}</argument>
                <argument>${project.version}</argument>
                <argument>-S</argument>
              </arguments>
            </configuration>
            <goals>
              <goal>exec</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <!-- copy generated JARs -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>copy-libs</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target/classes</outputDirectory>
              <resources>
                <resource>
                  <directory>build/prep/</directory>
                  <includes>
                    <include>lib*.so</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-gradle-jars</id>
            <phase>package</phase>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <configuration>
              <outputDirectory>${basedir}/target</outputDirectory>
              <resources>
                <resource>
                  <directory>build/libs/</directory>
                  <includes>
                    <include>${project.artifactId}-${project.version}.jar</include>
                    <include>${project.artifactId}-${project.version}-javadoc.jar</include>
                    <include>${project.artifactId}-${project.version}-sources.jar</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- attach copied JARs to build -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>3.2.0</version>
        <executions>
          <execution>
            <id>attach-artifacts</id>
            <phase>package</phase>
            <goals>
              <goal>attach-artifact</goal>
            </goals>
            <configuration>
              <artifacts>
                <artifact>
                  <file>target/${project.artifactId}-${project.version}-javadoc.jar</file>
                  <type>jar</type>
                  <classifier>javadoc</classifier>
                </artifact>
                <artifact>
                  <file>target/${project.artifactId}-${project.version}-sources.jar</file>
                  <type>jar</type>
                  <classifier>sources</classifier>
                </artifact>
              </artifacts>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.3.1</version>
        <configuration>
          <doclint>none</doclint>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
