<?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">
  <modelVersion>4.0.0</modelVersion>

  <parent>
    <artifactId>vertx-rx</artifactId>
    <groupId>io.vertx</groupId>
    <version>3.2.1</version>
  </parent>

  <artifactId>vertx-rx-java</artifactId>
  <version>3.2.1</version>

  <name>Vert.x RxJava API</name>

  <properties>
    <asciidoc.dir>${project.basedir}/src/main/asciidoc</asciidoc.dir>
    <lang>java</lang>
    <!-- There is an issue with source plugin because we don't get the generated sources
         because of BSC plugin, also the source is messy because we keep a version of vert.x core
         so better use the assembly plugin instead -->
    <source.skip>true</source.skip>
  </properties>

  <dependencies>
    <dependency>
      <groupId>io.reactivex</groupId>
      <artifactId>rxjava</artifactId>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-docgen</artifactId>
      <optional>true</optional>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
      <classifier>sources</classifier>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.17</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>1.7.12</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-codegen</artifactId>
      <classifier>tck-sources</classifier>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <executions>
            <execution>
              <id>default-clean</id>
              <configuration>
                <filesets>
                  <fileset>
                    <directory>src/main/java/io/vertx/core</directory>
                  </fileset>
                </filesets>
              </configuration>
            </execution>
          </executions>
        </plugin>
        <plugin>
          <artifactId>maven-jar-plugin</artifactId>
          <executions>
            <execution>
              <id>default-jar</id>
              <configuration>
                <excludes>
                  <exclude>io/vertx/core/**</exclude>
                </excludes>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>

      <!-- Configure the execution of the compiler to execute the codegen processor -->
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <id>default-compile</id>
            <configuration>
              <annotationProcessors>
                <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
              </annotationProcessors>
              <compilerArgs>
                <arg>-AoutputDirectory=${project.basedir}/src/main</arg>
                <arg>-Amaven.groupId=${project.groupId}</arg>
                <arg>-Amaven.artifactId=${project.artifactId}</arg>
                <arg>-Amaven.version=${project.version}</arg>
              </compilerArgs>
            </configuration>
          </execution>
          <execution>
            <id>default-testCompile</id>
            <configuration>
              <annotationProcessors>
                <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
              </annotationProcessors>
              <compilerArgs>
                <arg>-AoutputDirectory=${project.basedir}/src/test</arg>
              </compilerArgs>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <!-- Unpack vertx-core source code to src/main/java -->
          <execution>
            <id>unpack-vertx-core</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>io.vertx</includeGroupIds>
              <includeArtifactIds>vertx-core</includeArtifactIds>
              <includeTypes>jar</includeTypes>
              <includeClassifiers>sources</includeClassifiers>
              <includes>io/vertx/core/**/*.java</includes>
              <outputDirectory>${basedir}/src/main/java</outputDirectory>
            </configuration>
          </execution>
          <!-- Unpack codegen source code to src/test/java -->
          <execution>
            <id>unpack-codegen</id>
            <phase>generate-test-sources</phase>
            <goals>
              <goal>unpack-dependencies</goal>
            </goals>
            <configuration>
              <includeGroupIds>io.vertx</includeGroupIds>
              <includeArtifactIds>vertx-codegen</includeArtifactIds>
              <includeTypes>jar</includeTypes>
              <includeClassifiers>tck-sources</includeClassifiers>
              <outputDirectory>${basedir}/src/test/java</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.bsc.maven</groupId>
        <artifactId>maven-processor-plugin</artifactId>
        <version>2.2.4</version>
        <executions>
          <execution>
            <goals>
              <goal>process</goal>
            </goals>
            <phase>process-classes</phase>
            <configuration>
              <processors>
                <processor>io.vertx.docgen.JavaDocGenProcessor</processor>
              </processors>
              <includes>
                <include>io/vertx/rxjava/core/**/*.java</include>
                <include>examples/**/*.java</include>
              </includes>
              <optionMap>
                <docgen.output>${asciidoc.dir}/java</docgen.output>
              </optionMap>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Doc generation -->
      <plugin>
        <groupId>org.asciidoctor</groupId>
        <artifactId>asciidoctor-maven-plugin</artifactId>
        <executions>
          <execution>
            <id>process-asciidoc</id>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-javadoc-plugin</artifactId>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>javadoc</goal>
            </goals>
            <configuration>
              <reportOutputDirectory>${project.build.directory}/docs</reportOutputDirectory>
              <sourcepath>${project.basedir}/src/main/java:${project.build.directory}/generated-sources/annotations</sourcepath>
              <sourceFileIncludes>
                <sourceFileInclude>io/vertx/rxjava/core/**/*.java</sourceFileInclude>
                <sourceFileInclude>io/vertx/rx/java/**/*.java</sourceFileInclude>
              </sourceFileIncludes>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>package-docs</id>
          </execution>
          <execution>
            <id>package-sources</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>true</attach>
              <descriptors>
                <descriptor>src/main/assembly/sources.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

</project>
