<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>dev.openfeature.contrib</groupId>
        <artifactId>parent</artifactId>
        <version>[1.0,2.0)</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <groupId>dev.openfeature.contrib.providers</groupId>
    <artifactId>flagd</artifactId>
    <version>0.14.0</version> <!--x-release-please-version -->

    <properties>
        <!-- exclusion expression for e2e tests -->
        <testExclusions>**/e2e/*.java</testExclusions>
        <io.grpc.version>1.79.0</io.grpc.version>
        <!-- caution - updating this will break compatibility with older protobuf-java versions -->
        <protobuf-java.min.version>3.25.6</protobuf-java.min.version>
        <com.vmlens.version>1.2.28</com.vmlens.version>
        <!-- Transitive flagd-core version -->
        <flagd-core.version>[2.0.0,3.0.0)</flagd-core.version>
    </properties>

    <name>flagd</name>
    <description>flagd provider for Java</description>
    <url>https://openfeature.dev</url>

    <developers>
        <developer>
            <id>toddbaert</id>
            <name>Todd Baert</name>
            <organization>OpenFeature</organization>
            <url>https://openfeature.dev/</url>
        </developer>
    </developers>

    <dependencies>
        <!-- we inherent dev.openfeature.javasdk and the test dependencies from the parent pom -->

        <!-- flagd core evaluation logic -->
        <dependency>
            <groupId>dev.openfeature.contrib.tools</groupId>
            <artifactId>flagd-core</artifactId>
            <version>${flagd-core.version}</version>
        </dependency>

        <dependency>
            <groupId>com.google.protobuf</groupId>
            <artifactId>protobuf-java</artifactId>
        </dependency>

        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-netty-shaded</artifactId>
            <version>${io.grpc.version}</version>
        </dependency>

        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-protobuf</artifactId>
            <version>${io.grpc.version}</version>
        </dependency>

        <dependency>
            <groupId>io.grpc</groupId>
            <artifactId>grpc-stub</artifactId>
            <version>${io.grpc.version}</version>
        </dependency>

        <!-- grpc-netty-shaded bundles netty with epoll support for unix sockets -->

        <dependency>
            <!-- necessary for Java 9+ -->
            <groupId>org.apache.tomcat</groupId>
            <artifactId>annotations-api</artifactId>
            <version>6.0.53</version>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-collections4</artifactId>
            <version>4.5.0</version>
        </dependency>

        <dependency>
            <groupId>io.opentelemetry</groupId>
            <artifactId>opentelemetry-api</artifactId>
            <version>1.62.0</version>
        </dependency>

        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>5.14.3</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers</artifactId>
            <version>2.0.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.testcontainers</groupId>
            <artifactId>testcontainers-junit-jupiter</artifactId>
            <version>2.0.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.rest-assured</groupId>
            <artifactId>rest-assured</artifactId>
            <version>6.0.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.21.0</version>
            <scope>test</scope>
        </dependency>
        <!-- uncomment for logoutput during test runs -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>2.0.17</version>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>com.vmlens</groupId>
            <artifactId>api</artifactId>
            <version>${com.vmlens.version}</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <dependencyManagement>
        <dependencies>
            <!-- we need to generate protobuf sources with the minium protobuf version we want to be compatible with -->
            <dependency>
                <groupId>com.google.protobuf</groupId>
                <artifactId>protobuf-java</artifactId>
                <!-- caution - updating this will break compatibility with older protobuf-java versions -->
                <version>${protobuf-java.min.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <!-- required for protobuf generation -->
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>1.7.1</version>
            </extension>
        </extensions>

        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.6.3</version>
                <executions>
                    <execution>
                        <id>update-schemas-submodule</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <!-- run: git submodule update \-\-init schemas for protos -->
                            <executable>git</executable>
                            <arguments>
                                <argument>submodule</argument>
                                <argument>update</argument>
                                <argument>--init</argument>
                                <argument>schemas</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.xolstice.maven.plugins</groupId>
                <artifactId>protobuf-maven-plugin</artifactId>
                <version>0.6.1</version>
                <configuration>
                    <protocArtifact>com.google.protobuf:protoc:3.25.5:exe:${os.detected.classifier}</protocArtifact>
                    <pluginId>grpc-java</pluginId>
                    <pluginArtifact>io.grpc:protoc-gen-grpc-java:1.69.1:exe:${os.detected.classifier}</pluginArtifact>
                    <protoSourceRoot>${project.basedir}/schemas/protobuf/</protoSourceRoot>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>compile</goal>
                            <goal>compile-custom</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>codequality</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.github.spotbugs</groupId>
                        <artifactId>spotbugs-maven-plugin</artifactId>
                        <version>4.9.8.3</version>
                        <configuration>
                            <onlyAnalyze>dev.openfeature.contrib.-</onlyAnalyze>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>com.vmlens</groupId>
                        <artifactId>vmlens-maven-plugin</artifactId>
                        <version>${com.vmlens.version}</version>
                        <executions>
                            <execution>
                                <id>test</id>
                                <goals>
                                    <goal>test</goal>
                                </goals>
                                <configuration>
                                    <includes>
                                        <include>**/*CTest.java</include>
                                    </includes>
                                    <failIfNoTests>true</failIfNoTests>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <!-- this profile handles running the flagd e2e tests -->
            <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.6.3</version>
                        <executions>
                            <execution>
                                <id>update-test-harness-submodule</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <!-- run: git submodule update \-\-init test-harness -->
                                    <executable>git</executable>
                                    <arguments>
                                        <argument>submodule</argument>
                                        <argument>update</argument>
                                        <argument>--init</argument>
                                        <argument>test-harness</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <execution>
                                <id>update-spec-submodule</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <!-- run: git submodule update \-\-init spec -->
                                    <executable>git</executable>
                                    <arguments>
                                        <argument>submodule</argument>
                                        <argument>update</argument>
                                        <argument>--init</argument>
                                        <argument>spec</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
