<?xml version="1.0" encoding="UTF-8"?>
<project
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
    xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">

  <modelVersion>4.0.0</modelVersion>
  <properties>
    <maven.version>3.0.4</maven.version>
    <annotation-processing.src>${basedir}/../../../plugins/kapt3/kapt3-compiler/src</annotation-processing.src>
    <annotation-processing.cli.src>${basedir}/../../../plugins/kapt3/kapt3-cli/src</annotation-processing.cli.src>
    <annotation-processing.resources>${basedir}/../../../plugins/kapt3/kapt3-compiler/resources</annotation-processing.resources>
    <annotation-processing.base.src>${basedir}/../../../plugins/kapt3/kapt3-base/src</annotation-processing.base.src>
    <annotation-processing.runtime.src>${basedir}/../../../plugins/kapt3/kapt3-runtime/src</annotation-processing.runtime.src>
  </properties>

  <parent>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-project</artifactId>
    <version>1.6.0</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>

  <artifactId>kotlin-annotation-processing-maven</artifactId>
  <packaging>jar</packaging>

  <description>Annotation Processor wrapper for Kotlin Maven plugin</description>

  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-compiler</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>com.android.tools.build</groupId>
      <artifactId>gradle</artifactId>
      <version>1.1.0</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>

  <build>
    <resources>
      <resource><directory>${annotation-processing.resources}</directory></resource>
    </resources>

    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>build-helper-maven-plugin</artifactId>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals><goal>add-source</goal></goals>
            <configuration>
              <sources>
                <source>${annotation-processing.src}</source>
                <source>${annotation-processing.cli.src}</source>
                <source>${annotation-processing.base.src}</source>
                <source>${annotation-processing.runtime.src}</source>
              </sources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <artifactId>kotlin-maven-plugin</artifactId>
        <groupId>org.jetbrains.kotlin</groupId>
        <version>${project.version}</version>
        <configuration>
          <jdkHome>${env.JDK_18}</jdkHome>
          <annotationPaths>
            <annotationPath>${basedir}/kotlinAnnotation</annotationPath>
          </annotationPaths>
        </configuration>

        <executions>
          <execution>
            <id>compile</id>
            <phase>compile</phase>
            <goals><goal>compile</goal></goals>
          </execution>
          <execution>
            <id>test-compile</id>
            <phase>test-compile</phase>
            <goals><goal>test-compile</goal></goals>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <configuration>
          <source>1.6</source>
          <target>1.6</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-failsafe-plugin</artifactId>
        <version>2.6</version>
        <executions>
          <execution>
            <goals>
              <goal>integration-test</goal>
              <goal>verify</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>tools_jar_profile</id>
      <activation>
        <activeByDefault>false</activeByDefault>
        <file>
          <exists>kotlin-annotation-processing-maven-build.txt</exists>
        </file>
      </activation>
      <properties>
        <toolsjar>${env.JDK_18}/lib/tools.jar</toolsjar>
      </properties>
      <dependencies>
        <dependency>
          <groupId>com.sun</groupId>
          <artifactId>tools</artifactId>
          <version>1.8.0</version>
          <scope>system</scope>
          <systemPath>${toolsjar}</systemPath>
        </dependency>
      </dependencies>
    </profile>
  </profiles>
</project>
