<?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.5.1</version>
  </parent>

  <artifactId>vertx-rx-java2</artifactId>
  <version>3.5.1</version>

  <name>Vert.x RxJava2 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.rxjava2</groupId>
      <artifactId>rxjava</artifactId>
    </dependency>
    <dependency>
      <groupId>org.reactivestreams</groupId>
      <artifactId>reactive-streams</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>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>io.vertx</groupId>
      <artifactId>vertx-rx-java</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-rx-java</artifactId>
      <type>test-jar</type>
      <scope>test</scope>
      <version>3.5.1</version>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-yaml</artifactId>
      <version>2.9.0</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>
                  <exclude>/docoverride/**</exclude>
                  <exclude>/examples/**</exclude>
                </excludes>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
          <execution>
            <id>copy-templates</id>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <phase>generate-resources</phase>
            <configuration>
              <outputDirectory>${project.build.outputDirectory}/vertx-rxjava2/template</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.basedir}/../rx-java/src/main/resources/vertx-rxjava/template</directory>
                  <includes>
                    <include>class.templ</include>
                    <include>classbody.templ</include>
                    <include>common.templ</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
          <execution>
            <id>copy-codegen-extra</id>
            <goals>
              <goal>copy-resources</goal>
            </goals>
            <phase>generate-test-sources</phase>
            <configuration>
              <outputDirectory>${project.basedir}/src/test/java/</outputDirectory>
              <resources>
                <resource>
                  <directory>${project.basedir}/../rx-java/src/test/java</directory>
                  <includes>
                    <include>io/vertx/codegen/extra/**</include>
                  </includes>
                </resource>
              </resources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          </archive>
        </configuration>
      </plugin>

      <plugin>
        <groupId>biz.aQute.bnd</groupId>
        <artifactId>bnd-maven-plugin</artifactId>
        <version>3.2.0</version>

        <executions>
          <execution>
            <id>default-bnd-process</id>
            <goals>
              <goal>bnd-process</goal>
            </goals>
          </execution>
        </executions>
        <configuration>
          <bnd><![CDATA[
          Import-Package: \
              io.vertx.codegen.annotations;resolution:=optional,\
              io.vertx.core,\
              io.vertx.core.buffer,\
              io.vertx.core.cli,\
              io.vertx.core.cli.annotations,\
              io.vertx.core.cli.converters,\
              io.vertx.core.datagram,\
              io.vertx.core.dns,\
              io.vertx.core.eventbus,\
              io.vertx.core.file,\
              io.vertx.core.http,\
              io.vertx.core.json,\
              io.vertx.core.logging,\
              io.vertx.core.metrics,\
              io.vertx.core.net,\
              io.vertx.core.parsetools,\
              io.vertx.core.shareddata,\
              io.vertx.core.spi,\
              io.vertx.core.spi.cluster,\
              io.vertx.core.spi.launcher,\
              io.vertx.core.spi.logging,\
              io.vertx.core.spi.metrics,\
              io.vertx.core.streams,\
              *
           -exportcontents: !examples,!io.vertx.core.*, *
          ]]></bnd>
        </configuration>
      </plugin>

      <!-- 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>-Acodegen.output=${project.basedir}/src/main</arg>
                <arg>-Acodegen.generators=RxJava2</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>-Acodegen.output=${project.basedir}/src/test</arg>
                <arg>-Acodegen.generators=RxJava2</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>
              <excludes>**/impl/**/*.java,**/logging/*.java</excludes>
              <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>3.1.0</version>
        <executions>
          <execution>
            <goals>
              <goal>process</goal>
            </goals>
            <phase>process-classes</phase>
            <configuration>
              <processors>
                <processor>io.vertx.docgen.JavaDocGenProcessor</processor>
                <processor>io.vertx.docgen.DocGenProcessor</processor>
              </processors>
              <includes>
                <include>io/vertx/reactivex/**/*.java</include>
                <include>examples/**/*.java</include>
              </includes>
              <optionMap>
                <docgen.output>${asciidoc.dir}/java2</docgen.output>
                <maven.groupId>${project.groupId}</maven.groupId>
                <maven.artifactId>${project.artifactId}</maven.artifactId>
                <maven.version>${project.version}</maven.version>
              </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>
        <version>3.0.0-M1</version>
        <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/reactivex/**/*.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>
