<?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>com.dylibso.chicory</groupId>
    <artifactId>chicory</artifactId>
    <version>1.7.3</version>
  </parent>
  <artifactId>build-time-compiler-cli-experimental</artifactId>
  <packaging>jar</packaging>

  <name>Chicory - Build Time Compiler Cli</name>
  <description>Chicory Build Time Compiler CLI</description>

  <dependencies>
    <dependency>
      <groupId>com.dylibso.chicory</groupId>
      <artifactId>build-time-compiler</artifactId>
    </dependency>
    <dependency>
      <groupId>com.dylibso.chicory</groupId>
      <artifactId>compiler</artifactId>
    </dependency>
    <dependency>
      <groupId>com.dylibso.chicory</groupId>
      <artifactId>wasm</artifactId>
    </dependency>
    <dependency>
      <groupId>info.picocli</groupId>
      <artifactId>picocli</artifactId>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <executions>
          <execution>
            <id>default-compile</id>
            <goals>
              <goal>compile</goal>
            </goals>
            <phase>compile</phase>
            <configuration>
              <release>${maven.compiler.release}</release>
              <parameters>true</parameters>
              <failOnWarning>${maven.compiler.failOnWarning}</failOnWarning>
              <showDeprecation>true</showDeprecation>
              <showWarnings>true</showWarnings>
              <compilerArgs>
                <arg>-Aproject=${project.groupId}/${project.artifactId}</arg>
              </compilerArgs>
              <annotationProcessorPaths>
                <path>
                  <groupId>info.picocli</groupId>
                  <artifactId>picocli-codegen</artifactId>
                  <version>${picocli.version}</version>
                </path>
              </annotationProcessorPaths>
            </configuration>
          </execution>
        </executions>

      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>shade</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <transformers>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>com.dylibso.chicory.experimental.compiler.cli.Cli</mainClass>
                </transformer>
              </transformers>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <filters>
                <filter>
                  <artifact>*:*</artifact>
                  <excludes>
                    <exclude>META-INF/*.SF</exclude>
                    <exclude>META-INF/*.DSA</exclude>
                    <exclude>META-INF/*.RSA</exclude>
                  </excludes>
                </filter>
              </filters>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- now make the jar chmod +x style executable -->
      <plugin>
        <groupId>org.skife.maven</groupId>
        <artifactId>really-executable-jar-maven-plugin</artifactId>
        <version>2.1.1</version>
        <configuration>
          <flags>-Xmx1G</flags>
          <programFile>chicory-compiler</programFile>
          <attachProgramFile>true</attachProgramFile>
        </configuration>

        <executions>
          <execution>
            <goals>
              <goal>really-executable-jar</goal>
            </goals>
            <phase>package</phase>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
