<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>net.bis5.excella</groupId>
    <artifactId>primefaces-excella-exporter-parent</artifactId>
    <version>2.0.0</version>
  </parent>
  <artifactId>primefaces-excella-exporter-test</artifactId>

  <name>PrimeFaces ExCella Exporter :: Integration Test</name>
  <description>Integration test for primefaces-excella-exporter</description>
  <packaging>war</packaging>

  <properties>
    <primefaces-selenium.version>11.0.0</primefaces-selenium.version>
    <wildfly-jar-maven-plugin.version>5.0.1.Final</wildfly-jar-maven-plugin.version>
    <maven-failsafe-plugin.version>3.0.0-M5</maven-failsafe-plugin.version>
    <wildfly.version>24.0.1.Final</wildfly.version>

    <sonar.coverage.jacoco.xmlReportPaths>${project.basedir}/../target/site/jacoco-aggregate/jacoco.xml</sonar.coverage.jacoco.xmlReportPaths>
  </properties>

  <dependencies>
    <dependency>
      <groupId>net.bis5.excella</groupId>
      <artifactId>primefaces-excella-exporter</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.bbreak.excella</groupId>
      <artifactId>excella-reports</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>org.primefaces</groupId>
      <artifactId>primefaces</artifactId>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.platform</groupId>
      <artifactId>jakarta.jakartaee-web-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-engine</artifactId>
    </dependency>
    <dependency>
      <groupId>org.primefaces</groupId>
      <artifactId>primefaces-selenium-core</artifactId>
      <version>${primefaces-selenium.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.primefaces</groupId>
      <artifactId>primefaces-selenium-components</artifactId>
      <version>${primefaces-selenium.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.wildfly.plugins</groupId>
        <artifactId>wildfly-jar-maven-plugin</artifactId>
        <version>${wildfly-jar-maven-plugin.version}</version>
        <executions>
          <execution>
            <id>start-wildfly</id>
            <phase>integration-test</phase>
            <goals>
              <goal>package</goal>
              <goal>start</goal>
            </goals>
          </execution>
          <execution>
            <id>stop-wildfly</id>
            <phase>post-integration-test</phase>
            <goals>
              <goal>shutdown</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <jvmArguments>
            <arg>-Djboss.bind.address=0.0.0.0</arg>
            <arg>${failsafeArgLine}</arg>
          </jvmArguments>
          <feature-packs>
            <feature-pack>
              <location>wildfly@maven(org.jboss.universe:community-universe)#${wildfly.version}</location>
            </feature-pack>
          </feature-packs>
          <layers>
            <layer>jsf</layer>
            <layer>management</layer>
          </layers>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>groovy-maven-plugin</artifactId>
        <version>2.1.1</version>
        <executions>
          <execution>
            <id>wait-for-shutdown-wildfly</id>
            <phase>verify</phase>
            <goals>
              <goal>execute</goal>
            </goals>
            <configuration>
              <source>Thread.sleep(5000)</source>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>${maven-surefire-plugin.version}</version>
        <configuration>
          <excludes>
            <exclude>net/bis5/excella/primefaces/exporter/**/*.java</exclude>
          </excludes>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>${maven-failsafe-plugin.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <includes>
            <include>net/bis5/excella/primefaces/exporter/**/*.java</include>
          </includes>
          <systemPropertyVariables>
            <webdriver.headless>true</webdriver.headless>
            <baseUrl>http://docker-host:8080/</baseUrl>
          </systemPropertyVariables>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.jacoco</groupId>
        <artifactId>jacoco-maven-plugin</artifactId>
        <version>${jacoco-maven-plugin.version}</version>
        <configuration>
          <append>true</append>
        </configuration>
        <executions>
          <execution>
            <id>prepare-agent</id>
            <goals>
              <goal>prepare-agent-integration</goal>
            </goals>
            <configuration>
              <destFile>${project.basedir}/../target/jacoco-it.exec</destFile>
              <propertyName>failsafeArgLine</propertyName>
            </configuration>
          </execution>
          <execution>
            <id>report</id>
            <phase>verify</phase>
            <goals>
              <goal>report-aggregate</goal>
            </goals>
            <configuration>
              <dataFileIncludes>
                <include>${project.basedir}/../target/jacoco-it.exec</include>
              </dataFileIncludes>
              <outputDirectory>${project.basedir}/../target/site/jacoco-aggregate</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>debug</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.wildfly.plugins</groupId>
            <artifactId>wildfly-jar-maven-plugin</artifactId>
            <version>${wildfly-jar-maven-plugin.version}</version>
            <configuration>
              <jvmArguments>
                <arg>-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n</arg>
              </jvmArguments>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
