<?xml version="1.0"?>
<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">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.neo4j</groupId>
        <artifactId>cypher-shell-parent</artifactId>
        <version>5.26.12</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>cypher-shell</artifactId>
    <version>5.26.12</version>
    <packaging>jar</packaging>
    <name>Neo4j - Cypher Shell</name>
    <description>Cypher Shell</description>
    <url>http://components.neo4j.org/${project.artifactId}/${project.version}</url>

    <properties>
        <appassembler-maven-plugin.version>2.1.0</appassembler-maven-plugin.version>
        <assembly-suffix />
        <executable-suffix />
        <jline.version>3.21.0</jline.version>
        <moduleName>org.neo4j.shell</moduleName>
        <name-of-main-class>org.neo4j.shell.Main</name-of-main-class>
        <native-maven-plugin.version>0.9.9</native-maven-plugin.version>
        <os-maven-plugin.version>1.7.0</os-maven-plugin.version>
        <skipCompress>false</skipCompress>
        <svm.version>21.3.0</svm.version>
    </properties>

    <scm>
        <connection>scm:git:git://github.com/neo4j/neo4j.git</connection>
        <developerConnection>scm:git:git@github.com:neo4j/neo4j.git</developerConnection>
        <url>https://github.com/neo4j/neo4j</url>
    </scm>

    <dependencies>


        <!-- Neo4j dependencies -->

        <dependency>
            <groupId>org.neo4j.driver</groupId>
            <artifactId>neo4j-java-driver</artifactId>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>cypher-antlr-ast-common</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>cypher-v5-ast-factory</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>cypher-v5-literal-interpreter</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j-cypher-dsl</artifactId>
            <version>2024.2.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apiguardian</groupId>
                    <artifactId>apiguardian-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Other dependencies -->

        <dependency>
            <groupId>net.sourceforge.argparse4j</groupId>
            <artifactId>argparse4j</artifactId>
            <version>0.9.0</version>
        </dependency>
        <dependency>
            <groupId>org.jline</groupId>
            <artifactId>jline-terminal</artifactId>
            <version>${jline.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jline</groupId>
            <artifactId>jline-reader</artifactId>
            <version>${jline.version}</version>
        </dependency>
        <dependency>
            <groupId>org.jline</groupId>
            <artifactId>jline-terminal-jansi</artifactId>
            <version>${jline.version}</version>
        </dependency>

        <dependency>
            <groupId>org.graalvm.nativeimage</groupId>
            <artifactId>svm</artifactId>
            <version>${svm.version}</version>
            <!-- Provided scope as it is only needed for compiling the SVM substitution classes -->
            <scope>provided</scope>
            <!-- We don't use those, they are not GPLv2 licensed. -->
            <exclusions>
                <exclusion>
                    <groupId>org.graalvm.sdk</groupId>
                    <artifactId>graal-sdk</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.graalvm.truffle</groupId>
                    <artifactId>truffle-api</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.awaitility</groupId>
            <artifactId>awaitility</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>build.properties</include>
                </includes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <!-- The purpose of this execution is to provide a user-friendly error message when started with an unsupported jvm -->
                    <execution>
                        <id>compile-java8</id>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <source>1.8</source>
                            <target>1.8</target>
                            <compileSourceRoots>
                                <compileSourceRoot>${project.basedir}/src/main/java8</compileSourceRoot>
                            </compileSourceRoots>
                        </configuration>
                    </execution>
                    <!-- This is the normal execution -->
                    <execution>
                        <id>compile</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>compile</goal>
                        </goals>
                        <configuration>
                            <release>${maven.compiler.target}</release>
                            <multiReleaseOutput>true</multiReleaseOutput>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Multi-Release>true</Multi-Release>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>appassembler-maven-plugin</artifactId>
                <version>${appassembler-maven-plugin.version}</version>
                <configuration>
                    <assembleDirectory>${project.build.directory}/assembly</assembleDirectory>
                    <repositoryLayout>flat</repositoryLayout>
                    <repositoryName>lib</repositoryName>
                    <useWildcardClassPath>true</useWildcardClassPath>
                    <programs>
                        <program>
                            <mainClass>org.neo4j.shell.startup.CypherShellBoot</mainClass>
                            <id>cypher-shell</id>
                        </program>
                    </programs>
                </configuration>
                <executions>
                    <execution>
                        <id>make-distribution</id>
                        <goals>
                            <goal>assemble</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <configuration>
                    <encoding>UTF-8</encoding>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <id>assembly-java</id>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/assembly/assembly-java.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <extensions>
            <extension>
                <groupId>kr.motd.maven</groupId>
                <artifactId>os-maven-plugin</artifactId>
                <version>${os-maven-plugin.version}</version>
            </extension>
        </extensions>
    </build>

    <profiles>
        <profile>
            <id>windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <executable-suffix>.exe</executable-suffix>
            </properties>
        </profile>
        <profile>
            <id>native</id>
            <activation>
                <property>
                    <name>native</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.graalvm.buildtools</groupId>
                        <artifactId>native-maven-plugin</artifactId>
                        <version>${native-maven-plugin.version}</version>
                        <extensions>true</extensions>
                        <configuration>
                            <mainClass>${name-of-main-class}</mainClass>
                            <imageName>cypher-shell</imageName>
                            <buildArgs>
                                <buildArg>--no-fallback</buildArg>
                                <!--
                                 | Caused by
                                 | org.neo4j.collection.trackable.HeapTrackingCollections and
                                 | org.neo4j.cypher.internal.runtime.interpreted.commands.predicates.ConstantCachedIn
                                 | need some investigation
                                 -->
                                <buildArg>--allow-incomplete-classpath</buildArg>
                            </buildArgs>
                        </configuration>
                        <executions>
                            <execution>
                                <id>create-native-image</id>
                                <goals>
                                    <goal>build</goal>
                                </goals>
                                <phase>package</phase>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>compress-binary</id>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration combine.self="override">
                                    <executable>upx</executable>
                                    <skip>${skipCompress}</skip>
                                    <arguments>
                                        <argument>${project.build.directory}/cypher-shell${executable-suffix}</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>assembly-native</id>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <finalName>cypher-shell-${project.version}-${os.detected.classifier}</finalName>
                                    <attach>false</attach>
                                    <descriptors>
                                        <descriptor>src/main/assembly/assembly-native${assembly-suffix}.xml</descriptor>
                                    </descriptors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
