<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>Camunda External Task Client - CLIENT</name>

  <artifactId>camunda-external-task-client</artifactId>

  <packaging>jar</packaging>

  <parent>
    <groupId>org.camunda.bpm</groupId>
    <artifactId>camunda-external-task-client-root</artifactId>
    <version>1.2.2</version>
  </parent>

  <properties>
    <!-- should be updated during a release together with the camunda.version tag in the project pom -->
    <camunda.version>7.11.0</camunda.version>

    <version.httpclient>4.5.7</version.httpclient>
    <version.jackson>2.9.9.3</version.jackson>

    <version.plugin.surefire>2.16</version.plugin.surefire>
    <version.plugin.failsafe>2.22.0</version.plugin.failsafe>
    <version.plugin.helper>3.0.0</version.plugin.helper>
    <version.plugin.cargo>1.6.10</version.plugin.cargo>

    <version.junit>4.10</version.junit>
    <version.slf4j>1.6.1</version.slf4j>
    <version.assertj>3.9.0</version.assertj>
    <version.jsonassert>1.5.0</version.jsonassert>
    <version.tomcat>9.0.19</version.tomcat>
    <version.jaxb>2.2.4</version.jaxb>
  </properties>

  <dependencies>

    <!-- mandatory dependencies -->
    <dependency>
      <groupId>org.camunda.commons</groupId>
      <artifactId>camunda-commons-logging</artifactId>
    </dependency>

    <dependency>
      <groupId>org.camunda.commons</groupId>
      <artifactId>camunda-commons-typed-values</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpclient</artifactId>
      <version>${version.httpclient}</version>
    </dependency>

    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-databind</artifactId>
      <version>${version.jackson}</version>
    </dependency>


    <!-- test dependencies -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${version.junit}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <version>${version.slf4j}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${version.assertj}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.bpm.model</groupId>
      <artifactId>camunda-bpmn-model</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.apache.httpcomponents</groupId>
      <artifactId>httpmime</artifactId>
      <version>${version.httpclient}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.skyscreamer</groupId>
      <artifactId>jsonassert</artifactId>
      <version>${version.jsonassert}</version>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.spin</groupId>
      <artifactId>camunda-spin-dataformat-all</artifactId>
      <scope>test</scope>
    </dependency>

    <dependency>
      <groupId>org.camunda.bpm.qa</groupId>
      <artifactId>engine-variable-test</artifactId>
      <version>${project.version}</version>
      <classifier>classes</classifier>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <plugins>

      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <version>${version.plugin.helper}</version>
        <executions>
          <execution>
            <id>add-it-source</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>add-test-source</goal>
            </goals>
            <configuration>
              <sources>
                <source>src/it/java</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${version.plugin.surefire}</version>
        <configuration>
          <skipTests>${skip.unit.tests}</skipTests>
          <trimStackTrace>false</trimStackTrace>
        </configuration>
      </plugin>

    </plugins>

    <testResources>
      <testResource>
        <directory>src/it/resources</directory>
      </testResource>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
    </testResources>

  </build>

  <profiles>
    <profile>
      <id>jdk-9-plus</id>
      <activation>
        <jdk>(1.8,)</jdk>
      </activation>

      <dependencies>
        <dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
          <version>${version.jaxb}</version>
          <scope>provided</scope>
        </dependency>
      </dependencies>
    </profile>

    <profile>
      <id>it</id>

      <!-- DO NOT REMOVE IF YOU DON'T KNOW WHAT YOU DO -->
      <repositories>
        <repository>
          <id>test</id>
          <url>http://repository</url>
          <releases>
            <enabled>false</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>

      <properties>
        <engine.runtime>${project.build.directory}/camunda-tomcat</engine.runtime>
        <tomcat.runtime>${engine.runtime}/server/apache-tomcat-${version.tomcat}</tomcat.runtime>
        <http.port>${tomcat.connector.http.port}</http.port>

        <tomcat.connector.http.port>48080</tomcat.connector.http.port>
        <tomcat.connector.http.redirectPort>48443</tomcat.connector.http.redirectPort>
        <tomcat.connector.ajp.port>48009</tomcat.connector.ajp.port>
        <tomcat.connector.ajp.redirectPort>48443</tomcat.connector.ajp.redirectPort>
        <tomcat.server.port>48005</tomcat.server.port>

        <cargo.timeout>240000</cargo.timeout>
        <cargo.deploy.timeout>60000</cargo.deploy.timeout>
        <skip.unit.tests>false</skip.unit.tests>
      </properties>

      <dependencies>

        <dependency>
          <groupId>org.camunda.bpm.tomcat</groupId>
          <artifactId>camunda-tomcat-assembly</artifactId>
          <version>${camunda.version}</version>
          <type>tar.gz</type>
          <scope>test</scope>
          <exclusions>
            <exclusion>
              <artifactId>slf4j-api</artifactId>
              <groupId>org.slf4j</groupId>
            </exclusion>
          </exclusions>
        </dependency>

        <dependency>
          <groupId>org.camunda.bpm.webapp</groupId>
          <artifactId>camunda-webapp-tomcat</artifactId>
          <version>${camunda.version}</version>
          <type>war</type>
          <scope>test</scope>
        </dependency>

        <dependency>
          <groupId>org.camunda.bpm</groupId>
          <artifactId>camunda-engine-rest</artifactId>
          <scope>test</scope>
          <type>war</type>
          <classifier>tomcat</classifier>
          <version>${camunda.version}</version>
        </dependency>

        <dependency>
          <groupId>org.camunda.bpm.qa</groupId>
          <artifactId>engine-variable-test</artifactId>
          <scope>test</scope>
          <type>war</type>
          <version>${project.version}</version>
        </dependency>

      </dependencies>

      <build>
        <plugins>

          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <phase>generate-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.camunda.bpm.tomcat</groupId>
                      <artifactId>camunda-tomcat-assembly</artifactId>
                      <version>${camunda.version}</version>
                      <type>tar.gz</type>
                      <outputDirectory>${engine.runtime}</outputDirectory>
                      <overWrite>true</overWrite>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>${version.plugin.failsafe}</version>
            <configuration>
              <redirectTestOutputToFile>true</redirectTestOutputToFile>
            </configuration>
            <executions>
              <execution>
                <goals>
                  <goal>integration-test</goal>
                  <goal>verify</goal>
                </goals>
              </execution>
            </executions>
          </plugin>

          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven2-plugin</artifactId>
            <version>${version.plugin.cargo}</version>
            <executions>
              <execution>
                <id>start-container</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>start</goal>
                </goals>
              </execution>
              <execution>
                <id>stop-container</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>stop</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
              <!-- Container configuration -->
              <container>
                <type>installed</type>
                <containerId>tomcat9x</containerId>
                <append>false</append>
                <home>${tomcat.runtime}</home>
                <timeout>${cargo.timeout}</timeout>
                <log>${tomcat.runtime}/logs/catalina.out</log>
              </container>
              <configuration>
                <type>standalone</type>
                <home>${project.build.directory}/cargo-config-tomcat</home>
                <properties>
                  <cargo.servlet.port>${tomcat.connector.http.port}</cargo.servlet.port>
                  <cargo.tomcat.ajp.port>${tomcat.connector.ajp.port}</cargo.tomcat.ajp.port>
                  <cargo.start.jvmargs>-Djava.security.egd=file:/dev/./urandom</cargo.start.jvmargs>
                </properties>
                <files>
                  <copy>
                    <configfile>true</configfile>
                    <file>${project.basedir}/src/it/resources/tomcat/bpm-platform.xml</file>
                    <tofile>conf/bpm-platform.xml</tofile>
                    <overwrite>true</overwrite>
                  </copy>
                </files>
              </configuration>
              <deployables>
                <deployable>
                  <groupId>org.camunda.bpm</groupId>
                  <artifactId>camunda-engine-rest</artifactId>
                  <type>war</type>
                  <classifier>tomcat</classifier>
                  <pingURL>
                    http://localhost:${tomcat.connector.http.port}/engine-rest/engine/default/process-definition
                  </pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                  <properties>
                    <context>engine-rest</context>
                  </properties>
                </deployable>
                <deployable>
                  <groupId>org.camunda.bpm.webapp</groupId>
                  <artifactId>camunda-webapp-tomcat</artifactId>
                  <type>war</type>
                  <pingURL>http://localhost:${tomcat.connector.http.port}/camunda</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                  <properties>
                    <context>camunda</context>
                  </properties>
                </deployable>
                <deployable>
                  <groupId>org.camunda.bpm.qa</groupId>
                  <artifactId>engine-variable-test</artifactId>
                  <type>war</type>
                </deployable>
              </deployables>
              <wait>false</wait>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
