<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Copyright French Prime minister Office/SGMAP/DINSIC/Vitam Program (2015-2021)
  ~
  ~ contact.vitam@culture.gouv.fr
  ~
  ~ This software is a computer program whose purpose is to implement a digital archiving back-office system managing
  ~ high volumetry securely and efficiently.
  ~
  ~ This software is governed by the CeCILL 2.1 license under French law and abiding by the rules of distribution of free
  ~ software. You can use, modify and/ or redistribute the software under the terms of the CeCILL 2.1 license as
  ~ circulated by CEA, CNRS and INRIA at the following URL "https://cecill.info".
  ~
  ~ As a counterpart to the access to the source code and rights to copy, modify and redistribute granted by the license,
  ~ users are provided only with a limited warranty and the software's author, the holder of the economic rights, and the
  ~ successive licensors have only limited liability.
  ~
  ~ In this respect, the user's attention is drawn to the risks associated with loading, using, modifying and/or
  ~ developing or reproducing the software by the user in light of its specific status of free software, that may mean
  ~ that it is complicated to manipulate, and that also therefore means that it is reserved for developers and
  ~ experienced professionals having in-depth computer knowledge. Users are therefore encouraged to load and test the
  ~ software's suitability as regards their requirements in conditions enabling the security of their systems and/or data
  ~ to be ensured and, more generally, to use and operate it in the same conditions as regards security.
  ~
  ~ The fact that you are presently reading this means that you have had knowledge of the CeCILL 2.1 license and that you
  ~ accept its terms.
  -->

<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">
    <parent>
        <artifactId>scheduler</artifactId>
        <groupId>fr.gouv.vitam</groupId>
        <version>8.0.3</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>scheduler-server</artifactId>


    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <unix.name>scheduler</unix.name>
        <unix.user>vitam</unix.user>
        <unix.group>vitam</unix.group>
        <jib.skip>true</jib.skip>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.flywaydb</groupId>
            <artifactId>flyway-database-postgresql</artifactId>
        </dependency>
        <dependency>
            <groupId>com.zaxxer</groupId>
            <artifactId>HikariCP</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.transaction</groupId>
            <artifactId>jta</artifactId>
        </dependency>

        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>internal-security-client</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>metadata-client</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>logbook-operations-client</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>functional-administration-client</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>storage-engine-client</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>processing-management-client</artifactId>
            <version>${project.version}</version>
        </dependency>

        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>common-private</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>common-security</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>common-junit</artifactId>
            <version>${project.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>fr.gouv.vitam</groupId>
            <artifactId>common-database-public</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>


    <build>
        <plugins>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>3.0</version>
                <configuration>
                    <header>../../licenses/cecill21.txt</header>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>check</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>jib-maven-plugin</artifactId>
                <configuration>
                    <to>
                        <image>${env.SERVICE_DOCKER_PUSH_URL}/vitam/scheduler</image>
                        <tags>
                            <tag>${git.commit.id.describe-short}</tag>
                            <tag>${project.version}</tag>
                        </tags>
                    </to>
                </configuration>
            </plugin>
            <plugin>
                <!-- Dependency manipulation (copy, unpack) and analysis. -->
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-dependencies</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-dependencies</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/dependencies</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>false</overWriteSnapshots>
                            <overWriteIfNewer>true</overWriteIfNewer>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-config-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/conf/sysconfig</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/main/conf</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <!-- Debian -->
                    <execution>
                        <id>copy-debian-controlFiles</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/control</outputDirectory>
                            <overwrite>true</overwrite>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/deb/control</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-script-resources</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/script</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/main/script</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>

                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addClasspath>true</addClasspath>
                            <mainClass>fr.gouv.vitam.scheduler.server.SchedulerMain</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>rpm-maven-plugin</artifactId>
                <configuration>
                    <disabled>false</disabled>
                    <license>CeCILL 2.1</license>
                    <distribution>Vitam Project</distribution>
                    <group>Application/Archiving</group>
                    <packager>Vitam Package Team</packager>
                    <defineStatements/>
                    <targetOS>linux</targetOS>
                    <requires>
                        <require>systemd</require>
                        <require>${jdk.version.rpm}</require>
                        <require>vitam-user-${unix.user}</require>
                    </requires>
                    <defaultDirmode>750</defaultDirmode>
                    <defaultFilemode>640</defaultFilemode>
                    <defaultUsername>${unix.user}</defaultUsername>
                    <defaultGroupname>${unix.group}</defaultGroupname>
                    <mappings>
                        <mapping>
                            <directory>/vitam/lib/${unix.name}</directory>
                            <artifact/>
                            <dependency/>
                        </mapping>
                        <mapping>
                            <directory>/vitam/conf/${unix.name}</directory>
                            <sources>
                                <source>
                                    <location>${project.build.directory}/conf</location>
                                </source>
                            </sources>
                        </mapping>
                    </mappings>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.version}</version>
            </plugin>

            <plugin>
                <artifactId>jdeb</artifactId>
                <groupId>org.vafer</groupId>
                <configuration>
                    <snapshotExpand>true</snapshotExpand>
                    <skip>false</skip>
                    <controlDir>${project.build.directory}/control</controlDir>
                    <dataSet>

                        <!-- Artifacts -->
                        <data>
                            <src>${project.build.directory}/${project.build.finalName}.jar</src>
                            <type>file</type>
                            <mapper>
                                <type>perm</type>
                                <user>${unix.user}</user>
                                <group>${unix.group}</group>
                                <filemode>0644</filemode>
                                <prefix>/vitam/lib/${unix.name}/</prefix>
                            </mapper>
                        </data>

                        <data>
                            <src>${project.build.directory}/dependencies</src>
                            <type>directory</type>
                            <missingSrc>ignore</missingSrc>
                            <mapper>
                                <type>perm</type>
                                <user>${unix.user}</user>
                                <group>${unix.group}</group>
                                <filemode>0644</filemode>
                                <prefix>/vitam/lib/${unix.name}</prefix>
                            </mapper>
                        </data>
                        <data>
                            <src>${project.build.directory}/conf</src>
                            <type>directory</type>
                            <missingSrc>ignore</missingSrc>
                            <mapper>
                                <type>perm</type>
                                <user>${unix.user}</user>
                                <group>${unix.group}</group>
                                <filemode>0750</filemode>
                                <prefix>/vitam/conf/${unix.name}</prefix>
                            </mapper>
                        </data>

                        <!-- Additional templates -->
                        <data>
                            <type>template</type>
                            <paths>
                                <path>/vitam/tmp/${unix.name}</path>
                                <path>/vitam/log/${unix.name}</path>
                            </paths>
                            <mapper>
                                <type>perm</type>
                                <user>${unix.user}</user>
                                <group>${unix.group}</group>
                            </mapper>
                        </data>

                    </dataSet>
                </configuration>
            </plugin>

        </plugins>
    </build>
</project>
