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

<!--
 ~  Copyright 2018 Red Hat, Inc.
 ~
 ~  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>io.smallrye</groupId>
    <artifactId>smallrye-metrics-testsuite-parent</artifactId>
    <version>1.1.3</version>
  </parent>

  <artifactId>smallrye-metrics-rest-tck</artifactId>

  <name>SmallRye: MicroProfile Metrics TCK</name>

  <dependencies>
    <dependency>
      <groupId>org.eclipse.microprofile.metrics</groupId>
      <artifactId>microprofile-metrics-rest-tck</artifactId>
      <version>${version.microprofile-metrics}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.microprofile.metrics</groupId>
      <artifactId>microprofile-metrics-api</artifactId>
    </dependency>
    <dependency>
      <groupId>io.smallrye</groupId>
      <artifactId>smallrye-metrics-testsuite-common</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.weld.servlet</groupId>
      <artifactId>weld-servlet</artifactId>
    </dependency>

    <dependency>
      <groupId>org.jboss.spec.javax.servlet</groupId>
      <artifactId>jboss-servlet-api_3.1_spec</artifactId>
    </dependency>

  </dependencies>

  <properties>
    <!-- this is for running the tests on JDK9+ where we add JAXB to the test's class path manually -->
    <jaxb.version>2.3.1</jaxb.version>
  </properties>


  <profiles>
    <profile>
      <id>wildfly-servlet</id>
      <activation>
        <property>
          <!-- use this rather than activeByDefault due to https://issues.apache.org/jira/browse/MNG-4917 -->
          <name>!noWildflyServlet</name>
        </property>
      </activation>
      <dependencies>
        <dependency>
          <groupId>org.wildfly.arquillian</groupId>
          <artifactId>wildfly-arquillian-container-managed</artifactId>
        </dependency>
      </dependencies>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <systemProperties>
                <jboss.options>${jboss.extra.opts}</jboss.options>
              </systemProperties>
              <environmentVariables>
                <JBOSS_HOME>${project.build.directory}/wildfly-servlet-${version.wildfly}</JBOSS_HOME>
              </environmentVariables>
            </configuration>
          </plugin>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack</id>
                <phase>process-test-classes</phase>
                <goals>
                  <goal>unpack</goal>
                </goals>
                <configuration>
                  <artifactItems>
                    <artifactItem>
                      <groupId>org.wildfly</groupId>
                      <artifactId>wildfly-servlet-dist</artifactId>
                      <version>${version.wildfly}</version>
                      <type>zip</type>
                      <overWrite>false</overWrite>
                      <outputDirectory>${project.build.directory}</outputDirectory>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>jdk9plus</id>
      <activation>
        <jdk>[9,)</jdk>
      </activation>
      <properties>
        <jboss.extra.opts>--add-modules java.se</jboss.extra.opts>
      </properties>
      <dependencies>
        <dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-impl</artifactId>
          <version>${jaxb.version}</version>
        </dependency>
        <dependency>
          <groupId>javax.xml.bind</groupId>
          <artifactId>jaxb-api</artifactId>
          <version>${jaxb.version}</version>
        </dependency>
      </dependencies>
    </profile>
  </profiles>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <dependenciesToScan>
            <dependency>org.eclipse.microprofile.metrics:microprofile-metrics-rest-tck</dependency>
          </dependenciesToScan>
          <environmentVariables>
            <MP_METRICS_TAGS>tier=integration</MP_METRICS_TAGS>
          </environmentVariables>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
