<?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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>io.phasetwo.keycloak</groupId>
  <artifactId>keycloak-magic-link</artifactId>
  <packaging>jar</packaging>
  <version>0.76</version>

  <name>Phase Two Keycloak Magic link</name>
  <description>Magic link implementation.</description>
  <url>https://github.com/p2-inc/keycloak-magic-link</url>

  <parent>
    <groupId>io.phasetwo</groupId>
    <artifactId>oss-parent</artifactId>
    <version>0.13</version>
  </parent>

  <developers>
    <developer>
      <name>Phase Two, Inc.</name>
      <url>https://github.com/p2-inc</url>
    </developer>
  </developers>

  <licenses>
    <license>
      <name>Elastic License v2</name>
      <url>https://raw.githubusercontent.com/elastic/elasticsearch/main/licenses/ELASTIC-LICENSE-2.0.txt</url>
    </license>
  </licenses>

  <properties>
    <java.version>21</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <main.java.package>io.phasetwo.keycloak.magic</main.java.package>
    <junit.version>4.13.2</junit.version>
    <keycloak.version>26.6.3</keycloak.version>
    <lombok.version>1.18.46</lombok.version>
    <auto-service.version>1.1.1</auto-service.version>
    <ossrh.url>https://ossrh-staging-api.central.sonatype.com</ossrh.url>
    <jacoco.version>0.8.14</jacoco.version>
    <testcontainers.version>1.21.4</testcontainers.version>
    <junit-jupiter.version>5.12.1</junit-jupiter.version>
  </properties>

  <scm>
    <url>https://github.com/p2-inc/keycloak-magic-link</url>
    <connection>scm:git:git@github.com:p2-inc/keycloak-magic-link.git</connection>
    <tag>v0.76</tag>
  </scm>

  <build>
    <sourceDirectory>src/main/java</sourceDirectory>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-javadoc-plugin</artifactId>
        <version>3.12.0</version>
        <configuration>
          <source>${java.version}</source>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>${java.version}</source>
          <target>${java.version}</target>
          <compilerArgument>-Xlint:unchecked</compilerArgument>
          <compilerArgument>-Xlint:deprecation</compilerArgument>
          <useIncrementalCompilation>false</useIncrementalCompilation>
          <annotationProcessorPaths>
            <path>
              <groupId>com.google.auto.service</groupId>
              <artifactId>auto-service</artifactId>
              <version>${auto-service.version}</version>
            </path>
            <path>
              <groupId>org.projectlombok</groupId>
              <artifactId>lombok</artifactId>
              <version>${lombok.version}</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      </plugin>
      <plugin>
        <groupId>com.fizzed</groupId>
        <artifactId>fizzed-versionizer-maven-plugin</artifactId>
        <version>1.0.6</version>
        <executions>
          <execution>
            <id>generate-version-class</id>
            <goals>
              <goal>generate</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <javaPackage>${main.java.package}</javaPackage>
          <versionCommit>${buildNumber}</versionCommit>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>3.2.2</version>
        <configuration>
          <classpathDependencyExcludes>
            <classpathDependencyExclude>org.jboss.slf4j:slf4j-jboss-logmanager</classpathDependencyExclude>
          </classpathDependencyExcludes>
          <systemPropertyVariables>
            <keycloak-version>${keycloak.version}</keycloak-version>
            <include.cypress>${include.cypress}</include.cypress>
          </systemPropertyVariables>
        </configuration>
      </plugin>
    </plugins>
    <testResources>
      <testResource>
        <directory>src/test/resources</directory>
      </testResource>
      <testResource>
        <directory>src/test/e2e</directory>
        <targetPath>e2e</targetPath>
      </testResource>
    </testResources>
  </build>

  <dependencies>
    <!-- annotation processing helpers for logging and services -->
    <dependency>
      <groupId>org.projectlombok</groupId>
      <artifactId>lombok</artifactId>
      <version>${lombok.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.google.auto.service</groupId>
      <artifactId>auto-service</artifactId>
      <version>${auto-service.version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- keycloak deps -->
    <dependency>
      <groupId>org.keycloak</groupId>
      <artifactId>keycloak-server-spi</artifactId>
      <version>${keycloak.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.keycloak</groupId>
      <artifactId>keycloak-server-spi-private</artifactId>
      <version>${keycloak.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.keycloak</groupId>
      <artifactId>keycloak-services</artifactId>
      <version>${keycloak.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.ws.rs</groupId>
      <artifactId>jakarta.ws.rs-api</artifactId>
      <version>3.1.0</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.validation</groupId>
      <artifactId>jakarta.validation-api</artifactId>
      <version>3.0.2</version>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>io.github.wimdeblauwe</groupId>
      <artifactId>testcontainers-cypress</artifactId>
      <version>1.10.0</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jacoco</groupId>
      <artifactId>org.jacoco.agent</artifactId>
      <version>${jacoco.version}</version>
      <classifier>runtime</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${junit-jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter-params</artifactId>
      <version>${junit-jupiter.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.testcontainers</groupId>
      <artifactId>junit-jupiter</artifactId>
      <version>${testcontainers.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.github.dasniko</groupId>
      <artifactId>testcontainers-keycloak</artifactId>
      <version>4.2.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jboss.shrinkwrap.resolver</groupId>
      <artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
      <version>3.3.3</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.rest-assured</groupId>
      <artifactId>rest-assured</artifactId>
      <version>5.5.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>cypress-tests</id>
      <properties>
        <include.cypress>true</include.cypress>
      </properties>
      <build>
        <plugins>
          <!--   copy the jacoco agent to target build  -->
          <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-jacoco</id>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <phase>compile</phase>
                <configuration>
                  <includeArtifactIds>org.jacoco.agent</includeArtifactIds>
                  <includeClassifiers>runtime</includeClassifiers>
                  <outputDirectory>${project.build.directory}/jacoco-agent</outputDirectory>
                  <stripVersion>true</stripVersion>
                </configuration>
              </execution>
            </executions>
          </plugin>

          <!--   set up jacoco plugin to generate report  -->
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <version>${jacoco.version}</version>
            <executions>
              <execution>
                <id>merge</id>
                <phase>test</phase>
                <goals>
                  <goal>merge</goal>
                </goals>
                <configuration>
                  <fileSets>
                    <fileSet>
                      <directory>${project.build.directory}/jacoco-report/</directory>
                      <includes>
                        <include>*.exec</include>
                      </includes>
                    </fileSet>
                  </fileSets>
                  <destFile>${project.build.directory}/jacoco-report/jacoco-all.exec</destFile>
                </configuration>
              </execution>
              <execution>
                <id>report</id>
                <phase>test</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <dataFile>${project.build.directory}/jacoco-report/jacoco-all.exec</dataFile>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
