<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>dev.openfeature</groupId>
  <artifactId>sdk</artifactId>
  <version>1.10.0</version> <!--x-release-please-version -->

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>${maven.compiler.source}</maven.compiler.target>
    <junit.jupiter.version>5.11.0</junit.jupiter.version>
     <!-- exclusion expression for e2e tests -->
    <testExclusions>**/e2e/*.java</testExclusions>
    <module-name>${project.groupId}.${project.artifactId}</module-name>
  </properties>

  <name>OpenFeature Java SDK</name>
  <description>This is the Java implementation of OpenFeature, a vendor-agnostic abstraction library for evaluating feature flags.</description>
  <url>https://openfeature.dev</url>
  <developers>
    <developer>
      <id>abrahms</id>
      <name>Justin Abrahms</name>
      <organization>eBay</organization>
      <url>https://justin.abrah.ms/</url>
    </developer>
  </developers>
  <licenses>
    <license>
      <name>Apache License 2.0</name>
      <url>https://www.apache.org/licenses/LICENSE-2.0</url>
    </license>
  </licenses>

  <scm>
    <connection>scm:git:https://github.com/open-feature/java-sdk.git</connection>
    <developerConnection>scm:git:https://github.com/open-feature/java-sdk.git</developerConnection>
    <url>https://github.com/open-feature/java-sdk</url>
  </scm>

  <dependencies>

    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>1.18.34</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <!-- used so that lombok can generate suppressions for spotbugs. It needs to find it on the relevant classpath -->
      <groupId>com.github.spotbugs</groupId>
      <artifactId>spotbugs</artifactId>
      <version>4.8.6</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>2.0.16</version>
    </dependency>

    <!-- test -->
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>4.11.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>3.26.3</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit.jupiter.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
      <version>${junit.jupiter.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <version>${junit.jupiter.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>${junit.jupiter.version}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.junit.platform</groupId>
      <artifactId>junit-platform-suite</artifactId>
      <version>1.11.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-java</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.cucumber</groupId>
      <artifactId>cucumber-junit-platform-engine</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.simplify4u</groupId>
      <artifactId>slf4j2-mock</artifactId>
      <version>2.3.0</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.google.guava</groupId>
      <artifactId>guava</artifactId>
      <version>33.3.0-jre</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.awaitility</groupId>
      <artifactId>awaitility</artifactId>
      <version>4.2.2</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <dependencyManagement>
    <dependencies>

      <!-- Start mockito workaround -->
      <!-- https://github.com/mockito/mockito/issues/3121 -->
      <!-- These are transitive dependencies of mockito we are forcing -->
      <dependency>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy</artifactId>
        <version>1.15.1</version>
        <scope>test</scope>
      </dependency>

      <dependency>
        <groupId>net.bytebuddy</groupId>
        <artifactId>byte-buddy-agent</artifactId>
        <version>1.15.1</version>
        <scope>test</scope>
      </dependency>
      <!-- End mockito workaround-->

      <dependency>
        <groupId>io.cucumber</groupId>
        <artifactId>cucumber-bom</artifactId>
        <version>7.18.1</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>5.11.0</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>

    </dependencies>
  </dependencyManagement>

  <build>
    <plugins>
      <plugin>
        <groupId>org.cyclonedx</groupId>
        <artifactId>cyclonedx-maven-plugin</artifactId>
        <version>2.8.1</version>
        <configuration>
          <projectType>library</projectType>
          <schemaVersion>1.3</schemaVersion>
          <includeBomSerialNumber>true</includeBomSerialNumber>
          <includeCompileScope>true</includeCompileScope>
          <includeProvidedScope>true</includeProvidedScope>
          <includeRuntimeScope>true</includeRuntimeScope>
          <includeSystemScope>true</includeSystemScope>
          <includeTestScope>false</includeTestScope>
          <includeLicenseText>false</includeLicenseText>
          <outputFormat>all</outputFormat>
        </configuration>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>makeAggregateBom</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <version>3.8.0</version>
        <executions>
          <execution>
            <phase>verify</phase>
            <goals>
              <goal>analyze</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <failOnWarning>true</failOnWarning>
          <ignoredUnusedDeclaredDependencies>
            <ignoredUnusedDeclaredDependency>com.github.spotbugs:*</ignoredUnusedDeclaredDependency>
            <ignoredUnusedDeclaredDependency>org.junit*</ignoredUnusedDeclaredDependency>
            <ignoredUnusedDeclaredDependency>org.simplify4u:slf4j2-mock*</ignoredUnusedDeclaredDependency>
          </ignoredUnusedDeclaredDependencies>
          <ignoredDependencies>
            <ignoredDependency>com.google.guava*</ignoredDependency>
            <ignoredDependency>io.cucumber*</ignoredDependency>
            <ignoredDependency>org.junit*</ignoredDependency>
            <ignoredDependency>com.google.code.findbugs*</ignoredDependency>
            <ignoredDependency>com.github.spotbugs*</ignoredDependency>
            <ignoredDependency> org.simplify4u:slf4j-mock-common:*</ignoredDependency>
          </ignoredDependencies>
        </configuration>
      </plugin>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.13.0</version>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <argLine>
            ${surefireArgLine}
          </argLine>
          <excludes>
            <!-- tests to exclude -->
            <exclude>${testExclusions}</exclude>
          </excludes>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <argLine>
            ${surefireArgLine}
          </argLine>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>0.8.12</version>

        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent</goal>
            </goals>

            <configuration>
              <destFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</destFile>
              <propertyName>surefireArgLine</propertyName>
            </configuration>
          </execution>

          <execution>
            <id>report</id>
            <phase>verify</phase>
            <goals>
              <goal>report</goal>
            </goals>

            <configuration>
              <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
              <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
            </configuration>
          </execution>

          <execution>
            <id>jacoco-check</id>
            <goals>
              <goal>check</goal>
            </goals>
            <configuration>
              <dataFile>${project.build.directory}/coverage-reports/jacoco-ut.exec</dataFile>
              <excludes>
                <exclude>dev/openfeature/sdk/exceptions/**</exclude>
              </excludes>

              <rules>
                <rule>
                  <element>PACKAGE</element>
                  <limits>
                    <limit>
                      <counter>LINE</counter>
                      <value>COVEREDRATIO</value>
                      <minimum>0.80</minimum>
                    </limit>
                  </limits>
                </rule>
              </rules>
            </configuration>
          </execution>

        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.4.2</version>
        <configuration>
          <archive>
            <manifestEntries>
              <Automatic-Module-Name>${module-name}</Automatic-Module-Name>
            </manifestEntries>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-pmd-plugin</artifactId>
        <version>3.25.0</version>
        <executions>
          <execution>
            <id>run-pmd</id>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <version>4.8.6.3</version>
        <configuration>
          <excludeFilterFile>spotbugs-exclusions.xml</excludeFilterFile>
          <plugins>
            <plugin>
              <groupId>com.h3xstream.findsecbugs</groupId>
              <artifactId>findsecbugs-plugin</artifactId>
              <version>1.13.0</version>
            </plugin>
          </plugins>
        </configuration>
        <dependencies>
          <!-- overwrite dependency on spotbugs if you want to specify the version of spotbugs -->
          <dependency>
            <groupId>com.github.spotbugs</groupId>
            <artifactId>spotbugs</artifactId>
            <version>4.8.6</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>run-spotbugs</id>
            <phase>verify</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-checkstyle-plugin</artifactId>
        <version>3.5.0</version>
        <configuration>
          <configLocation>checkstyle.xml</configLocation>
          <encoding>UTF-8</encoding>
          <consoleOutput>true</consoleOutput>
          <failsOnError>true</failsOnError>
          <linkXRef>false</linkXRef>
        </configuration>
        <dependencies>
          <dependency>
            <groupId>com.puppycrawl.tools</groupId>
            <artifactId>checkstyle</artifactId>
            <version>8.45.1</version>
          </dependency>
        </dependencies>
        <executions>
          <execution>
            <id>validate</id>
            <phase>validate</phase>
            <goals>
              <goal>check</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <!-- Deploy related plugins are isolated so that local development can ignore them -->
  <profiles>
    <profile>
      <id>deploy</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>

        <plugins>
          <!-- Begin publish to maven central -->
          <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>
          <!-- End publish to maven central -->

          <!-- Begin source & javadocs being generated -->
          <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.10.0</version>
            <configuration>
              <failOnWarnings>true</failOnWarnings>
              <doclint>all,-missing</doclint>  <!-- ignore missing javadoc, these are enforced with more customizability in the checkstyle plugin -->
            </configuration>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!-- end source & javadoc -->

          <!-- sign the jars -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-gpg-plugin</artifactId>
            <version>3.2.5</version>
            <executions>
              <execution>
                <id>sign-artifacts</id>
                <phase>install</phase>
                <goals>
                  <goal>sign</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <!-- end sign -->

        </plugins>
      </build>
    </profile>

    <profile>
      <id>e2e</id>
      <properties>
        <!-- run the e2e tests by clearing the exclusions -->
        <testExclusions/>
      </properties>
      <build>
        <plugins>
          <!-- pull the gherkin tests as a git submodule  -->
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.4.1</version>
            <executions>
              <execution>
                <id>update-test-harness-submodule</id>
                <phase>validate</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <!-- run: git submodule update \-\-init \-\-recursive -->
                  <executable>git</executable>
                  <arguments>
                    <argument>submodule</argument>
                    <argument>update</argument>
                    <argument>--init</argument>
                    <argument>test-harness</argument>
                  </arguments>
                </configuration>
              </execution>
              <execution>
                <id>copy-gherkin-tests</id>
                <phase>validate</phase>
                <goals>
                  <goal>exec</goal>
                </goals>
                <configuration>
                  <!-- copy the feature spec we want to test into resources so them can be easily loaded -->
                  <!-- run: cp test-harness/features/evaluation.feature src/test/resources/features/ -->
                  <executable>cp</executable>
                  <arguments>
                    <argument>test-harness/features/evaluation.feature</argument>
                    <argument>src/test/resources/features/</argument>
                  </arguments>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <distributionManagement>
    <snapshotRepository>
      <id>ossrh</id>
      <url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

</project>
