<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright 2015-2019 The OpenZipkin Authors

    Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
    in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software distributed under the License
    is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
    or implied. See the License for the specific language governing permissions and limitations under
    the License.

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

  <parent>
    <groupId>io.zipkin.zipkin2</groupId>
    <artifactId>parent</artifactId>
    <version>2.12.0</version>
  </parent>

  <!-- TODO: group ID change: https://github.com/openzipkin/zipkin/issues/2132 -->
  <groupId>io.zipkin.java</groupId>
  <artifactId>zipkin-server</artifactId>
  <name>Zipkin Server</name>

  <properties>
    <main.basedir>${project.basedir}/..</main.basedir>
    <main.java.version>1.8</main.java.version>
    <main.signature.artifact>java18</main.signature.artifact>
    <start-class>zipkin.server.ZipkinServer</start-class>
    <maven-invoker-plugin.version>3.1.0</maven-invoker-plugin.version>

    <!-- Manual version updates to work around warnings mentioned in UNDERTOW-1355 -->
    <xnio.version>3.6.5.Final</xnio.version>
    <jboss-threads.version>2.3.2.Final</jboss-threads.version>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <!-- Import dependency management from Spring Boot -->
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-dependencies</artifactId>
        <version>${spring-boot.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <dependencies>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <!-- Use log4j 2 instead of SLF4J to allow log4j 1.2 used by Kafka 0.8 to still work -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-log4j2</artifactId>
    </dependency>

    <!-- reduces http transport latency -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-undertow</artifactId>
      <exclusions>
        <exclusion>
          <groupId>io.undertow</groupId>
          <artifactId>undertow-websockets-jsr</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- BEGIN WORKAROUNDS FOR UNDERTOW-1355 -->
    <dependency>
      <groupId>org.jboss.xnio</groupId>
      <artifactId>xnio-api</artifactId>
      <version>${xnio.version}</version>
      <exclusions>
        <exclusion>
          <groupId>org.jboss.threads</groupId>
          <artifactId>jboss-threads</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <dependency>
      <groupId>org.jboss.threads</groupId>
      <artifactId>jboss-threads</artifactId>
      <version>${jboss-threads.version}</version>
    </dependency>

    <dependency>
      <groupId>org.jboss.xnio</groupId>
      <artifactId>xnio-nio</artifactId>
      <version>${xnio.version}</version>
    </dependency>
    <!-- END WORKAROUNDS FOR UNDERTOW-1355 -->

    <!-- zipkin requires exporting /health endpoint -->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-configuration-processor</artifactId>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>io.zipkin.zipkin2</groupId>
      <artifactId>zipkin</artifactId>
    </dependency>

    <dependency>
      <groupId>io.zipkin.zipkin2</groupId>
      <artifactId>zipkin-collector</artifactId>
    </dependency>

    <!-- Static content for the web UI -->
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-ui</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>
    </dependency>

    <!-- Cassandra backend -->
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-storage-cassandra</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>
      <exclusions>
        <exclusion>
          <groupId>com.datastax.cassandra</groupId>
          <artifactId>cassandra-driver-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <!-- shaded to not interfere with netty 4.1 and boringssl. [JAVA-1241] -->
    <dependency>
      <groupId>com.datastax.cassandra</groupId>
      <artifactId>cassandra-driver-core</artifactId>
      <version>${cassandra-driver-core.version}</version>
      <classifier>shaded</classifier>
      <optional>true</optional>
      <exclusions>
        <exclusion>
          <groupId>io.netty</groupId>
          <artifactId>*</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
    <dependency>
      <groupId>com.datastax.cassandra</groupId>
      <artifactId>cassandra-driver-mapping</artifactId>
      <version>${cassandra-driver-core.version}</version>
      <optional>true</optional>
      <exclusions>
        <exclusion>
          <groupId>com.datastax.cassandra</groupId>
          <artifactId>cassandra-driver-core</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Cassandra 3 backend -->
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-storage-cassandra3</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>
      <exclusions>
        <exclusion>
          <groupId>com.datastax.cassandra</groupId>
          <artifactId>cassandra-driver-core</artifactId>
        </exclusion>
        <exclusion>
          <groupId>com.datastax.cassandra</groupId>
          <artifactId>cassandra-driver-mapping</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- Elasticsearch http -->
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-storage-elasticsearch</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>
    </dependency>

    <!-- MySQL backend -->
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-storage-mysql</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>
    </dependency>

    <!-- Kafka Collector -->
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-collector-kafka</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>
    </dependency>

    <!-- RabbitMQ Collector -->
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-collector-rabbitmq</artifactId>
      <version>${project.version}</version>
      <optional>true</optional>
    </dependency>

    <!--Prometheus metrics-->
    <dependency>
      <groupId>io.zipkin.java</groupId>
      <artifactId>zipkin-autoconfigure-metrics-prometheus</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- Trace api controller activity with Brave -->
    <dependency>
      <groupId>io.zipkin.brave</groupId>
      <artifactId>brave</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.zipkin.brave</groupId>
      <artifactId>brave-instrumentation-okhttp3</artifactId>
      <version>${brave.version}</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.zipkin.brave</groupId>
      <artifactId>brave-context-log4j2</artifactId>
      <version>${brave.version}</version>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.zipkin.brave.cassandra</groupId>
      <artifactId>brave-instrumentation-cassandra-driver</artifactId>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-test</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>io.zipkin.zipkin2</groupId>
      <artifactId>zipkin</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>com.jayway.jsonpath</groupId>
      <artifactId>json-path</artifactId>
      <version>2.4.0</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>integration</id>
      <activation>
        <activeByDefault>true</activeByDefault>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-invoker-plugin</artifactId>
            <version>${maven-invoker-plugin.version}</version>
            <configuration>
              <cloneProjectsTo>${project.build.directory}/it</cloneProjectsTo>
              <settingsFile>src/it/settings.xml</settingsFile>
              <profiles>
                <profile>!release</profile>
              </profiles>
              <localRepositoryPath>${project.build.directory}/local-repo</localRepositoryPath>
              <postBuildHookScript>verify</postBuildHookScript>
              <addTestClassPath>true</addTestClassPath>
              <skipInvocation>${skipTests}</skipInvocation>
              <streamLogs>true</streamLogs>
            </configuration>
            <executions>
              <execution>
                <id>integration-test</id>
                <goals>
                  <goal>install</goal>
                  <goal>run</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <resources>
      <resource>
        <directory>src/main/resources</directory>
        <filtering>true</filtering>
      </resource>
    </resources>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <classifier>exec</classifier>
          <executable>true</executable>
        </configuration>
      </plugin>
      <!-- disable retrolambda since this module uses java 8 types -->
      <plugin>
        <groupId>net.orfjackal.retrolambda</groupId>
        <artifactId>retrolambda-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>none</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
