<?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-lang-kotlin-parent</artifactId>
    <groupId>io.vertx</groupId>
    <version>4.5.7</version>
  </parent>

  <artifactId>vertx-lang-kotlin-gen</artifactId>

  <dependencies>
    <dependency>
      <groupId>io.vertx</groupId>
      <artifactId>vertx-core</artifactId>
    </dependency>
    <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-lang-kotlin-coroutines</artifactId>
      <optional>true</optional>
    </dependency>

    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-test-junit</artifactId>
      <scope>test</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-codegen</artifactId>
      <classifier>tck</classifier>
      <scope>test</scope>
    </dependency>

  </dependencies>

  <profiles>
    <profile>
      <id>generate-something</id>
      <activation>
        <jdk>[8,16)</jdk>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>compile</id>
                <goals>
                  <goal>compile</goal>
                </goals>
                <phase>compile</phase>
                <configuration>
                  <sourceDirs>
                    <sourceDir>src/main/java</sourceDir>
                    <sourceDir>target/generated-sources/kotlin</sourceDir>
                  </sourceDirs>
                </configuration>
              </execution>
              <execution>
                <id>test-kapt</id>
                <goals>
                  <goal>test-kapt</goal>
                </goals>
                <configuration>
                  <annotationProcessors>
                    <annotationProcessor>io.vertx.codegen.CodeGenProcessor</annotationProcessor>
                  </annotationProcessors>
                  <annotationProcessorArgs>
                    <processorArg>codegen.generators=Kotlin,KotlinCoroutines</processorArg>
                  </annotationProcessorArgs>
                  <sourceDirs>
                    <sourceDir>src/test/kotlin</sourceDir>
                    <sourceDir>${project.build.directory}/sources/vertx-codegen</sourceDir>
                  </sourceDirs>
                </configuration>
              </execution>
              <execution>
                <id>test-compile</id>
                <goals>
                  <goal>test-compile</goal>
                </goals>
                <phase>test-compile</phase>
                <configuration>
                  <sourceDirs>
                    <sourceDir>src/test/kotlin</sourceDir>
                    <!-- We need this because test-kapt does not store the generated Kotlin source at the right location -->
                    <sourceDir>${project.build.directory}/generated-sources/kaptKotlin</sourceDir>
                  </sourceDirs>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <build>
    <plugins>

      <plugin>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <!-- Unpack codegen source code to sources/test/java -->
          <execution>
            <id>unpack-tck</id>
            <phase>generate-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>${project.build.directory}/sources/vertx-codegen</outputDirectory>
            </configuration>
          </execution>
        </executions>
      </plugin>

    </plugins>
  </build>

</project>
