<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (c) Microsoft Corporation.
  Licensed under the MIT License.
-->

<project>
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.microsoft.regorus</groupId>
  <artifactId>regorus-java</artifactId>
  <version>0.10.1</version>

  <name>Regorus Java</name>
  <description>Java bindings for Regorus - a fast, lightweight Rego interpreter written in Rust</description>
  <url>https://github.com/microsoft/regorus/bindings/java</url>

  <licenses>
    <license>
      <name>MIT License</name>
      <url>https://opensource.org/licenses/MIT</url>
    </license>
    <license>
      <name>Apache License 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
    <license>
      <name>BSD 3-Clause License</name>
      <url>https://opensource.org/licenses/BSD-3-Clause</url>
    </license>
  </licenses>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
  </properties>

  <distributionManagement>
    <repository>
      <id>ossrh</id>
      <name>Central Repository OSSRH</name>
      <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
    </repository>
  </distributionManagement>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.2</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.google.code.gson</groupId>
      <artifactId>gson</artifactId>
      <version>2.14.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource>
        <!-- 
          Include native/ folder in built JAR.
          During CI build we build native libraries for various platforms
          and put them into native/ folder. 
          See `.github/publish-java.yml`.
         -->
        <directory>${project.basedir}/native</directory>
      </resource>
    </resources>

    <plugins>
      <plugin>
        <artifactId>exec-maven-plugin</artifactId>
        <groupId>org.codehaus.mojo</groupId>
        <version>3.6.3</version>
        <executions>
          <execution>
            <!-- Build a debug release for tests -->
            <id>build-native-lib-for-test</id>
            <phase>test-compile</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>python3</executable>
              <arguments>
                <argument>${project.basedir}/tools/testbuild.py</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.5.5</version>
        <configuration>
          <!-- Add debug build to Java path, so it's discoverable by JVM. This is only for tests. -->
          <argLine>-Djava.library.path=${project.basedir}/target/debug:${java.library.path}</argLine>
        </configuration>
      </plugin>

      <!-- Build javadoc JAR, this is required by Maven Central. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.12.0</version>
        <executions>
          <execution>
            <id>attach-javadoc</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- Build sources JAR, this is required by Maven Central. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>3.4.0</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <reporting>
    <plugins>
      <plugin>
        <artifactId>maven-project-info-reports-plugin</artifactId>
      </plugin>
    </plugins>
  </reporting>
</project>
