<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright 2015-2017 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/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <groupId>org.hawkular.apm</groupId>
    <artifactId>hawkular-apm</artifactId>
    <version>0.14.2.Final</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>

  <artifactId>hawkular-apm-server-rest</artifactId>
  <packaging>jar</packaging>
  <name>Hawkular APM::Server::REST</name>

  <dependencies>

    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hawkular.apm</groupId>
      <artifactId>hawkular-apm-server-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hawkular.commons</groupId>
      <artifactId>hawkular-tenant-jaxrs-filter</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.logging</groupId>
      <artifactId>jboss-logging</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.logging</groupId>
      <artifactId>jboss-logging-annotations</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>

    <!-- Wildfly provided -->
    <dependency>
      <groupId>org.jboss.resteasy</groupId>
      <artifactId>resteasy-jaxrs</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>javax.inject</groupId>
      <artifactId>javax.inject</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>javax.enterprise</groupId>
      <artifactId>cdi-api</artifactId>
      <scope>provided</scope>
    </dependency>

    <dependency>
      <groupId>org.jboss.logging</groupId>
      <artifactId>jboss-logging-processor</artifactId>
      <scope>provided</scope>
    </dependency>

    <!-- docs -->
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-annotations</artifactId>
    </dependency>
    <dependency>
      <groupId>io.swagger</groupId>
      <artifactId>swagger-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hawkular.commons</groupId>
      <artifactId>hawkular-cors-jaxrs-filter</artifactId>
      <version>${version.org.hawkular.commons}</version>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>docgen</id>
      <properties>
        <restDocDirectory>${project.basedir}/src/main/rest-doc</restDocDirectory>
        <swaggerDirectory>${project.build.directory}/generated/swagger-ui</swaggerDirectory>
      </properties>
      <build>
        <!-- Document generation from the Swagger annotations on the REST-API. -->
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-apidoc-groovy</id>
                <phase>process-resources</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.hawkular</groupId>
                      <artifactId>hawkular-build-tools</artifactId>
                      <version>${version.org.hawkular.hawkular-build-tools}</version>
                      <type>jar</type>
                      <includes>**/*.groovy</includes>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>com.github.kongchen</groupId>
            <artifactId>swagger-maven-plugin</artifactId>
            <configuration>
              <apiSources>
                <apiSource>
                  <springmvc>false</springmvc>
                  <locations>org.hawkular.apm.server.rest</locations>
                  <basePath>/hawkular/apm/</basePath>
                  <info>
                    <title>Hawkular APM REST API</title>
                    <version>1.0</version>
                  </info>
                  <!--
                  <swaggerInternalFilter>org.hawkular.metrics.api.jaxrs.swagger.SwaggerFilter</swaggerInternalFilter>
                  -->
                  <swaggerDirectory>${swaggerDirectory}</swaggerDirectory>
                </apiSource>
              </apiSources>
            </configuration>
            <executions>
              <execution>
                <phase>compile</phase>
                <goals>
                  <goal>generate</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.codehaus.gmavenplus</groupId>
            <artifactId>gmavenplus-plugin</artifactId>
            <dependencies>
              <dependency>
                <groupId>org.codehaus.groovy</groupId>
                <artifactId>groovy-all</artifactId>
                <version>${version.org.codehaus.groovy}</version>
              </dependency>
            </dependencies>
            <configuration>
              <properties>
                <baseFile>${restDocDirectory}/base.adoc</baseFile>
                <swaggerFile>${swaggerDirectory}/swagger.json</swaggerFile>
                <outputFile>${project.build.directory}/generated/rest-apm.adoc</outputFile>
              </properties>
              <scripts>
                <script>file:///${project.build.directory}/dependency/hawkular-documentation/apidoc.groovy</script>
              </scripts>
            </configuration>
            <executions>
              <execution>
                <id>generate-api-doc</id>
                <phase>compile</phase>
                <goals>
                  <goal>execute</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
