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

  <artifactId>vertx-rx-java2-gen</artifactId>
  <version>4.3.4</version>

  <name>Vert.x RxJava2 Code Generator</name>

  <properties>
    <asciidoc.dir>${project.basedir}/src/main/asciidoc</asciidoc.dir>
    <lang>java</lang>
  </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-rx-gen</artifactId>
      <version>4.3.4</version>
    </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>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-gen</artifactId>
      <version>4.3.4</version>
      <type>test-jar</type>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.13.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>com.fasterxml.jackson.dataformat</groupId>
      <artifactId>jackson-dataformat-yaml</artifactId>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <artifactId>maven-clean-plugin</artifactId>
          <executions>
            <execution>
              <id>default-clean</id>
              <configuration>
                <filesets>
                  <fileset>
                    <directory>${project.basedir}/src/unpacked/java</directory>
                  </fileset>
                </filesets>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>

      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
        <executions>
          <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-codegen/src/test/java</directory>
                  <includes>
                    <include>io/vertx/codegen/extra/**</include>
                  </includes>
                </resource>
              </resources>
            </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>
            <mvel2.disable.jit>true</mvel2.disable.jit>
          </systemProperties>
        </configuration>
        <executions>
          <!-- Run the annotation processor on java sources and generate the API -->
          <execution>
            <id>generate-api</id>
            <goals>
              <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <sourceDirectory>${project.build.directory}/sources/java</sourceDirectory>
              <processors>
                <processor>io.vertx.codegen.CodeGenProcessor</processor>
              </processors>
              <optionMap>
                <codegen.output>${project.basedir}/src/main</codegen.output>
              </optionMap>
              <excludes>
                <exclude>examples/**/*.java</exclude>
              </excludes>
            </configuration>
          </execution>

          <!-- Run the annotation processor to produce test stubs -->
          <execution>
            <id>generate-stubs</id>
            <goals>
              <goal>process-test</goal>
            </goals>
            <phase>generate-test-sources</phase>
            <configuration>
              <sourceDirectory>${project.basedir}/src/test/stubs</sourceDirectory>
              <processors>
                <processor>io.vertx.codegen.CodeGenProcessor</processor>
              </processors>
              <optionMap>
                <codegen.output>${project.basedir}/src/test</codegen.output>
                <codegen.generators>RxJava2</codegen.generators>
              </optionMap>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Configure the execution of the compiler to execute the codegen processor -->
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <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>
          <groupId>org.codehaus.mojo</groupId>
          <artifactId>build-helper-maven-plugin</artifactId>
          <executions>
            <execution>
              <id>add-test-source</id>
              <goals>
                <goal>add-test-source</goal>
              </goals>
              <configuration>
                <sources>
                  <source>${basedir}/src/unpacked/java</source>
                </sources>
              </configuration>
            </execution>
          </executions>
        </plugin>
      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <!-- Unpack codegen tck source code to src/unpacked/java -->
          <execution>
            <id>unpack-codegen</id>
            <phase>generate-test-sources</phase>
            <goals>
              <!-- We use unpack instead of unpack-dependencies on purpose to not depend on the jar because it can confuse the IDE -->
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>io.vertx</groupId>
                  <artifactId>vertx-codegen</artifactId>
                  <classifier>tck-sources</classifier>
                </artifactItem>
              </artifactItems>
              <outputDirectory>${project.basedir}/src/unpacked/java</outputDirectory>
              <includes>**/*.java,META-INF/vertx/json-mappers.properties</includes>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
