<?xml version="1.0"?>
<!--
  ~ Copyright 2016 Red Hat, Inc. and/or its affiliates
  ~ and other contributors as indicated by the @author tags.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~ http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

<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">
    <parent>
        <artifactId>keycloak-parent</artifactId>
        <groupId>org.keycloak</groupId>
        <version>26.3.4</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>keycloak-services</artifactId>
    <name>Keycloak REST Services</name>
    <description>Keycloak REST Services</description>

    <properties>
        <version.swagger.doclet>1.1.2</version.swagger.doclet>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-core</artifactId>
            <scope>test</scope>
            <type>test-jar</type>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>${keycloak.crypto.artifactId}</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.mail</groupId>
            <artifactId>jakarta.mail-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.angus</groupId>
            <artifactId>angus-mail</artifactId>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-server-spi</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-server-spi-private</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.twitter4j</groupId>
            <artifactId>twitter4j-core</artifactId>
        </dependency>

        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>commons-logging-jboss-logging</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jboss.logging</groupId>
            <artifactId>jboss-logging-processor</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <!-- for MockHttpRequest -->
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus.resteasy.reactive</groupId>
            <artifactId>resteasy-reactive</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus.resteasy.reactive</groupId>
            <artifactId>resteasy-reactive-common</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>io.quarkus</groupId>
            <artifactId>quarkus-micrometer</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.transaction</groupId>
            <artifactId>jakarta.transaction-api</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.soap</groupId>
            <artifactId>jakarta.xml.soap-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jboss.resteasy</groupId>
            <artifactId>resteasy-core-spi</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
            <artifactId>owasp-java-html-sanitizer</artifactId>
        </dependency>
        <dependency>
            <groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
            <artifactId>java8-shim</artifactId>
        </dependency>
        <dependency>
            <groupId>com.googlecode.owasp-java-html-sanitizer</groupId>
            <artifactId>java10-shim</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>javax.annotation</groupId>
            <artifactId>javax.annotation-api</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.datatype</groupId>
            <artifactId>jackson-datatype-jdk8</artifactId>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.woodstox</groupId>
            <artifactId>woodstox-core</artifactId>
            <version>${woodstox.version}</version>    <!-- this version has to match that of used in Wildfly -->
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.zxing</groupId>
            <artifactId>javase</artifactId>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-saml-core-public</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-saml-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.apicatalog</groupId>
            <artifactId>titanium-json-ld</artifactId>
        </dependency>
        <dependency>
            <groupId>io.setl</groupId>
            <artifactId>rdf-urdna</artifactId>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.icegreen</groupId>
            <artifactId>greenmail</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.webauthn4j</groupId>
            <artifactId>webauthn4j-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.github.ua-parser</groupId>
            <artifactId>uap-java</artifactId>
        </dependency>
        <dependency>
            <groupId>org.eclipse.microprofile.openapi</groupId>
            <artifactId>microprofile-openapi-api</artifactId>
        </dependency>
        <dependency>
            <groupId>io.smallrye.common</groupId>
            <artifactId>smallrye-common-annotation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.keycloak</groupId>
            <artifactId>keycloak-model-storage-private</artifactId>
        </dependency>
        <dependency>
        	<groupId>org.keycloak</groupId>
        	<artifactId>keycloak-config-api</artifactId>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArgument>
                        -AgeneratedTranslationFilesPath=${project.build.directory}/generated-translation-files
                    </compilerArgument>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.jboss.logging</groupId>
                            <artifactId>jboss-logging-processor</artifactId>
                            <version>${jboss-logging-annotations.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <systemPropertyVariables>
                        <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    </systemPropertyVariables>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>jboss-release</id>

            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-resources</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>target/docs</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>src/docs</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-raw-openapi-definition</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.basedir}/target/apidocs-rest/output</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/apidocs-rest/swagger/apidocs</directory>
                                            <includes>
                                                <include>**/openapi.yaml</include>
                                                <include>**/openapi.json</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                    <overwrite>true</overwrite>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>io.smallrye</groupId>
                        <artifactId>smallrye-open-api-maven-plugin</artifactId>
                        <configuration>
                            <scanProfiles>admin</scanProfiles>
                            <outputDirectory>${project.build.directory}/apidocs-rest/swagger/apidocs</outputDirectory>
                            <infoTitle>Keycloak Admin REST API</infoTitle>
                            <infoDescription>This is a REST API reference for the Keycloak Admin REST API.</infoDescription>
                        </configuration>
                        <executions>
                            <execution>
                                <goals>
                                    <goal>generate-schema</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.openapitools</groupId>
                        <artifactId>openapi-generator-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-ascii-docs</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>generate</goal>
                                </goals>
                                <configuration>
                                    <globalProperties>
                                        <apiDocs>true</apiDocs>
                                        <apiModels>true</apiModels>
                                        <apiTests>false</apiTests>
                                        <modelTests>false</modelTests>
                                        <verbose>false</verbose>
                                    </globalProperties>
                                    <inputSpec>${project.build.directory}/apidocs-rest/swagger/apidocs/openapi.yaml</inputSpec>
                                    <output>${project.basedir}/target/docs/asciidoc/</output>
                                    <generatorName>asciidoc</generatorName>
                                    <generateApiDocumentation>true</generateApiDocumentation>
                                    <generateModelDocumentation>true</generateModelDocumentation>
                                    <generateSupportingFiles>true</generateSupportingFiles>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>${project.artifactId}</artifactId>
                                    <templateDirectory>src/docs/openapi-generator-templates/keycloak-admin-api</templateDirectory>
                                    <configOptions>
                                        <useIntroduction>true</useIntroduction>
                                        <delegatePattern>false</delegatePattern>
                                        <useMethodAndPath>true</useMethodAndPath>
                                        <prependFormOrBodyParameters>false</prependFormOrBodyParameters>
                                        <skipExamples>true</skipExamples>
                                    </configOptions>
                                    <skipValidateSpec>true</skipValidateSpec>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctor-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-docs</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>process-asciidoc</goal>
                                </goals>
                                <configuration>
                                    <sourceDirectory>${project.basedir}/target/docs/asciidoc</sourceDirectory>
                                    <sourceDocumentName>index.adoc</sourceDocumentName>
                                    <outputDirectory>${project.basedir}/target/apidocs-rest/output</outputDirectory>
                                    <backend>html5</backend>
                                    <attributes>
                                        <!-- List of attributes:
                                        https://github.com/asciidoctor/asciidoctorj/blob/master/asciidoctorj-core/src/main/java/org/asciidoctor/Attributes.java
                                         -->
                                        <toc/>
                                        <toc-position>left</toc-position>
                                        <generated>${project.basedir}/target/apidocs-rest/asciidoc</generated>
                                        <!-- Boolean attributes are passed as defined/undefined to AsciiDoc, not at their literal value -->
                                        <project_community>true</project_community>
                                        <project_product>false</project_product>
                                    </attributes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>


        <profile>
            <id>product</id>
            <activation>
                <property>
                    <name>product</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.asciidoctor</groupId>
                        <artifactId>asciidoctor-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>generate-docs</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>process-asciidoc</goal>
                                </goals>
                                <configuration combine.children="append">
                                    <attributes combine.children="append">
                                        <project_community>false</project_community>
                                        <project_product>true</project_product>
                                    </attributes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

    </profiles>
</project>
