<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 2002-2020, the original author or authors.

    This software is distributable under the BSD license. See the terms of the
    BSD license in the documentation provided with this software.

    https://opensource.org/licenses/BSD-3-Clause

-->
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.jline</groupId>
        <artifactId>jline-parent</artifactId>
        <version>4.1.0</version>
    </parent>

    <artifactId>jline-graal</artifactId>
    <name>JLine Native Demo</name>

    <properties>
        <automatic.module.name>org.jline.graal</automatic.module.name>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jline</groupId>
            <artifactId>jline-shell</artifactId>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <phase>package</phase>
                        <configuration>
                            <outputDirectory>${project.build.directory}/lib</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.graalvm.buildtools</groupId>
                <artifactId>native-maven-plugin</artifactId>
                <configuration>
                    <skip>${native.image.skip}</skip>
                    <imageName>graal</imageName>
                    <mainClass>org.jline.demo.graal.Graal</mainClass>
                </configuration>
                <executions>
                    <execution>
                        <id>build-native</id>
                        <goals>
                            <goal>compile-no-fork</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>verify-native-image</id>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <phase>verify</phase>
                        <configuration>
                            <skip>${native.image.skip}</skip>
                            <executable>${project.build.directory}/graal</executable>
                            <arguments>
                                <argument>--check</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>native-image-ffm</id>
            <properties>
                <java.release.version>22</java.release.version>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.jline</groupId>
                    <artifactId>jline-terminal-ffm</artifactId>
                    <version>${project.version}</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <configuration>
                            <buildArgs>
                                <arg>--enable-native-access=ALL-UNNAMED</arg>
                            </buildArgs>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>native-image-jni</id>
            <dependencies>
                <dependency>
                    <groupId>org.jline</groupId>
                    <artifactId>jline-terminal-jni</artifactId>
                    <version>${project.version}</version>
                </dependency>
            </dependencies>
        </profile>
    </profiles>

</project>
