<?xml version="1.0"?>
<!--
  ~ Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
  ~
  ~ This program and the accompanying materials are made available under the
  ~ terms of the Eclipse Public License 2.0 which is available at
  ~
  ~ http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
  ~ which is available at https://www.apache.org/licenses/LICENSE-2.0.
  ~
  ~ SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
  ~
  -->
<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.vertx</groupId>
    <artifactId>vertx-core-aggregator</artifactId>
    <version>5.0.10</version>
  </parent>

  <artifactId>vertx-core-logging</artifactId>
  <version>5.0.10</version>

  <name>Vert.x Core Logging</name>

  <dependencies>

    <!-- Loggers -->
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <optional>true</optional>
    </dependency>

    <!-- Testing -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>${junit.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.hamcrest</groupId>
      <artifactId>hamcrest-core</artifactId>
      <version>${harmcrest.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.assertj</groupId>
      <artifactId>assertj-core</artifactId>
      <version>${assertj.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
      </plugins>
    </pluginManagement>
    <plugins>

      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <id>compile-module-logging-with-slf4j</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <compileSourceRoots>
                <compileSourceRoot>${project.basedir}/src/test/module-logging-with-slf4j</compileSourceRoot>
              </compileSourceRoots>
              <outputDirectory>${project.build.directory}/module-logging-with-slf4j-classes</outputDirectory>
            </configuration>
          </execution>
          <execution>
            <id>compile-module-logging</id>
            <phase>test-compile</phase>
            <goals>
              <goal>testCompile</goal>
            </goals>
            <configuration>
              <compileSourceRoots>
                <compileSourceRoot>${project.basedir}/src/test/module-logging</compileSourceRoot>
              </compileSourceRoots>
              <outputDirectory>${project.build.directory}/module-logging-classes</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <phase>initialize</phase>
            <goals>
              <goal>properties</goal>
            </goals>
          </execution>
        </executions>
      </plugin>

      <!-- We need to use the exec-maven-plugin to recreate a modular app -->
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>exec-maven-plugin</artifactId>
        <version>3.3.0</version>
        <executions>
          <execution>
            <id>test-module-logging-with-jul</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>test</phase>
            <configuration>
              <executable>java</executable>
              <arguments>
                <argument>--module-path=target/classes${path.separator}target/module-logging-classes${path.separator}${org.slf4j:slf4j-api:jar}${path.separator}${org.slf4j:slf4j-simple:jar}</argument>
                <argument>--module=logging/logging.Main</argument>
              </arguments>
            </configuration>
          </execution>
          <execution>
            <id>test-module-logging-with-sl4j</id>
            <goals>
              <goal>exec</goal>
            </goals>
            <phase>test</phase>
            <configuration>
              <executable>java</executable>
              <arguments>
                <argument>--module-path=target/classes${path.separator}target/module-logging-with-slf4j-classes${path.separator}${org.slf4j:slf4j-api:jar}${path.separator}${org.slf4j:slf4j-simple:jar}</argument>
                <argument>--module=logging/logging.Main</argument>
              </arguments>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <configuration>
          <failIfNoTests>true</failIfNoTests>
        </configuration>
        <executions>
          <execution>
            <id>default-test</id>
            <configuration>
              <skip>true</skip>
            </configuration>
          </execution>
          <execution>
            <id>test-jul</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <includes>
                <include>**/JULLogDelegateTest.java</include>
              </includes>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.slf4j:*</classpathDependencyExclude>
                <classpathDependencyExclude>org.apache.logging.log4j:*</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
          <execution>
            <id>test-slf4j</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemProperties>
                <org.slf4j.simpleLogger.logFile>System.out</org.slf4j.simpleLogger.logFile>
                <org.slf4j.simpleLogger.cacheOutputStream>false</org.slf4j.simpleLogger.cacheOutputStream>
              </systemProperties>
              <includes>
                <include>**/SLF4JLogDelegateTest.java</include>
              </includes>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.apache.logging.log4j:*</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
          <execution>
            <id>test-log4j2</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <includes>
                <include>**/Log4J2LogDelegateTest.java</include>
              </includes>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.slf4j:*</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
          <execution>
            <id>test-classpath-logging-selection-jul</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemProperties>
                <test.expected>jul</test.expected>
              </systemProperties>
              <includes>
                <include>**/LoggingSelectionTest.java</include>
              </includes>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.slf4j:*</classpathDependencyExclude>
                <classpathDependencyExclude>org.apache.logging.log4j:*</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
          <execution>
            <id>test-classpath-logging-selection-slf4j</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemProperties>
                <test.expected>slf4j</test.expected>
              </systemProperties>
              <includes>
                <include>**/LoggingSelectionTest.java</include>
              </includes>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.apache.logging.log4j:*</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
          <execution>
            <id>test-classpath-logging-selection-log4j2</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemProperties>
                <test.expected>log4j2</test.expected>
              </systemProperties>
              <includes>
                <include>**/LoggingSelectionTest.java</include>
              </includes>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.slf4j:*</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
          <execution>
            <id>test-classpath-logging-selection-slf4j-over-log4j</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemProperties>
                <test.expected>slf4j</test.expected>
              </systemProperties>
              <includes>
                <include>**/LoggingSelectionTest.java</include>
              </includes>
            </configuration>
          </execution>
          <execution>
            <id>test-classpath-logging-selection-force-jul</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemProperties>
                <test.expected>jul</test.expected>
              </systemProperties>
              <includes>
                <include>**/LoggingSelectionTest.java</include>
              </includes>
              <additionalClasspathElements>
                <additionalClasspathElement>${project.basedir}/src/test/classpath/jul</additionalClasspathElement>
              </additionalClasspathElements>
            </configuration>
          </execution>
          <execution>
            <id>test-classpath-logging-selection-slf4j-no-impl</id>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <systemProperties>
                <test.expected>log4j2</test.expected>
              </systemProperties>
              <includes>
                <include>**/LoggingSelectionTest.java</include>
              </includes>
              <classpathDependencyExcludes>
                <classpathDependencyExclude>org.slf4j:slf4j-simple</classpathDependencyExclude>
              </classpathDependencyExcludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
