<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>
  <name>Zeebe Distribution</name>
  <artifactId>camunda-cloud-zeebe</artifactId>
  <packaging>jar</packaging>

  <parent>
    <groupId>io.camunda</groupId>
    <artifactId>zeebe-parent</artifactId>
    <version>1.2.11</version>
    <relativePath>../parent/pom.xml</relativePath>
  </parent>

  <properties>
    <zbctl.force>false</zbctl.force>
    <zbctl.rootDir>${maven.multiModuleProjectDirectory}</zbctl.rootDir>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-broker</artifactId>
    </dependency>

    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-gateway</artifactId>
    </dependency>

    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-elasticsearch-exporter</artifactId>
    </dependency>

    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-util</artifactId>
    </dependency>

    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-atomix-cluster</artifactId>
    </dependency>

    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>zeebe-atomix-utils</artifactId>
    </dependency>

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

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
    </dependency>

    <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>simpleclient</artifactId>
    </dependency>

    <dependency>
      <groupId>io.prometheus</groupId>
      <artifactId>simpleclient_hotspot</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
    </dependency>

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

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-autoconfigure</artifactId>
    </dependency>

    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-core</artifactId>
      <exclusions>
        <exclusion>
          <!-- Conflicts with histogram in elasticsearch exporter dependency -->
          <groupId>org.hdrhistogram</groupId>
          <artifactId>HdrHistogram</artifactId>
        </exclusion>
      </exclusions>
    </dependency>

    <!-- needed for the Spring actuators which enable health checks and liveness probes-->
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-actuator-autoconfigure</artifactId>
    </dependency>

    <dependency>
      <groupId>io.micrometer</groupId>
      <artifactId>micrometer-registry-prometheus</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-beans</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-context</artifactId>
    </dependency>

    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
      <scope>test</scope>
    </dependency>

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

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

  <build>
    <finalName>camunda-cloud-zeebe-${project.version}</finalName>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>appassembler-maven-plugin</artifactId>
        <configuration>
          <configurationDirectory>config</configurationDirectory>
          <copyConfigurationDirectory>true</copyConfigurationDirectory>
          <includeConfigurationDirectoryInClasspath>true</includeConfigurationDirectoryInClasspath>
          <extraJvmArguments>
            -Xms128m
            --illegal-access=deny
            -XX:+ExitOnOutOfMemoryError
            -Dfile.encoding=UTF-8
          </extraJvmArguments>
          <repositoryLayout>flat</repositoryLayout>
          <useWildcardClassPath>true</useWildcardClassPath>
          <repositoryName>lib</repositoryName>
          <assembleDirectory>${project.build.directory}/camunda-cloud-zeebe</assembleDirectory>
          <platforms>
            <platform>windows</platform>
            <platform>unix</platform>
          </platforms>
          <programs>
            <program>
              <mainClass>io.camunda.zeebe.broker.StandaloneBroker</mainClass>
              <id>broker</id>
            </program>
            <program>
              <mainClass>io.camunda.zeebe.gateway.StandaloneGateway</mainClass>
              <id>gateway</id>
            </program>
          </programs>
        </configuration>
        <executions>
          <execution>
            <id>assemble</id>
            <phase>package</phase>
            <goals>
              <goal>assemble</goal>
            </goals>
            <configuration>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-antrun-plugin</artifactId>
        <executions>
          <execution>
            <id>copy-zbctl</id>
            <phase>package</phase>
            <goals>
              <goal>run</goal>
            </goals>
            <configuration>
              <target>
                <copy file="${zbctl.rootDir}/clients/go/cmd/zbctl/dist/zbctl" tofile="${project.build.directory}/camunda-cloud-zeebe/bin/zbctl" failonerror="${zbctl.force}" />
                <copy file="${zbctl.rootDir}/clients/go/cmd/zbctl/dist/zbctl.exe" tofile="${project.build.directory}/camunda-cloud-zeebe/bin/zbctl.exe" failonerror="${zbctl.force}" />
                <copy file="${zbctl.rootDir}/clients/go/cmd/zbctl/dist/zbctl.darwin" tofile="${project.build.directory}/camunda-cloud-zeebe/bin/zbctl.darwin" failonerror="${zbctl.force}" />
                <chmod dir="${project.build.directory}/camunda-cloud-zeebe/bin" perm="ugo+rx" includes="zbctl*" failonerror="${zbctl.force}" />
              </target>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>assemble</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>true</attach>
              <appendAssemblyId>false</appendAssemblyId>
              <descriptors>
                <descriptor>src/main/assembly.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <!-- dependencies only packaged but not explicitly used -->
          <usedDependencies>
            <dependency>io.camunda:zeebe-elasticsearch-exporter</dependency>

            <!-- Needed for Spring Actuators, which provide health checks and liveness/readiness probed -->
            <dependency>org.springframework.boot:spring-boot-starter-web</dependency>
            <dependency>io.micrometer:micrometer-core</dependency>
            <dependency>io.micrometer:micrometer-registry-prometheus</dependency>
          </usedDependencies>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

