<?xml version="1.0" encoding="UTF-8"?>
<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">
  <parent>
    <groupId>io.vertx</groupId>
    <artifactId>vertx-lang-scala-parent_2.12</artifactId>
    <version>3.4.2</version>
    <relativePath>..</relativePath>
  </parent>

  <modelVersion>4.0.0</modelVersion>

  <artifactId>vertx-lang-scala-stack_2.12</artifactId>

  <packaging>pom</packaging>

  <properties>
    <vertx-module>none</vertx-module>
    <!--
      Configure plugins that skip building documentation that otherwise would fail without
      the documentation bits. This is useful in pom aggregators that don't have documentation
      to build, they change this property to true.
    -->
    <doc.skip>false</doc.skip>

    <!-- We skip sources jar generation as we do it with the assembly plugin to have greater
         control over the content -->
    <source.skip>false</source.skip>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-lang-scala_2.12</artifactId>
      <version>${stack.version}</version>
    </dependency>

    <!-- CODEGEN -->
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-docgen</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codetrans</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy</artifactId>
      <version>2.4.11</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>net.alchim31.maven</groupId>
          <artifactId>scala-maven-plugin</artifactId>
          <version>3.2.2</version>
          <configuration>
            <args>
              <arg>-target:jvm-1.8</arg>
              <arg>-feature</arg>
              <arg>-deprecation</arg>
              <arg>-explaintypes</arg>
              <arg>-unchecked</arg>
              <arg>-Xlint</arg>
            </args>
          </configuration>
          <executions>
            <execution>
              <id>scala-doc</id>
              <phase>test</phase>
              <goals>
                <goal>doc</goal>
              </goals>
            </execution>
            <execution>
              <id>scala-compile</id>
              <phase>compile</phase>
              <goals>
                <goal>compile</goal>
              </goals>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <configuration>
            <additionalClasspathElements>
              <additionalClasspathElement>${project.build.testSourceDirectory}
              </additionalClasspathElement>
              <additionalClasspathElement>${project.basedir}/src/main/resources
              </additionalClasspathElement>
            </additionalClasspathElements>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <executions>
            <execution>
              <id>default-clean</id>
              <configuration>
                <filesets>
                  <fileset>
                    <directory>src/main/scala</directory>
                  </fileset>
                  <fileset>
                    <directory>${asciidoc.dir}</directory>
                  </fileset>
                </filesets>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <executions>
            <execution>
              <id>unpack-vertx-core</id>
              <phase>generate-sources</phase>
              <goals>
                <goal>unpack-dependencies</goal>
              </goals>
              <configuration>
                <includeGroupIds>io.vertx</includeGroupIds>
                <includeArtifactIds>${vertx-module}</includeArtifactIds>
                <includeTypes>jar</includeTypes>
                <includeClassifiers>sources</includeClassifiers>
                <includes>**/*.java</includes>
                <excludes>**/rxjava/**/*.*</excludes>
                <outputDirectory>${project.build.directory}/sources/vertx</outputDirectory>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-compiler-plugin</artifactId>
          <executions>
            <execution>
              <id>default-compile</id>
              <configuration>
                <annotationProcessors>
                  <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
                  <annotationProcessor>io.vertx.docgen.JavaDocGenProcessor</annotationProcessor>
                  <annotationProcessor>io.vertx.docgen.DocGenProcessor</annotationProcessor>
                </annotationProcessors>
                <generatedSourcesDirectory>${project.basedir}/src/main/generated</generatedSourcesDirectory>
                <compilerArgs>
                  <arg>-AoutputDirectory=${project.basedir}/src/main</arg>
                  <!-- $lang is replaced by the docgen processor to the target lang -->
                  <arg>-Adocgen.output=${asciidoc.dir}/$lang</arg>

                  <arg>-Amaven.groupId=${project.groupId}</arg>
                  <arg>-Amaven.artifactId=${project.artifactId}</arg>
                  <arg>-Amaven.version=${project.version}</arg>
                </compilerArgs>
              </configuration>
            </execution>
          </executions>
        </plugin>

        <plugin>
          <groupId>org.bsc.maven</groupId>
          <artifactId>maven-processor-plugin</artifactId>
          <version>3.1.0</version>
          <configuration>
            <systemProperties>
              <java.util.logging.SimpleFormatter.format>%4$s: %3$s - %5$s %6$s%n
              </java.util.logging.SimpleFormatter.format>
            </systemProperties>
          </configuration>
          <executions>
            <!-- Run the annotation processor and generate the Scala API -->
            <execution>
              <id>generate-api</id>
              <goals>
                <goal>process</goal>
              </goals>
              <phase>generate-sources</phase>
              <configuration>
                <processors>
                  <processor>io.vertx.codegen.CodeGenProcessor</processor>
                  <processor>io.vertx.docgen.DocGenProcessor</processor>
                </processors>
                <optionMap>
                  <outputDirectory>${project.basedir}/src/main</outputDirectory>
                  <docgen.output>${asciidoc.dir}/scala</docgen.output>
                </optionMap>
                <sourceDirectory>${project.build.directory}/sources/vertx</sourceDirectory>
              </configuration>
            </execution>
            <!-- Run the annotation processor on codegen and generate the Scala codegen -->
            <execution>
              <id>generate-codegen</id>
              <goals>
                <goal>process</goal>
              </goals>
              <phase>generate-test-sources</phase>
              <configuration>
                <processors>
                  <processor>io.vertx.codegen.CodeGenProcessor</processor>
                </processors>
                <optionMap>
                  <outputDirectory>${project.basedir}/src/test</outputDirectory>
                </optionMap>
                <sourceDirectory>${project.build.directory}/sources/codegen</sourceDirectory>
              </configuration>
            </execution>
            <!-- We have to run the annotation processor again to process docs -->
            <execution>
              <id>docgen-docs</id>
              <goals>
                <goal>process</goal>
              </goals>
              <phase>prepare-package</phase>
              <configuration>
                <processors>
                  <processor>io.vertx.docgen.DocGenProcessor</processor>
                </processors>
                <optionMap>
                  <outputDirectory>${project.basedir}/src/main</outputDirectory>
                  <docgen.output>${asciidoc.dir}/scala</docgen.output>
                  <maven.groupId>${project.groupId}</maven.groupId>
                  <maven.artifactId>${project.artifactId}</maven.artifactId>
                  <maven.version>${project.version}</maven.version>
                </optionMap>
                <sourceDirectory>${project.build.directory}/sources/vertx</sourceDirectory>
              </configuration>
            </execution>
            <!-- We have to run the annotation processor again to process docoverride -->
            <execution>
              <id>docgen-docoverride</id>
              <goals>
                <goal>process</goal>
              </goals>
              <phase>prepare-package</phase>
              <configuration>
                <processors>
                  <processor>io.vertx.docgen.DocGenProcessor</processor>
                </processors>
                <optionMap>
                  <outputDirectory>${project.basedir}/src/main</outputDirectory>
                  <docgen.output>${asciidoc.dir}/scala</docgen.output>
                  <maven.groupId>${project.groupId}</maven.groupId>
                  <maven.artifactId>${project.artifactId}</maven.artifactId>
                  <maven.version>${project.version}</maven.version>
                </optionMap>
                <sourceDirectory>${project.basedir}/src/main/docoverride</sourceDirectory>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <executions>
            <execution>
              <id>assemble-docs</id>
              <phase>package</phase>
              <goals>
                <goal>single</goal>
              </goals>
              <configuration>
                <attach>true</attach>
                <descriptorSourceDirectory>src/main/assembly</descriptorSourceDirectory>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <modules>
    <module>vertx-mqtt-server</module>
    <module>vertx-sql-common</module>
    <module>vertx-bridge-common</module>
    <module>vertx-jdbc-client</module>
    <module>vertx-mongo-client</module>
    <module>vertx-mongo-service</module>
    <module>vertx-auth-common</module>
    <module>vertx-auth-shiro</module>
    <module>vertx-auth-htdigest</module>
    <module>vertx-auth-oauth2</module>
    <module>vertx-auth-mongo</module>
    <module>vertx-auth-jwt</module>
    <module>vertx-auth-jdbc</module>
    <module>vertx-web</module>
    <module>vertx-web-common</module>
    <module>vertx-web-client</module>
    <module>vertx-sockjs-service-proxy</module>
    <module>vertx-web-templ-freemarker</module>
    <module>vertx-web-templ-handlebars</module>
    <module>vertx-web-templ-jade</module>
    <module>vertx-web-templ-mvel</module>
    <module>vertx-web-templ-pebble</module>
    <module>vertx-web-templ-thymeleaf</module>
    <module>vertx-mysql-postgresql-client</module>
    <module>vertx-mail-client</module>
    <module>vertx-rabbitmq-client</module>
    <module>vertx-redis-client</module>
    <module>vertx-stomp</module>
    <module>vertx-tcp-eventbus-bridge</module>
    <module>vertx-amqp-bridge</module>
    <module>vertx-dropwizard-metrics</module>
    <module>vertx-hawkular-metrics</module>
    <module>vertx-shell</module>
    <module>vertx-kafka-client</module>
    <module>vertx-circuit-breaker</module>
    <module>vertx-config</module>
    <module>vertx-service-discovery</module>
  </modules>
</project>
