<?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>
  <groupId>org.openpolicyagent</groupId>
  <artifactId>opa-java-wasm-parent</artifactId>
  <version>2.1.0</version>
  <packaging>pom</packaging>
  <name>OPA Wasm for Java</name>
  <description>Evaluate OPA policies in Wasm using the Endive runtime</description>
  <url>https://github.com/open-policy-agent/opa-java-wasm</url>

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

  <developers>
    <developer>
      <name>Andrea Peruffo</name>
      <email>andrea.peruffo1982@gmail.com</email>
      <organization>Red Hat</organization>
      <organizationUrl>https://www.redhat.com</organizationUrl>
    </developer>
  </developers>

  <modules>
    <module>core</module>
  </modules>

  <scm child.scm.connection.inherit.append.path="false" child.scm.developerConnection.inherit.append.path="false" child.scm.url.inherit.append.path="false">
    <connection>scm:git:https://github.com/open-policy-agent/opa-java-wasm.git</connection>
    <developerConnection>scm:git@github.com:open-policy-agent/opa-java-wasm.git</developerConnection>
    <url>https://github.com/open-policy-agent/opa-java-wasm.git</url>
  </scm>

  <properties>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.release>11</maven.compiler.release>
    <maven.compiler.testRelease>17</maven.compiler.testRelease>
    <maven-compiler-plugin.version>3.16.0</maven-compiler-plugin.version>
    <maven-source-plugin.version>3.4.0</maven-source-plugin.version>
    <maven-invoker-plugin.version>3.7.0</maven-invoker-plugin.version>
    <maven-failsafe-plugin.version>3.3.1</maven-failsafe-plugin.version>
    <maven-surefire-plugin.version>3.6.0</maven-surefire-plugin.version>
    <maven-plugin-plugin.version>3.13.1</maven-plugin-plugin.version>
    <versions-maven-plugin.version>2.17.1</versions-maven-plugin.version>
    <maven-javadoc-plugin.version>3.12.0</maven-javadoc-plugin.version>
    <maven-gpg-plugin.version>3.2.8</maven-gpg-plugin.version>
    <nexus-staging-maven-plugin.version>1.7.0</nexus-staging-maven-plugin.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <junit.version>6.1.3</junit.version>
    <endive.version>1.1.0</endive.version>
    <jackson.version>2.22.3</jackson.version>
    <spotless.version>3.10.4</spotless.version>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>run.endive</groupId>
        <artifactId>bom</artifactId>
        <version>${endive.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>${maven-compiler-plugin.version}</version>
        <configuration>
          <source>${maven.compiler.source}</source>
          <target>${maven.compiler.target}</target>
          <release>${maven.compiler.target}</release>
          <testRelease>${maven.compiler.testRelease}</testRelease>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <systemPropertyVariables>
            <jna.library.path>../target/release</jna.library.path>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>${maven-javadoc-plugin.version}</version>
        <configuration>
          <doclint>none</doclint>
          <source>1.8</source>
        </configuration>
        <executions>
          <execution>
            <id>attach-javadocs</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
        <version>${maven-source-plugin.version}</version>
        <executions>
          <execution>
            <id>attach-sources</id>
            <goals>
              <goal>jar</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>java17</id>
      <activation>
        <jdk>[17,)</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>com.diffplug.spotless</groupId>
            <artifactId>spotless-maven-plugin</artifactId>
            <version>${spotless.version}</version>
            <configuration>
              <formats>
                <format>
                  <includes>
                    <include>*.md</include>
                    <include>.gitignore</include>
                  </includes>
                  <trimTrailingWhitespace/>
                  <endWithNewline/>
                  <indent>
                    <spaces>true</spaces>
                    <spacesPerTab>2</spacesPerTab>
                  </indent>
                </format>
              </formats>
              <java>
                <includes>
                  <include>**/src/main/java/**/*.java</include>
                  <include>**/src/test/java/**/*.java</include>
                </includes>
                <googleJavaFormat>
                  <version>1.18.1</version>
                  <style>AOSP</style>
                  <reflowLongStrings>true</reflowLongStrings>
                  <formatJavadoc>false</formatJavadoc>
                </googleJavaFormat>
                <importOrder/>
                <removeUnusedImports/>
              </java>
              <pom>
                <includes>
                  <include>**/pom.xml</include>
                </includes>
                <sortPom/>
              </pom>
            </configuration>
            <executions>
              <execution>
                <id>format</id>
                <goals>
                  <goal>check</goal>
                </goals>
                <phase>process-sources</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>release</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>${maven-gpg-plugin.version}</version>
            <configuration>
              <gpgArguments>
                <arg>--pinentry-mode</arg>
                <arg>loopback</arg>
              </gpgArguments>
            </configuration>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <goals>
                  <goal>sign</goal>
                </goals>
                <phase>verify</phase>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.sonatype.central</groupId>
            <artifactId>central-publishing-maven-plugin</artifactId>
            <version>0.12.0</version>
            <extensions>true</extensions>
            <configuration>
              <publishingServerId>central</publishingServerId>
              <waitUntil>published</waitUntil>
              <autoPublish>true</autoPublish>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
