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

  <artifactId>fluxnova-qa-integration-tests-webapps-shared-engine</artifactId>
  <name>Fluxnova Platform - QA Integration Tests - Webapps Shared Engine</name>

  <parent>
    <groupId>org.finos.fluxnova.bpm.qa</groupId>
    <artifactId>fluxnova-qa-integration-tests-webapps-root</artifactId>
    <version>2.0.3</version>
    <relativePath>../</relativePath>
  </parent>

  <dependencies>
    <dependency>
      <groupId>org.finos.fluxnova.bpm.qa</groupId>
      <artifactId>fluxnova-qa-integration-tests-webapps</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>wildfly</id>
      <properties>
        <jboss.runtime>${basedir}/../${wildfly.runtime.location}</jboss.runtime>
        <http.port>${jboss.http.port}</http.port>
      </properties>
      <dependencies>
        <dependency>
          <!-- make sure it comes after assembly in the build -->
          <groupId>org.finos.fluxnova.bpm.qa</groupId>
          <artifactId>fluxnova-qa-wildfly-runtime</artifactId>
          <version>${project.version}</version>
          <type>pom</type>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm.webapp</groupId>
          <artifactId>fluxnova-webapp-wildfly</artifactId>
          <version>${project.version}</version>
          <type>war</type>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm</groupId>
          <artifactId>fluxnova-engine-rest-jakarta</artifactId>
          <version>${project.version}</version>
          <classifier>wildfly</classifier>
          <scope>test</scope>
          <type>war</type>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm.example</groupId>
          <artifactId>fluxnova-example-invoice-jakarta</artifactId>
          <version>${project.version}</version>
          <scope>test</scope>
          <type>war</type>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <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>${cargo.wildfly.container.id}</containerId>
                <append>false</append>
                <home>${jboss.runtime}</home>
                <timeout>${cargo.timeout}</timeout>
              </container>
              <configuration>
                <type>standalone</type>
                <home>${project.build.directory}/config-wildfly</home>
                <properties>
                  <cargo.servlet.port>${jboss.http.port}</cargo.servlet.port>
                  <cargo.jboss.ajp.port>${jboss.ajp.port}</cargo.jboss.ajp.port>
                  <cargo.jvmargs>-Djava.net.preferIPv4Stack=true</cargo.jvmargs>
                </properties>
              </configuration>
              <deployables>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm.example</groupId>
                  <artifactId>fluxnova-example-invoice-jakarta</artifactId>
                  <type>war</type>
                  <pingURL>http://localhost:${jboss.http.port}/engine-rest/engine/default/user/demo/profile</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                </deployable>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm</groupId>
                  <artifactId>fluxnova-engine-rest-jakarta</artifactId>
                  <classifier>wildfly</classifier>
                  <type>war</type>
                  <pingURL>http://localhost:${jboss.http.port}/engine-rest/engine/default/process-definition</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                </deployable>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm.webapp</groupId>
                  <artifactId>fluxnova-webapp-wildfly</artifactId>
                  <type>war</type>
                  <pingURL>http://localhost:${jboss.http.port}/fluxnova</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                </deployable>
              </deployables>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <excludes>
                <!-- CAM-14109 -->
                <exclude>**/SessionCookieSameSiteIT.java</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>wildfly26</id>
      <properties>
        <jboss.runtime>${basedir}/../${wildfly26.runtime.location}</jboss.runtime>
        <http.port>${jboss.http.port}</http.port>
      </properties>
      <dependencies>
        <dependency>
          <!-- make sure it comes after assembly in the build -->
          <groupId>org.finos.fluxnova.bpm.qa</groupId>
          <artifactId>fluxnova-qa-wildfly26-runtime</artifactId>
          <version>${project.version}</version>
          <type>pom</type>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm.webapp</groupId>
          <artifactId>fluxnova-webapp-jboss</artifactId>
          <version>${project.version}</version>
          <type>war</type>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm</groupId>
          <artifactId>fluxnova-engine-rest</artifactId>
          <version>${project.version}</version>
          <classifier>wildfly</classifier>
          <scope>test</scope>
          <type>war</type>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm</groupId>
          <artifactId>fluxnova-engine</artifactId>
          <scope>test</scope>
          <exclusions>
            <exclusion>
              <groupId>org.springframework</groupId>
              <artifactId>spring-beans</artifactId>
            </exclusion>
          </exclusions>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <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>${cargo.wildfly26.container.id}</containerId>
                <append>false</append>
                <home>${jboss.runtime}</home>
                <timeout>${cargo.timeout}</timeout>
              </container>
              <configuration>
                <type>standalone</type>
                <home>${project.build.directory}/config-wildfly</home>
                <properties>
                  <cargo.servlet.port>${jboss.http.port}</cargo.servlet.port>
                  <cargo.jboss.ajp.port>${jboss.ajp.port}</cargo.jboss.ajp.port>
                  <cargo.jvmargs>-Djava.net.preferIPv4Stack=true</cargo.jvmargs>
                </properties>
              </configuration>
              <deployables>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm.example</groupId>
                  <artifactId>fluxnova-example-invoice</artifactId>
                  <type>war</type>
                  <pingURL>http://localhost:${jboss.http.port}/engine-rest/engine/default/user/demo/profile</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                </deployable>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm</groupId>
                  <artifactId>fluxnova-engine-rest</artifactId>
                  <classifier>wildfly</classifier>
                  <type>war</type>
                  <pingURL>http://localhost:${jboss.http.port}/engine-rest/engine/default/process-definition</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                </deployable>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm.webapp</groupId>
                  <artifactId>fluxnova-webapp-jboss</artifactId>
                  <type>war</type>
                  <pingURL>http://localhost:${jboss.http.port}/fluxnova</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                </deployable>
              </deployables>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <excludes>
                <!-- CAM-14109 -->
                <exclude>**/SessionCookieSameSiteIT.java</exclude>
              </excludes>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>tomcat9</id>
      <properties>
        <tomcat.runtime>${basedir}/../${tomcat9.runtime.location}</tomcat.runtime>
        <http.port>${tomcat.connector.http.port}</http.port>
      </properties>
      <dependencies>
        <dependency>
          <!-- make sure it comes after assembly in the build -->
          <groupId>org.finos.fluxnova.bpm.qa</groupId>
          <artifactId>fluxnova-qa-tomcat9-runtime</artifactId>
          <version>${project.version}</version>
          <type>pom</type>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm.webapp</groupId>
          <artifactId>fluxnova-webapp-tomcat</artifactId>
          <version>${project.version}</version>
          <type>war</type>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm</groupId>
          <artifactId>fluxnova-engine-rest</artifactId>
          <scope>test</scope>
          <type>war</type>
          <classifier>tomcat</classifier>
          <version>${project.version}</version>
        </dependency>
      </dependencies>

      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <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>tomcat8x</containerId>
                <append>false</append>
                <home>${tomcat.runtime}</home>
                <timeout>${cargo.timeout}</timeout>
              </container>
              <configuration>
                <type>standalone</type>
                <home>${project.build.directory}/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>
                </properties>
              </configuration>
              <deployables>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm</groupId>
                  <artifactId>fluxnova-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.finos.fluxnova.bpm.webapp</groupId>
                  <artifactId>fluxnova-webapp-tomcat</artifactId>
                  <type>war</type>
                  <pingURL>http://localhost:${tomcat.connector.http.port}/fluxnova</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                  <properties>
                    <context>fluxnova</context>
                  </properties>
                </deployable>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm.example</groupId>
                  <artifactId>fluxnova-example-invoice</artifactId>
                  <type>war</type>
                  <properties>
                    <context>invoice</context>
                  </properties>
                </deployable>
              </deployables>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>tomcat</id>
      <properties>
        <tomcat.runtime>${basedir}/../${tomcat.runtime.location}</tomcat.runtime>
        <http.port>${tomcat.connector.http.port}</http.port>
      </properties>
      <dependencies>
        <dependency>
          <!-- make sure it comes after assembly in the build -->
          <groupId>org.finos.fluxnova.bpm.qa</groupId>
          <artifactId>fluxnova-qa-tomcat-runtime</artifactId>
          <version>${project.version}</version>
          <type>pom</type>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm.webapp</groupId>
          <artifactId>fluxnova-webapp-tomcat-jakarta</artifactId>
          <version>${project.version}</version>
          <type>war</type>
          <scope>test</scope>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm</groupId>
          <artifactId>fluxnova-engine-rest-jakarta</artifactId>
          <version>${project.version}</version>
          <type>war</type>
          <scope>test</scope>
          <classifier>tomcat</classifier>
        </dependency>
        <dependency>
          <groupId>org.finos.fluxnova.bpm.example</groupId>
          <artifactId>fluxnova-example-invoice-jakarta</artifactId>
          <version>${project.version}</version>
          <type>war</type>
          <scope>test</scope>
        </dependency>
      </dependencies>

      <build>
        <plugins>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <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>tomcat10x</containerId>
                <append>false</append>
                <home>${tomcat.runtime}</home>
                <timeout>${cargo.timeout}</timeout>
              </container>
              <configuration>
                <type>standalone</type>
                <home>${project.build.directory}/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>
                </properties>
              </configuration>
              <deployables>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm</groupId>
                  <artifactId>fluxnova-engine-rest-jakarta</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.finos.fluxnova.bpm.webapp</groupId>
                  <artifactId>fluxnova-webapp-tomcat-jakarta</artifactId>
                  <type>war</type>
                  <pingURL>http://localhost:${tomcat.connector.http.port}/fluxnova</pingURL>
                  <pingTimeout>${cargo.deploy.timeout}</pingTimeout>
                  <properties>
                    <context>fluxnova</context>
                  </properties>
                </deployable>
                <deployable>
                  <groupId>org.finos.fluxnova.bpm.example</groupId>
                  <artifactId>fluxnova-example-invoice-jakarta</artifactId>
                  <type>war</type>
                  <properties>
                    <context>invoice</context>
                  </properties>
                </deployable>
              </deployables>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>distro</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <skipTests>true</skipTests>
              <skipITs>true</skipITs>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>webapps-integration</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <version>3.0.0-M3</version>
            <configuration>
              <redirectTestOutputToFile>true</redirectTestOutputToFile>
              <dependenciesToScan>
                <dependency>org.finos.fluxnova.bpm.qa:fluxnova-qa-integration-tests-webapps</dependency>
              </dependenciesToScan>
              <systemPropertyVariables>
                <selenium.screenshot.directory>${project.build.directory}/selenium-screenshots</selenium.screenshot.directory>
              </systemPropertyVariables>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>

    <!-- allows dropping all databases -->
    <profile>
      <id>clean-db</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-sql-scripts</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.finos.fluxnova.bpm</groupId>
                      <artifactId>fluxnova-engine</artifactId>
                      <outputDirectory>${project.build.directory}/sql-scripts/engine</outputDirectory>
                      <overWrite>true</overWrite>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>sql-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>drop-db-if-present</id>
                <phase>generate-test-sources</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
                <configuration>
                  <srcFiles>
                    <!-- try dropping the DB if it exists. -->
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.decision.engine.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.case.engine.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.engine.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.identity.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.decision.history.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.case.history.sql</srcFile>
                    <srcFile>${project.build.directory}/sql-scripts/engine/org/finos/fluxnova/bpm/engine/db/drop/activiti.${database.type}.drop.history.sql</srcFile>
                  </srcFiles>
                  <autocommit>true</autocommit>
                  <onError>continue</onError>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>

    <profile>
      <id>embedded-engine-rest</id>
      <!-- Works only on Wildfly 26 -->
      <dependencies>
        <dependency>
          <groupId>org.wildfly.arquillian</groupId>
          <artifactId>wildfly-arquillian-container-managed</artifactId>
          <version>1.1.0.Beta1</version>
          <scope>test</scope>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <dependenciesToScan>
                <dependency>org.finos.fluxnova.bpm.qa:fluxnova-qa-integration-tests-webapps</dependency>
              </dependenciesToScan>
              <skipTests>false</skipTests>
              <includes>
                <include>**/EmbeddedEngineRest_WILDFLY.*</include>
              </includes>
              <redirectTestOutputToFile>${redirect.test.output}</redirectTestOutputToFile>
              <systemPropertyVariables>
                <projectversion>${project.parent.version}</projectversion>
              </systemPropertyVariables>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.codehaus.cargo</groupId>
            <artifactId>cargo-maven3-plugin</artifactId>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <configuration>
              <skip>true</skip>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
        <filtering>true</filtering>
      </testResource>
    </testResources>

    <pluginManagement>
      <plugins>
        <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build
          itself. -->
        <plugin>
          <groupId>org.eclipse.m2e</groupId>
          <artifactId>lifecycle-mapping</artifactId>
          <version>1.0.0</version>
          <configuration>
            <lifecycleMappingMetadata>
              <pluginExecutions>
                <pluginExecution>
                  <pluginExecutionFilter>
                    <groupId>
                      org.apache.maven.plugins
                    </groupId>
                    <artifactId>
                      maven-antrun-plugin
                    </artifactId>
                    <versionRange>
                      [1.7,)
                    </versionRange>
                    <goals>
                      <goal>run</goal>
                    </goals>
                  </pluginExecutionFilter>
                  <action>
                    <ignore />
                  </action>
                </pluginExecution>
              </pluginExecutions>
            </lifecycleMappingMetadata>
          </configuration>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

</project>
