<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You 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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.apache.nifi.registry</groupId>
        <artifactId>nifi-registry-core</artifactId>
        <version>2.0.0-M1</version>
    </parent>
    <artifactId>nifi-registry-web-api</artifactId>
    <packaging>war</packaging>

    <properties>
        <swagger.source.dir>${project.basedir}/src/main/resources/swagger</swagger.source.dir>
        <swagger.generated.dir>${project.build.directory}/swagger</swagger.generated.dir>
        <asciidoc.source.dir>${project.basedir}/src/main/asciidoc</asciidoc.source.dir>
        <asciidoc.generated.dir>${project.build.directory}/asciidoc</asciidoc.generated.dir>
        <docs.dir>${project.build.directory}/${project.artifactId}-${project.version}/docs/</docs.dir>
        <jakarta.xml.bind-api.version>4.0.1</jakarta.xml.bind-api.version>
    </properties>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${spring.boot.version}</version>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.kongchen</groupId>
                <artifactId>swagger-maven-plugin</artifactId>
                <version>3.1.8</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <apiSources>
                                <apiSource>
                                    <locations>
                                        <location>org.apache.nifi.registry.web.api</location>
                                    </locations>
                                    <schemes>
                                        <scheme>http</scheme>
                                        <scheme>https</scheme>
                                    </schemes>
                                    <outputFormats>json</outputFormats>
                                    <basePath>/nifi-registry-api</basePath>
                                    <info>
                                        <title>Apache NiFi Registry REST API</title>
                                        <version>${project.version}</version>
                                        <description>
                                            The REST API provides an interface to a registry with operations for saving, versioning, reading NiFi flows and components.
                                        </description>
                                        <contact>
                                            <name>Apache NiFi Registry</name>
                                            <email>dev@nifi.apache.org</email>
                                            <url>https://nifi.apache.org</url>
                                        </contact>
                                        <license>
                                            <url>https://www.apache.org/licenses/LICENSE-2.0.html</url>
                                            <name>Apache 2.0 License</name>
                                        </license>
                                        <termsOfService>As described in the license</termsOfService>
                                    </info>
                                    <securityDefinitions>
                                        <securityDefinition>
                                            <jsonPath>${swagger.source.dir}/security-definitions.json</jsonPath>
                                        </securityDefinition>
                                    </securityDefinitions>
                                    <swaggerDirectory>${swagger.generated.dir}</swaggerDirectory>
                                </apiSource>
                            </apiSources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${docs.dir}/rest-api/images</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/main/resources/images</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>io.swagger.codegen.v3</groupId>
                <artifactId>swagger-codegen-maven-plugin</artifactId>
                <version>3.0.46</version>
                <executions>
                    <execution>
                        <phase>compile</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <inputSpec>${swagger.generated.dir}/swagger.json</inputSpec>
                            <output>${docs.dir}/rest-api</output>
                            <language>html</language>
                            <templateDirectory>src/main/resources/templates</templateDirectory>
                        </configuration>
                    </execution>
	        </executions>
            <dependencies>
                <dependency>
                    <groupId>com.github.jknack</groupId>
                    <artifactId>handlebars</artifactId>
                    <version>4.3.1</version>
                </dependency>
            </dependencies>
            </plugin>
            <plugin>
                <groupId>org.apache.rat</groupId>
                <artifactId>apache-rat-plugin</artifactId>
                <configuration>
                    <excludes combine.children="append">
                        <exclude>src/test/resources/test-versioned-flow-snapshot.json</exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>include-swagger-ui</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>com.googlecode.maven-download-plugin</groupId>
                        <artifactId>download-maven-plugin</artifactId>
                        <version>1.7.1</version>
                        <executions>
                            <execution>
                                <id>download-swagger-ui</id>
                                <!-- This plugin downloads swagger UI static assets during the build, to be
                                     served by the web app to render the dynamically generated Swagger spec.
                                     For offline development, or to build without the swagger UI, deactivate
                                     the "include-swagger-ui" maven profile during the build with the following
                                     profile option: -P'!include-swagger-ui' -->
                                <goals>
                                    <goal>wget</goal>
                                </goals>
                                <configuration>
                                    <url>https://github.com/swagger-api/swagger-ui/archive/v${swagger.ui.version}.tar.gz</url>
                                    <unpack>true</unpack>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>bundle-swagger-ui</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <sequential>
                                            <echo>Copy static Swagger UI files to target</echo>
                                            <copy todir="${project.build.directory}/classes/static/swagger">
                                                <fileset dir="${project.build.directory}/swagger-ui-${swagger.ui.version}/dist">
                                                    <include name="**" />
                                                </fileset>
                                            </copy>
                                            <echo>Disable schema validation by removing validatorUrl</echo>
                                            <replace token="https://online.swagger.io/validator" value="" dir="${project.build.directory}/classes/static/swagger">
                                                <include name="swagger-ui-bundle.js" />
                                                <include name="swagger-ui-standalone-preset.js" />
                                            </replace>
                                            <echo>Rename 'index.html' to 'ui.html'</echo>
                                            <move file="${project.build.directory}/classes/static/swagger/index.html" tofile="${project.build.directory}/classes/static/swagger/ui.html" />
                                            <echo>Replace default swagger.json location</echo>
                                            <replace token="http://petstore.swagger.io/v2/swagger.json" value="/nifi-registry-api/swagger/swagger.json" dir="${project.build.directory}/classes/static/swagger">
                                                <include name="ui.html" />
                                            </replace>
                                            <echo>Copy swagger.json into static assets folder</echo>
                                            <copy todir="${project.build.directory}/classes/static/swagger">
                                                <fileset dir="${project.build.directory}/swagger">
                                                    <include name="*.json" />
                                                </fileset>
                                            </copy>
                                        </sequential>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <version>${spring.boot.version}</version>
            <exclusions>
                <!-- Spring Boot Starter Logging 2 does not support Logback 1.3 -->
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jersey</artifactId>
            <version>${spring.boot.version}</version>
            <exclusions>
                <!-- spring-boot-starter-jersey brings in a Spring 4.x version of spring-aop which causes problems -->
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aop</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Exclude micrometer-core because it creates a class cast issue with logback, revisit later -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
            <version>${spring.boot.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>io.micrometer</groupId>
                    <artifactId>micrometer-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework.security.kerberos</groupId>
            <artifactId>spring-security-kerberos-core</artifactId>
            <version>1.0.1.RELEASE</version>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework.security</groupId>
                    <artifactId>spring-security-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- Must be marked provided in order to produce a correct WAR -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <version>${spring.boot.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-framework</artifactId>
            <version>2.0.0-M1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-revision-spring-jdbc</artifactId>
            <version>2.0.0-M1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-revision-entity-service</artifactId>
            <version>2.0.0-M1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-property-utils</artifactId>
            <scope>provided</scope> <!-- will be in lib dir -->
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-properties</artifactId>
            <version>2.0.0-M1</version>
            <scope>provided</scope> <!-- This will be in the lib directory -->
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-security-api</artifactId>
            <version>2.0.0-M1</version>
            <scope>provided</scope> <!-- This will be in lib directory -->
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-provider-api</artifactId>
            <version>2.0.0-M1</version>
            <scope>provided</scope> <!-- This will be in lib directory -->
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-security-utils</artifactId>
            <version>2.0.0-M1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi</groupId>
            <artifactId>nifi-security-cert</artifactId>
            <version>2.0.0-M1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <!-- Required for compatibility with JAXB 2 generated objects for configuration parsing -->
        <dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
        </dependency>
        <dependency>
            <groupId>io.swagger</groupId>
            <artifactId>swagger-annotations</artifactId>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.media</groupId>
            <artifactId>jersey-media-multipart</artifactId>
        </dependency>
        <dependency>
            <groupId>io.jsonwebtoken</groupId>
            <artifactId>jjwt</artifactId>
            <version>0.9.1</version>
        </dependency>
        <!-- Test Dependencies -->
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-test</artifactId>
            <version>2.0.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.nifi.registry</groupId>
            <artifactId>nifi-registry-client</artifactId>
            <version>2.0.0-M1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jetty</artifactId>
            <version>${spring.boot.version}</version>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.jetty.websocket</groupId>
                    <artifactId>websocket-server</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.eclipse.jetty.websocket</groupId>
                    <artifactId>javax-websocket-server-impl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>com.unboundid</groupId>
            <artifactId>unboundid-ldapsdk</artifactId>
            <version>6.0.9</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse.jetty</groupId>
            <artifactId>jetty-util</artifactId>
            <version>${jetty.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>oauth2-oidc-sdk</artifactId>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-oauth2-resource-server</artifactId>
        </dependency>
    </dependencies>
</project>
