<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>

    <parent>
        <groupId>io.confluent</groupId>
        <artifactId>metadata-service-parent</artifactId>
        <version>7.3.15</version>
    </parent>

    <artifactId>rbac-api-server</artifactId>
    <packaging>jar</packaging>
    <name>rbac-api-server</name>

    <description>
        Provides a Kafka Broker plugin that implemnts the RBAC http Api.
    </description>

    <properties>
        <!-- Compile / runtime -->
        <concurrent-trees.version>2.6.1</concurrent-trees.version>
        <auto-value.version>1.8.1</auto-value.version>
        <auto-service.version>1.0</auto-service.version>

        <!-- Test -->
        <jolt.version>0.1.1</jolt.version>

        <!-- This should match ce-kafka.   We have to specify this here because
             when we pull ce-kafka "test class" dependencies we are doing it via
             "classifier" which does not get us a separate "test" transitive
             dependency graph. -->
        <apacheDirectoryServer.version>2.0.0-M24</apacheDirectoryServer.version>
        <io.confluent.confluent-security-plugins.version>${confluent.version.range}</io.confluent.confluent-security-plugins.version>
    </properties>

    <dependencies>

        <!-- Base Dependencies -->
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>rest-utils</artifactId>
            <version>${io.confluent.rest-utils.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.kafka</groupId>
                    <artifactId>*</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>ce-kafka-http-server</artifactId>
            <version>${io.confluent.ce-kafka-http-server.version}</version>
        </dependency>
        <dependency>
            <groupId>com.google.auto.value</groupId>
            <artifactId>auto-value-annotations</artifactId>
            <version>${auto-value.version}</version>
        </dependency>

        <!-- ce-kafka plugin runtime dependencies -->
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jsr310</artifactId>
            <!-- We don't specify a version here, because we want this to be
                 inherited from an ancestor pom. Further, jackson bom maybe 
                 ahead of ${jackson.version} with additional security patches,
                 which is why we just skip it entirely -->
        </dependency>

        <!-- ce-kafka plugin runtime dependencies -->
        <dependency>
            <!-- This is where the MetadataServer interface is defined that MDS implements -->
            <groupId>io.confluent</groupId>
            <artifactId>auth-providers</artifactId>
            <version>${ce.kafka.version}</version>
        </dependency>
        <dependency>
            <!-- Need because of at least PatternType pojo -->
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>${ce.kafka.version}</version>
        </dependency>
        <dependency>
            <!-- AclResource uses request entities defined by the RestClient in ce-kafka -->
            <groupId>io.confluent</groupId>
            <artifactId>rest-authorizer</artifactId>
            <version>${ce.kafka.version}</version>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>confluent-security-plugins-common</artifactId>
            <version>${io.confluent.confluent-security-plugins.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>io.confluent</groupId>
                    <artifactId>confluent-licensing-new</artifactId>
                </exclusion>
                <exclusion>
                    <!-- Don't need to pull in the Schema Registry Client -->
                    <groupId>io.confluent</groupId>
                    <artifactId>kafka-schema-registry-client</artifactId>
                </exclusion>
                <!-- confluent-security-plugins pulls in cc-security-decisions-client, which
                     pulls in these 3 log4j dependencies, which causes JWTDebugLoggingTest to fail -->
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.logging.log4j</groupId>
                    <artifactId>log4j-slf4j-impl</artifactId>
                </exclusion>
                <exclusion>
                  <groupId>org.bouncycastle</groupId>
                  <artifactId>bc-fips</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.bouncycastle</groupId>
                    <artifactId>bcpkix-fips</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>confluent-resource-names</artifactId>
            <version>${ce.kafka.version}</version>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>confluent-audit</artifactId>
            <version>${ce.kafka.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>io.confluent</groupId>
                    <artifactId>broker-plugins</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <!-- Nice implementation of a RadixTree, used in the Manage Rolebindings of others
                 apis. -->
            <groupId>com.googlecode.concurrent-trees</groupId>
            <artifactId>concurrent-trees</artifactId>
            <version>${concurrent-trees.version}</version>
        </dependency>

        <dependency>
            <!-- For bean validation annotations ala @V1ValidScope -->
            <groupId>org.glassfish.jersey.ext</groupId>
            <artifactId>jersey-bean-validation</artifactId>
        </dependency>

        <dependency>
            <!-- Used by the MDS silent proxy writes to the leader node logic.-->
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-proxy</artifactId>
            <version>${jetty.version}</version>
        </dependency>

        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>logredactor</artifactId>
            <version>${logredactor.version}</version>
        </dependency>
        
        <dependency>
            <!-- Jersey uses Java Logging, this dependency allows us to control Jersey's logging
                from our log4j.properties file so that we can turn _off_ the
                Jersey dependency injection "providers" warnings and redirect logs to slf4j loggers -->
            <groupId>org.slf4j</groupId>
            <artifactId>jul-to-slf4j</artifactId>
            <version>${slf4j.version}</version>
        </dependency>

        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>rbac-common</artifactId>
            <version>${io.confluent.metadata-service.version}</version>
        </dependency>

        <!-- TEST Dependencies -->
        <dependency>
            <!-- Need to be able to run Kafka for test, but not have it as a runtime dep
                 for packaging purposes. -->
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_${kafka.scala.version}</artifactId>
            <version>${ce.kafka.version}</version>
            <scope>test</scope>
        </dependency>

        <!--
            If you run into issues running tests inside Intellij because of Open JavaFX being
            compiled with JDK11 while you are running JDK8, you need to tell Intellij to use
            Java 8 when internally running maven.

            FYI, As of the "2019" versions of Intellij, it ships with and uses JDK11 by default,
            which triggers a maven profile way up the dependency tree of audit logs.

            Preferences -> "Build, Execution, Deployment" -> "Build Tools" -> "Maven" -> "Importing"
              "JDK for importer" : select your jdk8
        -->

        <!-- TEST - Basics -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <scope>test</scope>
        </dependency>

        <!-- TEST - Confluent Things -->
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>confluent-licensing-new</artifactId>
            <version>${ce.kafka.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>rest-utils-test</artifactId>
            <version>${io.confluent.rest-utils.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>testing-ldap</artifactId>
            <version>${io.confluent.metadata-service.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>testing-ldap-cli</artifactId>
            <version>${io.confluent.metadata-service.version}</version>
            <scope>test</scope>
        </dependency>

        <!-- TEST - Tools -->
        <dependency>
            <!-- For Diffy and general JSON handling -->
            <groupId>com.bazaarvoice.jolt</groupId>
            <artifactId>json-utils</artifactId>
            <version>${jolt.version}</version>
            <scope>test</scope>
        </dependency>


        <!-- TEST - Explicitly pulling "test-jars" from ce-kafka, as it has some handy utils
             we would like to use, namely LdapTestUtils. -->
        <!-- -->
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka_${kafka.scala.version}</artifactId>
            <version>${ce.kafka.version}</version>
            <classifier>test</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>auth-metadata</artifactId>
            <version>${ce.kafka.version}</version>
        </dependency>
        <dependency>
            <!-- provides MockFaultHandler, which some Kafka test code needs -->
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-server-common</artifactId>
            <version>${ce.kafka.version}</version>
            <classifier>test</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>broker-plugins</artifactId>
            <version>${ce.kafka.version}</version>
            <classifier>test</classifier>
            <scope>test</scope>
            <exclusions>
              <exclusion>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-jdk18on</artifactId>
              </exclusion>
              <exclusion>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcpkix-jdk18on</artifactId>
              </exclusion>
              <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
              </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>broker-plugins</artifactId>
            <version>${ce.kafka.version}</version>
            <scope>test</scope>
            <exclusions>
              <exclusion>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcpkix-jdk15on</artifactId>
              </exclusion>
              <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
              </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>${ce.kafka.version}</version>
            <classifier>test</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>auth-providers</artifactId>
            <version>${ce.kafka.version}</version>
            <classifier>test</classifier>
            <scope>test</scope>
        </dependency>

        <!-- TEST - Manually pulling LDAP code, as pulling in test jars
             does not give you transitive dependencies, so we
             have to enumerate all the LDAP stuff that the ce-kafka testing uses -->
        <!-- Note we are not using/testing kerberos here, but they are still needed as the
             Kafka test tools link them. -->
        <dependency>
            <groupId>org.apache.directory.server</groupId>
            <artifactId>apacheds-interceptor-kerberos</artifactId>
            <version>${apacheDirectoryServer.version}</version>
            <scope>test</scope>
            <exclusions>
              <exclusion>
                <groupId>org.bouncycastle</groupId>
                <artifactId>bcprov-jdk15on</artifactId>
              </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.directory.server</groupId>
            <artifactId>apacheds-protocol-kerberos</artifactId>
            <version>${apacheDirectoryServer.version}</version>
            <scope>test</scope>
        </dependency>

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

        <!-- For a Nice Java-y type safe Client -->
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>retrofit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>converter-jackson</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.squareup.retrofit2</groupId>
            <artifactId>converter-scalars</artifactId>
            <scope>test</scope>
        </dependency>

        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>mds-test-tools</artifactId>
            <version>${io.confluent.metadata-service.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.confluent</groupId>
            <artifactId>kafka-client-plugins</artifactId>
            <version>${ce.kafka.version}</version>
            <scope>compile</scope>
        </dependency>

      <dependency>
        <groupId>io.confluent.security</groupId>
        <artifactId>authorizer-client</artifactId>
        <version>${project.version}</version>
        <scope>compile</scope>
      </dependency>
    </dependencies>

    <profiles>
        <profile>
            <id>runBox</id>
            <properties>
                <maven.test.skip>true</maven.test.skip>
                <skipUnitTests>true</skipUnitTests>
            </properties>
            <build>
                <defaultGoal>test</defaultGoal>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>buildnumber-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>none</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-checkstyle-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <configuration>
                            <skip>true</skip>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <phase>test</phase>
                                <goals>
                                    <goal>java</goal>
                                </goals>
                                <configuration>
                                    <!-- boxClass should be a -D command line param -->
                                    <mainClass>${boxClass}</mainClass>
                                    <classpathScope>test</classpathScope>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>cloudPackageSmokeTest</id>
            <activation>
                <property>
                    <name>MDS_CLOUD_SMOKE_TESTS</name>
                    <value>true</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-failsafe-plugin</artifactId>
                        <!-- Suppress the Junit Integration test group definition inherited from common, as
                             TestNG will see it an try to respect it.  -->
                        <configuration combine.self="override">

                            <suiteXmlFiles>
                                <!-- Just run the v2 tests using a topic backed mds.

                                     Ideally we would be testing against the DB, but the
                                     build system doesn't support that.

                                     These are cooperative tests, so they all run in single
                                     start/top of Kafka.
                                 -->
                                <file>testSuites/failsafe-parity-cooperative-topic.xml</file>
                            </suiteXmlFiles>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>com.google.auto.value</groupId>
                            <artifactId>auto-value</artifactId>
                            <version>${auto-value.version}</version>
                        </path>
                        <path>
                            <groupId>com.google.auto.service</groupId>
                            <artifactId>auto-service</artifactId>
                            <version>${auto-service.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <!-- Suppress the Junit Integration test group definition inherited from common
                     by forcing only our/this configuration to be used.
                     Means we have to duplicate the skipUnitTests featuure. -->
                <configuration combine.self="override">
                    <skip>${skipUnitTests}</skip>  <!-- ability to just skip unit tests -->
                    <suiteXmlFiles>
                        <file>testSuites/surefire.xml</file>

                        <!-- Mostly, do all the CP tests in surefire -->
                        <file>testSuites/failsafe-int-jUnit.xml</file>
                        <file>testSuites/failsafe-int-singleThreaded.xml</file>
                        <file>testSuites/failsafe-int-tokenTests.xml</file>
                        <file>testSuites/failsafe-int-classParallel.xml</file>

                        <!-- this suite has one cc-rbac test -->
                        <file>testSuites/failsafe-configuration.xml</file>
                    </suiteXmlFiles>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-testng</artifactId>
                        <version>${maven-surefire-plugin-module.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <!-- Suppress the Junit Integration test group definition inherited from common, as
                     TestNG will see it an try to respect it.  -->
                <configuration combine.self="override">

                    <suiteXmlFiles>
                        <file>testSuites/failsafe-int-jUnit.xml</file>
                        <file>testSuites/failsafe-int-singleThreaded.xml</file>
                        <file>testSuites/failsafe-int-tokenTests.xml</file>
                        <file>testSuites/failsafe-int-classParallel.xml</file>
                        <file>testSuites/failsafe-configuration.xml</file>
                    </suiteXmlFiles>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.apache.maven.surefire</groupId>
                        <artifactId>surefire-testng</artifactId>
                        <version>${maven-surefire-plugin-module.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <descriptors>
                        <descriptor>src/assembly/stub-mds-development.xml</descriptor>
                        <descriptor>src/assembly/live-mds-development.xml</descriptor>
                        <descriptor>src/assembly/package.xml</descriptor>
                    </descriptors>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
