<?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/maven-v4_0_0.xsd">
  <parent>
    <artifactId>sift</artifactId>
    <groupId>net.onedaybeard.sift</groupId>
    <version>0.1.0</version>
  </parent>
  <modelVersion>4.0.0</modelVersion>
  <artifactId>cli</artifactId>
  <name>sift - cli tool</name>
  <build>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.graalvm.nativeimage</groupId>
          <artifactId>native-image-maven-plugin</artifactId>
          <version>21.2.0</version>
          <executions>
            <execution>
              <phase>package</phase>
              <goals>
                <goal>native-image</goal>
              </goals>
            </execution>
          </executions>
          <configuration>
            <imageName>sift</imageName>
          </configuration>
        </plugin>
        <plugin>
          <artifactId>maven-resources-plugin</artifactId>
          <version>3.3.0</version>
          <executions>
            <execution>
              <id>copy-sift-binary-to-local-m2</id>
              <phase>none</phase>
              <goals>
                <goal>copy-resources</goal>
              </goals>
              <configuration>
                <outputDirectory>${user.home}/.m2/repository/net/onedaybeard/sift/cli/${project.version}</outputDirectory>
                <resources>
                  <resource>
                    <directory>${project.build.directory}</directory>
                    <includes>
                      <include>sift</include>
                    </includes>
                  </resource>
                </resources>
              </configuration>
            </execution>
          </executions>
        </plugin>
      </plugins>
    </pluginManagement>
    <plugins>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <version>3.4.1</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <transformers>
                <transformer />
                <transformer>
                  <mainClass>sift.cli.SiftCliKt</mainClass>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>native-image-debug</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.graalvm.nativeimage</groupId>
            <artifactId>native-image-maven-plugin</artifactId>
            <configuration>
              <buildArgs>--no-fallback
                                -H:GenerateDebugInfo=1
                                -H:DebugInfoSourceSearchPath=${project.basedir}/src/main/kotlin
                                -H:DebugInfoSourceSearchPath=${project.basedir}/../instrumenters/jpa/src/main/kotlin
                                -H:DebugInfoSourceSearchPath=${project.basedir}/../instrumenters/jdbi/src/main/kotlin
                                -H:DebugInfoSourceSearchPath=${project.basedir}/../instrumenters/instrumenter-core/src/main/kotlin
                                -H:DebugInfoSourceSearchPath=${project.basedir}/../instrumenters/spring-boot-axon-cqrs/src/main/kotlin
                                -H:DebugInfoSourceSearchPath=${project.basedir}/../core/src/main/kotlin</buildArgs>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-sift-binary-to-local-m2</id>
                <phase>install</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>native-image</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.graalvm.nativeimage</groupId>
            <artifactId>native-image-maven-plugin</artifactId>
            <configuration>
              <buildArgs>--no-fallback</buildArgs>
            </configuration>
          </plugin>
          <plugin>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-sift-binary-to-local-m2</id>
                <phase>install</phase>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
  <dependencies>
    <dependency>
      <groupId>org.jetbrains.kotlin</groupId>
      <artifactId>kotlin-stdlib-jdk8</artifactId>
      <version>1.7.20</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
</project>
