<?xml version="1.0" encoding="UTF-8"?>
<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>com.vaadin</groupId>
    <artifactId>observability-kit-tests</artifactId>
    <version>5.0-SNAPSHOT</version>
  </parent>
  <artifactId>observability-kit-tests-micrometer</artifactId>

  <packaging>war</packaging>
  <name>Test Vaadin Micrometer integration on a real Jetty deployment</name>

  <dependencies>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>observability-kit-micrometer</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>observability-kit-tests-common</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>vaadin-testbench-core-junit5</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>flow-server</artifactId>
      <version>${flow.version}</version>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>flow-client</artifactId>
      <version>${flow.version}</version>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>flow-html-components</artifactId>
      <version>${flow.version}</version>
    </dependency>
    <dependency>
      <groupId>jakarta.servlet</groupId>
      <artifactId>jakarta.servlet-api</artifactId>
      <version>${servlet.api.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.vaadin</groupId>
      <artifactId>flow-html-components-testbench</artifactId>
      <version>${flow.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.seleniumhq.selenium</groupId>
      <artifactId>selenium-java</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <defaultGoal>jetty:run</defaultGoal>
    <plugins>
      <!--  Run flow plugin to build frontend -->
      <plugin>
        <groupId>com.vaadin</groupId>
        <artifactId>flow-maven-plugin</artifactId>
        <version>${flow.version}</version>
        <executions>
          <execution>
            <goals>
              <goal>prepare-frontend</goal>
              <goal>build-frontend</goal>
            </goals>
            <phase>compile</phase>
          </execution>
        </executions>
      </plugin>
      <!-- Run jetty before integration tests, and stop after -->
      <plugin>
        <groupId>org.eclipse.jetty.ee10</groupId>
        <artifactId>jetty-ee10-maven-plugin</artifactId>
        <version>12.1.8</version>

        <configuration>
          <!-- Control port/key the stop goal uses to talk to the running
               server; without these the stop-jetty execution fails with
               "Please specify a valid port". -->
          <stopPort>8089</stopPort>
          <stopKey>observability-kit-micrometer</stopKey>
          <stopWait>5</stopWait>
        </configuration>

        <executions>
          <!-- start and stop jetty (running our app) when running
                        integration tests -->
          <execution>
            <id>start-jetty</id>
            <goals>
              <goal>start</goal>
            </goals>
            <phase>pre-integration-test</phase>
          </execution>
          <execution>
            <id>stop-jetty</id>
            <goals>
              <goal>stop</goal>
            </goals>
            <phase>post-integration-test</phase>
          </execution>
        </executions>
      </plugin>
      <!-- Run the *IT browser tests against the running Jetty. The tests are
           JUnit 5 TestBench tests (@BrowserTest), so failsafe uses the JUnit
           Platform provider (active via junit-jupiter on the test classpath).
           Unlike flow-tests we do not force the surefire-junit47 provider,
           which only runs JUnit 4 tests and would skip these. -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-failsafe-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
