<!--

    Copyright (C) 2011-2022 Red Hat, Inc. (https://github.com/Commonjava/service-parent)

    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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <parent>
    <groupId>org.commonjava</groupId>
    <artifactId>commonjava</artifactId>
    <version>17</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>service-parent</artifactId>
  <version>2</version>
  <packaging>pom</packaging>
  <name>Commonjava Services Parent POM</name>
  <url>https://github.com/Commonjava/service-parent</url>
  <description>Commonjava Services Parent POM</description>
  <inceptionYear>2011-2022</inceptionYear>

  <scm>
    <connection>scm:git:https://github.com/commonjava/service-parent</connection>
    <developerConnection>scm:git:https://github.com/commonjava/service-parent</developerConnection>
    <url>http://github.com/Commonjava/service-parent</url>
    <tag>service-parent-2</tag>
  </scm>

  <properties>
    <javaVersion>11</javaVersion>
    <projectEmail>https://github.com/Commonjava/service-parent</projectEmail>

    <quarkus.version>2.11.2.Final</quarkus.version>
    <quarkus.plugin.version>2.11.2.Final</quarkus.plugin.version>
    <opentelemery.version>1.17.0</opentelemery.version>
    <netty.version>4.1.76.Final</netty.version>

    <junit.version>5.8.2</junit.version>

    <enforcedMavenVersion>[3.6.0,)</enforcedMavenVersion>
  </properties>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-bom</artifactId>
        <version>${quarkus.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <dependency>
        <groupId>io.opentelemetry</groupId>
        <artifactId>opentelemetry-bom</artifactId>
        <version>${opentelemery.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
      <!-- Include this in dependency to fix netty_transport_native_epoll missing warning -->
      <dependency>
        <groupId>io.netty</groupId>
        <artifactId>netty-transport-native-epoll</artifactId>
        <version>${netty.version}</version>
        <classifier>linux-x86_64</classifier>
      </dependency>
      <dependency>
        <groupId>org.junit</groupId>
        <artifactId>junit-bom</artifactId>
        <version>${junit.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>io.quarkus</groupId>
          <artifactId>quarkus-maven-plugin</artifactId>
          <version>${quarkus.plugin.version}</version>
          <executions>
            <execution>
              <goals>
                <goal>build</goal>
                <goal>generate-code</goal>
                <goal>generate-code-tests</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-maven-plugin</artifactId>
      </plugin>
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <skipTests>${skipTests}</skipTests>
          <excludedGroups>function</excludedGroups>
          <argLine>-Djdk.attach.allowAttachSelf=true</argLine>
          <systemPropertyVariables>
            <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
            <maven.home>${maven.home}</maven.home>
          </systemPropertyVariables>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>run-its</id>
      <build>
        <plugins>
          <plugin>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
              <excludedGroups>function</excludedGroups>
              <skipTests>${skipTests}</skipTests>
              <argLine>${surefireUtArgLine} -Djdk.attach.allowAttachSelf=true</argLine>
              <systemPropertyVariables>
                <jacoco-agent.destfile>${project.build.directory}/jacoco-ut.exec</jacoco-agent.destfile>
                <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                <maven.home>${maven.home}</maven.home>
              </systemPropertyVariables>
            </configuration>
            <executions>
              <execution>
                <id>functional-tests</id>
                <phase>integration-test</phase>
                <goals>
                  <goal>test</goal>
                </goals>
                <configuration>
                  <excludedGroups>!function</excludedGroups>
                  <skipTests>${skipTests}</skipTests>
                  <groups>function</groups>
                  <argLine>${surefireFtArgLine} -Djdk.attach.allowAttachSelf=true</argLine>
                  <systemPropertyVariables>
                    <jacoco-agent.destfile>${project.build.directory}/jacoco-ft.exec</jacoco-agent.destfile>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    <maven.home>${maven.home}</maven.home>
                  </systemPropertyVariables>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.jacoco</groupId>
            <artifactId>jacoco-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>prepare-agent-ut</id>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
                <configuration>
                  <!-- Sets the VM argument line used when unit tests are run in surefire <argLine>. -->
                  <append>true</append>
                  <destFile>${project.build.directory}/jacoco-ut.exec</destFile>
                  <propertyName>surefireUtArgLine</propertyName>
                </configuration>
              </execution>
              <execution>
                <id>report-ut</id>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <dataFile>${project.build.directory}/jacoco-ut.exec</dataFile>
                  <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory>
                </configuration>
              </execution>
              <execution>
                <id>prepare-agent-ft</id>
                <phase>pre-integration-test</phase>
                <goals>
                  <goal>prepare-agent</goal>
                </goals>
                <configuration>
                  <!-- Sets the VM argument line used when unit tests are run in surefire <argLine>. -->
                  <append>true</append>
                  <destFile>${project.build.directory}/jacoco-ft.exec</destFile>
                  <propertyName>surefireFtArgLine</propertyName>
                </configuration>
              </execution>
              <execution>
                <id>report-ft</id>
                <phase>post-integration-test</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <dataFile>${project.build.directory}/jacoco-ft.exec</dataFile>
                  <outputDirectory>${project.reporting.outputDirectory}/jacoco-ft</outputDirectory>
                </configuration>
              </execution>
              <execution>
                <id>merge-results</id>
                <phase>verify</phase>
                <goals>
                  <goal>merge</goal>
                </goals>
                <configuration>
                  <fileSets>
                    <fileSet>
                      <directory>${project.build.directory}</directory>
                      <includes>
                        <include>*.exec</include>
                      </includes>
                    </fileSet>
                  </fileSets>
                  <destFile>${project.build.directory}/jacoco.exec</destFile>
                </configuration>
              </execution>
              <execution>
                <id>post-merge-report</id>
                <phase>verify</phase>
                <goals>
                  <goal>report</goal>
                </goals>
                <configuration>
                  <dataFile>${project.build.directory}/jacoco.exec</dataFile>
                  <outputDirectory>${project.reporting.outputDirectory}/jacoco</outputDirectory>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
