<?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>
    <groupId>io.camunda.connectors.community</groupId>
    <artifactId>script-connector-parent</artifactId>
    <version>2.1.1</version>
  </parent>
  <artifactId>script-connector-runtime</artifactId>
  <name>Script Connector Runtime</name>
  <dependencies>
    <dependency>
      <groupId>io.camunda.connectors.community</groupId>
      <artifactId>script-connector</artifactId>
    </dependency>
    <dependency>
      <groupId>io.camunda.connector</groupId>
      <artifactId>spring-boot-starter-camunda-connectors</artifactId>
    </dependency>
    <dependency>
      <groupId>io.camunda</groupId>
      <artifactId>camunda-process-test-spring</artifactId>
      <scope>test</scope>
    </dependency>
  </dependencies>
  <build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
          <!-- Needs to unpack this dependency.
           See: https://github.com/sdeleuze/kotlin-script-templating/issues/7#issuecomment-364572513
           -->
          <requiresUnpack>
            <dependency>
              <groupId>org.jetbrains.kotlin</groupId>
              <artifactId>kotlin-compiler-embeddable</artifactId>
            </dependency>
          </requiresUnpack>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <profiles>
    <profile>
      <id>build-image</id>
      <build>
        <plugins>
          <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>build-version</id>
                <goals>
                  <goal>build-image-no-fork</goal>
                </goals>
                <phase>package</phase>
                <configuration>
                  <image>
                    <name>ghcr.io/camunda-community-hub/script-connector/runtime:${project.version}</name>
                  </image>
                </configuration>
              </execution>
              <execution>
                <id>build-latest</id>
                <goals>
                  <goal>build-image-no-fork</goal>
                </goals>
                <phase>package</phase>
                <configuration>
                  <image>
                    <name>ghcr.io/camunda-community-hub/script-connector/runtime</name>
                  </image>
                </configuration>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>
</project>
