<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ /* ******************************************************************************
  ~  *
  ~  *
  ~  * This program and the accompanying materials are made available under the
  ~  * terms of the Apache License, Version 2.0 which is available at
  ~  * https://www.apache.org/licenses/LICENSE-2.0.
  ~  *
  ~  *  See the NOTICE file distributed with this work for additional
  ~  *  information regarding copyright ownership.
  ~  * Unless required by applicable law or agreed to in writing, software
  ~  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  ~  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  ~  * License for the specific language governing permissions and limitations
  ~  * under the License.
  ~  *
  ~  * SPDX-License-Identifier: Apache-2.0
  ~  ******************************************************************************/
  -->

<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns="http://maven.apache.org/POM/4.0.0"
    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>org.deeplearning4j</groupId>
        <artifactId>deeplearning4j</artifactId>
        <version>1.0.0-M1.1</version>
    </parent>

    <artifactId>rl4j</artifactId>
    <packaging>pom</packaging>

    <name>rl4j</name>
    <description>Deep Reinforcement Learning for the JVM</description>

    <modules>
        <module>rl4j-api</module>
        <module>rl4j-core</module>
        <module>rl4j-gym</module>
        <module>rl4j-doom</module>
        <module>rl4j-ale</module>
        <module>rl4j-malmo</module>
    </modules>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>ch.qos.logback</groupId>
                <artifactId>logback-core</artifactId>
                <version>${logback.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>
        <dependency>
            <groupId>org.junit.jupiter</groupId>
            <artifactId>junit-jupiter-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.junit.vintage</groupId>
            <artifactId>junit-vintage-engine</artifactId>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>test</phase>
                        <id>enforce-choice-of-nd4j-test-backend</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <skip>${skipBackendChoice}</skip>
                            <rules>
                                <requireActiveProfile>
                                    <profiles>nd4j-tests-cpu,nd4j-tests-cuda</profiles>
                                    <all>false</all>
                                </requireActiveProfile>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.lewisd</groupId>
                <artifactId>lint-maven-plugin</artifactId>
                <version>0.0.11</version>
                <configuration>
                    <failOnViolation>true</failOnViolation>
                    <onlyRunRules>
                        <rule>DuplicateDep</rule>
                        <rule>RedundantDepVersion</rule>
                        <rule>RedundantPluginVersion</rule>
                        <!-- Rules incompatible with Java 9
                        <rule>VersionProp</rule>
                        <rule>DotVersionProperty</rule> -->
                    </onlyRunRules>
                    <xmlOutputFile>${project.build.directory}/maven-lint-result.xml</xmlOutputFile>
                </configuration>
                <executions>
                    <execution>
                        <id>pom-lint</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
                <configuration>
                    <directories>
                        <directory>rl4j-api</directory>
                        <directory>rl4j-core</directory>
                        <directory>rl4j-gym</directory>
                        <directory>rl4j-doom</directory>
                        <directory>rl4j-ale</directory>
                        <directory>rl4j-malmo</directory>
                    </directories>
                </configuration>
            </plugin>
            <!-- Configuration for git-commit-id plugin - used with ND4J version check functionality -->
            <plugin>
                <groupId>pl.project13.maven</groupId>
                <artifactId>git-commit-id-plugin</artifactId>
            </plugin>
            <!-- Add generated git.properties files resource directory, for output of git-commit-id plugin -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <id>nd4j-tests-cpu</id>
            <dependencies>
                <dependency>
                    <groupId>org.nd4j</groupId>
                    <artifactId>nd4j-native</artifactId>
                    <version>${nd4j.version}</version>
                    <scope>test</scope>
                </dependency>
            </dependencies>
        </profile>
        <profile>
            <id>nd4j-tests-cuda</id>
            <properties>
                <!-- Note we put these properties here because the cuda modules themselves  have the cuda version tied to the artifact name. This allows us to use variables for the testing.  -->
                <cuda.version>11.0</cuda.version>
                <cudnn.version>8.0</cudnn.version>
                <javacpp-presets.cuda.version>1.5.4</javacpp-presets.cuda.version>
                <junit.jupiter.execution.parallel.enabled>false</junit.jupiter.execution.parallel.enabled>
                <junit.jupiter.execution.parallel.mode.default>same_thread</junit.jupiter.execution.parallel.mode.default>

            </properties>

            <dependencies>
                <dependency>
                    <groupId>org.nd4j</groupId>
                    <artifactId>nd4j-cuda-11.0</artifactId>
                    <version>${nd4j.version}</version>
                    <scope>test</scope>
                </dependency>

                <dependency>
                    <groupId>org.deeplearning4j</groupId>
                    <artifactId>deeplearning4j-cuda-11.0</artifactId>
                    <version>${project.version}</version>
                </dependency>

                <dependency>
                    <groupId>org.bytedeco</groupId>
                    <artifactId>cuda-platform-redist</artifactId>
                    <version>${cuda.version}-${cudnn.version}-${javacpp-presets.cuda.version}</version>
                    <scope>test</scope>
                </dependency>

            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <environmentVariables>
                                <CUDA_VISIBLE_DEVICES>0</CUDA_VISIBLE_DEVICES>
                            </environmentVariables>
                            <parallelMavenExecution>false</parallelMavenExecution>
                            <parallel>false</parallel>
                            <forkCount>0</forkCount>
                            <threadCount>1</threadCount>
                            <perCoreThreadCount>false</perCoreThreadCount>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
