<?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>
    <groupId>studiorailgun</groupId>
    <artifactId>Renderer</artifactId>
    <version>0.1.1</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <lwjgl.version>3.3.3</lwjgl.version>
        <joml.version>1.9.19</joml.version>
        <recast.version>1.5.7</recast.version>
        <imgui.version>1.86.11</imgui.version>
        <graalvm.version>23.1.3</graalvm.version>
        <junit.version>5.10.3</junit.version>
    </properties>

    <!-- Used for build number plugin because it LITERALLY WONT LET YOU NOT HAVE SCM-->
    <scm>
        <connection>scm:svn:http://127.0.0.1/dummy</connection>
        <developerConnection>scm:svn:https://127.0.0.1/dummy</developerConnection>
        <tag>HEAD</tag>
        <url>http://127.0.0.1/dummy</url>
    </scm>

    <dependencies>
        <!-- generic LWJGL runtimes -->
        <!--License: BSD-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
            <scope>import</scope>
        </dependency>

        <!--ASSIMP-->
        <!--License: BSD-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-assimp</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-assimp</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>

        <!--GLFW-->
        <!--License: BSD-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-glfw</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-glfw</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>

        <!--OpenGL-->
        <!--License: BSD-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-opengl</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-opengl</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>

        <!--OpenAL-->
        <!--License: BSD-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-openal</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-openal</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>

        <!--STB-->
        <!--License: BSD-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-stb</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-stb</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>

        <!--Remotery-->
        <!--License: Apache 2.0-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-remotery</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-remotery</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>

        <!--par_shapes-->
        <!--License: MIT-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-par</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-par</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>
        
        <!--JOML-->
        <!--License: MIT-->
        <dependency>
            <groupId>org.joml</groupId>
            <artifactId>joml</artifactId>
            <version>${joml.version}</version>
        </dependency>

        <!--GSON-->
        <!--License: Apache-->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.6</version>
        </dependency>

        <!--Ode4J-->
        <!--License: Dual LGPL 2.1 OR BSD 3-clause-->
        <!--https://github.com/tzaeschke/ode4j -->
        <dependency>
            <groupId>org.ode4j</groupId>
            <artifactId>core</artifactId>
            <version>0.5.3</version>
        </dependency>

        <!--SQLITE-JDBC-->
        <!--License: Apache-->
        <!-- https://mvnrepository.com/artifact/org.xerial/sqlite-jdbc -->
        <dependency>
            <groupId>org.xerial</groupId>
            <artifactId>sqlite-jdbc</artifactId>
            <version>3.36.0.3</version>
        </dependency>

        <!--JUnit-->
        <!--License: Eclipse Public License-->
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter</artifactId>
            <version>${junit.version}</version>
        </dependency>

        <!--Mockito-->
        <!--License: MIT-->
        <!-- https://mvnrepository.com/artifact/org.mockito/mockito-core -->
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>5.12.0</version>
            <scope>test</scope>
        </dependency>


        <!--GraalVM-->
        <!--License: GPLv2 w/ classpath exception-->
        <!--apparently maybe classpath exception allows use in eg game engine??-->
        <!-- https://mvnrepository.com/artifact/org.graalvm.js/js-scriptengine -->
        <dependency>
            <groupId>org.graalvm.js</groupId>
            <artifactId>js-scriptengine</artifactId>
            <version>${graalvm.version}</version>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.graalvm.polyglot/js-community -->
        <dependency>
            <groupId>org.graalvm.polyglot</groupId>
            <artifactId>js-community</artifactId>
            <version>${graalvm.version}</version>
            <type>pom</type>
            <scope>runtime</scope>
        </dependency>


        <!--steamworks4j-->
        <!--License: MIT-->
        <!-- https://mvnrepository.com/artifact/com.code-disaster.steamworks4j/steamworks4j -->
        <dependency>
            <groupId>com.code-disaster.steamworks4j</groupId>
            <artifactId>steamworks4j</artifactId>
            <version>1.9.0</version>
        </dependency>

        <!--recast4j-->
        <!--License: zlib-->
        <!-- https://mvnrepository.com/artifact/org.recast4j/recast -->
        <dependency>
            <groupId>org.recast4j</groupId>
            <artifactId>recast</artifactId>
            <version>${recast.version}</version>
        </dependency>
        <dependency>
            <groupId>org.recast4j</groupId>
            <artifactId>detour</artifactId>
            <version>${recast.version}</version>
        </dependency>
        <dependency>
            <groupId>org.recast4j</groupId>
            <artifactId>detour-crowd</artifactId>
            <version>${recast.version}</version>
        </dependency>
        <dependency>
            <groupId>org.recast4j</groupId>
            <artifactId>detour-tile-cache</artifactId>
            <version>${recast.version}</version>
        </dependency>
        <dependency>
            <groupId>org.recast4j</groupId>
            <artifactId>detour-extras</artifactId>
            <version>${recast.version}</version>
        </dependency>
        <dependency>
            <groupId>org.recast4j</groupId>
            <artifactId>detour-dynamic</artifactId>
            <version>${recast.version}</version>
        </dependency>


        <!--imgui-->
        <!--License: MIT-->
        <!---->
        <dependency>
            <groupId>io.github.spair</groupId>
            <artifactId>imgui-java-binding</artifactId>
            <version>${imgui.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.spair</groupId>
            <artifactId>imgui-java-lwjgl3</artifactId>
            <version>${imgui.version}</version>
        </dependency>
        <dependency>
            <groupId>io.github.spair</groupId>
            <artifactId>imgui-java-natives-windows</artifactId>
            <version>${imgui.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>io.github.spair</groupId>
            <artifactId>imgui-java-natives-linux</artifactId>
            <version>${imgui.version}</version>
            <scope>runtime</scope>
        </dependency>

        <!--Yoga-->
        <!--License: MIT-->
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-yoga</artifactId>
            <version>${lwjgl.version}</version>
        </dependency>
        <dependency>
            <groupId>org.lwjgl</groupId>
            <artifactId>lwjgl-yoga</artifactId>
            <version>${lwjgl.version}</version>
            <classifier>${lwjgl.natives}</classifier>
        </dependency>

        <!--MathUtils-->
        <!--License: MIT-->
        <dependency>
            <groupId>io.github.studiorailgun</groupId>
            <artifactId>MathUtils</artifactId>
            <version>1.4.0</version>
        </dependency>

        <!--DataStructures-->
        <!--License: MIT-->
        <dependency>
            <groupId>io.github.studiorailgun</groupId>
            <artifactId>DataStructures</artifactId>
            <version>1.1.0</version>
        </dependency>


    </dependencies>

    <profiles>

        <!--          LINUX                 -->
        <profile>
            <id>lwjgl-natives-linux</id>
            <activation>
                <os>
                    <family>unix</family>
                </os>
            </activation>
            <properties>
                <lwjgl.natives>natives-linux</lwjgl.natives>

                <!--The tests to run-->
                <groups>fast</groups>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <!--  Download Typescript -->
                            <execution>
                                <id>Download Typescript</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>${basedir}/assets/Scripts/compiler/get_typescript.sh</executable>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>








        <!--         WINDOWS            -->
        <profile>
            <id>lwjgl-natives-windows</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <lwjgl.natives>natives-windows</lwjgl.natives>

                <!--The tests to run-->
                <groups>fast</groups>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>exec-maven-plugin</artifactId>
                        <version>3.0.0</version>
                        <executions>
                            <!--  Download Typescript -->
                            <execution>
                                <id>Download Typescript</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>powershell.exe</executable>
                                    <arguments>
                                        <argument>-InputFormat</argument>
                                        <argument>None</argument>
                                        <argument>-File</argument>
                                        <argument>${basedir}/assets/scripts/compiler/get_typescript.ps1</argument>
                                    </arguments>
                                </configuration>
                            </execution>
                            <!--  Run NetArranger -->
                            <execution>
                                <id>Run NetArranger</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>exec</goal>
                                </goals>
                                <configuration>
                                    <executable>java.exe</executable>
                                    <arguments>
                                        <argument>-jar</argument>
                                        <argument>NetArranger.jar</argument>
                                    </arguments>
                                    <successCodes>
                                        <successCode>0</successCode>
                                        <successCode>1</successCode>
                                    </successCodes>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>



        <!--          INTEGRATION TESTING                 -->
        <!-- To execute this profile, run a command like "mvn test -P integration" -->
        <profile>
            <id>integration</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.22.2</version>
                        <configuration>
                            <!--If you want the logs to throw exceptions on opengl errors, remove the "n" after .jar=t-->
                            <argLine>-javaagent:./lwjglx-debug-1.0.0.jar=t;o=trace.log</argLine>
                            <forkCount>0</forkCount>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <!--The tests to run-->
                <groups>fast,unit,integration</groups>
            </properties>
        </profile>

        <!--          INTEGRATION TESTING DEBUG                 -->
        <!-- To execute this profile, run a command like "mvn test -P integration,integrationDebug" -->
        <profile>
            <id>integrationDebug</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.22.2</version>
                        <configuration>
                            <!--If you want the logs to throw exceptions on opengl errors, remove the "n" after .jar=t-->
                            <argLine>-javaagent:./lwjglx-debug-1.0.0.jar=t;o=trace.log</argLine>
                            <forkCount>0</forkCount>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
            <properties>
                <!--The tests to run-->
                <groups>fast,unit,integration</groups>
            </properties>
        </profile>



    </profiles>







    <!--             MAIN      BUILD             -->
    <build>
        <plugins>

            <!--Shade the jar (pack all dependencies)-->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>3.2.4</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <transformers>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>electrosphere.engine.Main</mainClass>
                                </transformer>
                                <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer">
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!--  Generate JNI Headers  -->
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.11.0</version>
                <configuration>
                    <compilerArgs>
                        <arg>-h</arg>
                        <arg>src/main/c/includes/native</arg>
                    </compilerArgs>
                </configuration>
            </plugin>


            <!--Exec build tools-->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.0.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>java</executable>
                            <includeProjectDependencies>false</includeProjectDependencies>
                            <includePluginDependencies>true</includePluginDependencies>
                            <mainClass>electrosphere.engine.Main</mainClass>
                            <arguments>
                                <argument>-cp</argument>
                                <argument>target/classes;target/Renderer-${version}-jar-with-dependencies.jar</argument>
                                <argument>electrosphere.engine.Main</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <!--  Build Fluid Lib -->
                    <execution>
                        <id>build-fluid-lib</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                        <configuration>
                            <executable>bash</executable>
                            <environmentVariables>
                                <SAVE_STEPS>0</SAVE_STEPS>
                            </environmentVariables>
                            <arguments>
                                <argument>./src/main/c/build.sh</argument>
                            </arguments>
                        </configuration>
                    </execution>
                </executions>
            </plugin>


            <!--Incrementing (local) build numbers-->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>buildnumber-maven-plugin</artifactId>
                <version>1.4</version>
                <executions>
                    <execution>
                        <id>buildnumber</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>create</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <format>{0,number}</format>
                    <items>
                        <item>buildNumber</item>
                    </items>                    
                    <doCheck>false</doCheck>
                    <doUpdate>false</doUpdate>
                    <revisionOnScmFailure>unknownbuild</revisionOnScmFailure>   
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>