<?xml version="1.0" encoding="UTF-8"?>
<!-- ~ Developed with the contribution of the European Commission - Directorate 
General for Maritime Affairs and Fisheries ~ © European Union, 2015-2016. 
~ ~ This file is part of the Integrated Fisheries Data Management (IFDM) 
Suite. The IFDM Suite is free software: you can ~ redistribute it and/or 
modify it under the terms of the GNU General Public License as published 
by the ~ Free Software Foundation, either version 3 of the License, or any 
later version. The IFDM Suite is distributed in ~ the hope that it will be 
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
or ~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
for more details. You should have received a ~ copy of the GNU General Public 
License along with the IFDM Suite. If not, see <http://www.gnu.org/licenses />. -->
<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>
    <parent>
        <groupId>fish.focus.maven</groupId>
        <artifactId>focus-pom</artifactId>
        <version>2.5</version>
        <relativePath />
    </parent>
    
    <groupId>fish.focus.uvms.maven</groupId>
    <artifactId>uvms-pom</artifactId>
    <version>3.16</version>
    <packaging>pom</packaging>
      
    <!-- ================================================================ -->
    <!-- Project specific settings, should be redefined in project's POMs -->
    <!-- ================================================================ -->
    <url>${focus-pom.public.base.site.url}/${project.artifactId}</url>
    <scm>
        <connection>${scm.connection}</connection>
        <tag>HEAD</tag>
    </scm>
    <!-- ================================================================ -->
    <!-- End Project specific settings                                    -->
    <!-- ================================================================ -->
    

    <properties>
                
        <!-- ================= -->
        <!-- Global Properties -->
        <!-- ================= -->
        <context.root>unionvms/</context.root>
        
        <!-- Maven default properties -->
        <project.scm.id>github</project.scm.id>
        <scm.connection>scm:git:https://github.com/FocusFish/uvms-pom.git</scm.connection>
        <scm.url>scm:git:https://github.com/FocusFish/uvms-pom.git</scm.url>
        
        
        <!-- =================================================== -->
        <!-- Common project dependency manage version properties -->
        <!-- =================================================== -->
        
        <!--Depmanagement -->
        <uvms-pom.jakartaee.version>8.0.0</uvms-pom.jakartaee.version>
        <uvms-pom.microprofile.version>4.0.1</uvms-pom.microprofile.version>
        <uvms-pom.slf4j.version>1.7.30</uvms-pom.slf4j.version>
        <uvms-pom.commons.collections>3.2.2</uvms-pom.commons.collections>
        <uvms-pom.commons.lang.version>2.6</uvms-pom.commons.lang.version>
        <uvms-pom.commons.lang3.version>3.9</uvms-pom.commons.lang3.version>
        
        <!-- ======= -->
        <!-- Plugins -->        
        <!-- ======= -->
        
        <!-- ======================= -->
        <!-- Default docker settings -->        
        <!-- ======================= -->
        <docker.dev.version>4.1.0</docker.dev.version>
        <docker.dev.start.phase>none</docker.dev.start.phase>
        <docker.dev.stop.phase>none</docker.dev.stop.phase>
        <docker.dev.prestop.phase>none</docker.dev.prestop.phase>
        <docker.liquibase.phase>none</docker.liquibase.phase>
        <docker.liquibase.changeLogFile>PATH_TO_CHANGELOGFILE</docker.liquibase.changeLogFile>
        <docker.liquibase.db.url>jdbc:postgresql://localhost:15432/db71u</docker.liquibase.db.url>
        <docker.liquibase.db.user>SET_ME</docker.liquibase.db.user>
        <docker.liquibase.db.passwd>SET_ME</docker.liquibase.db.passwd>
    </properties>
     
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>jakarta.platform</groupId>
                <artifactId>jakarta.jakartaee-api</artifactId>
                <version>${uvms-pom.jakartaee.version}</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>org.eclipse.microprofile</groupId>
                <artifactId>microprofile</artifactId>
                <version>${uvms-pom.microprofile.version}</version>
                <type>pom</type>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>${uvms-pom.commons.collections}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>${uvms-pom.commons.lang3.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-lang</groupId>
                <artifactId>commons-lang</artifactId>
                <version>${uvms-pom.commons.lang.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>
    
    <dependencies>
        <!-- Include default logging dependencies -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${uvms-pom.slf4j.version}</version>
            <scope>provided</scope>
        </dependency>
        <!-- Include default test dependencies (scope applies to all deps in the dependecy..)-->
        <dependency>
            <groupId>fish.focus.uvms.maven</groupId>
            <artifactId>uvms-pom-test-deps</artifactId>
            <version>3.16</version>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
    </dependencies>
   
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-site-plugin</artifactId>
                <executions>
                    <execution>
                        <inherited>false</inherited>
                        <id>attach-descriptor</id>
                        <goals>
                            <goal>attach-descriptor</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>        
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>docker</id>
            <properties>
                <driver.groupId>org.postgresql</driver.groupId>
                <driver.artifactId>postgresql</driver.artifactId>
                <driver.version>42.3.1</driver.version>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>${driver.groupId}</groupId>
                    <artifactId>${driver.artifactId}</artifactId>
                    <version>${driver.version}</version>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>io.fabric8</groupId>
                        <artifactId>docker-maven-plugin</artifactId>
                        <version>0.38.0</version>
                        <executions>
                            <execution>
                                <id>verifyallstopped</id>
                                <phase>${docker.dev.prestop.phase}</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                                <configuration>
                                    <allContainers>true</allContainers>
                                </configuration>
                            </execution>
                            <execution>
                                <id>start</id>
                                <phase>${docker.dev.start.phase}</phase>
                                <goals>
                                    <goal>start</goal>
                                </goals>
                            </execution>
                            <execution>
                                <id>stop</id>
                                <phase>${docker.dev.stop.phase}</phase>
                                <goals>
                                    <goal>stop</goal>
                                </goals>
                                <configuration>
                                    <allContainers>true</allContainers>
                                </configuration>
                            </execution>
                        </executions>
                        <configuration>
                            <images>
                                <image>
                                    <alias>postgres</alias>
                                    <name>uvms/postgres-release:${docker.dev.version}</name>
                                    <run>
                                        <net>bridge</net>
                                        <namingStrategy>none</namingStrategy>
                                        <ports>
                                            <port>15432:5432</port>
                                        </ports>
                                        <log>
                                            <enabled>true</enabled>
                                            <color>green</color>
                                        </log>
                                        <hostname>postgres</hostname>
                                    </run>
                                </image>
                                <image>
                                    <alias>wildfly</alias>
                                    <name>uvms/wildfly-base:${docker.dev.version}</name>
                                    <run>
                                        <net>bridge</net>
                                        <namingStrategy>none</namingStrategy>
                                        <links>
                                            <link>postgres:postgres</link>
                                        </links>
                                        <ports>
                                            <port>9990:9990</port>
                                            <port>28787:8787</port>
                                            <port>28080:8080</port>
                                            <port>28443:8443</port>
                                            <port>5445:5445</port>
                                            <port>5455:5455</port>
                                        </ports>
                                        <wait>
                                            <http>
                                               <url>http://localhost:28080</url>
                                               <method>GET</method>
                                               <status>200</status>
                                            </http>
                                            <time>300000</time>
                                            <kill>5000</kill>
                                            <shutdown>5000</shutdown>
                                        </wait>
                                        <cmd>
                                            <shell>/opt/jboss/start.sh /opt/jboss/wildfly/bin/standalone.sh -c standalone-full.xml -b 0.0.0.0 -bmanagement 0.0.0.0 --debug *:8787</shell>
                                        </cmd>
                                        <dependsOn>
                                            <container>postgres</container>
                                        </dependsOn>
                                        <log>
                                            <enabled>true</enabled>
                                            <color>blue</color>
                                        </log>
                                        <hostname>wildfly</hostname>
                                    </run>
                                </image>
                            </images>
                        </configuration>
                    </plugin>
                    <plugin>
                        <groupId>org.liquibase</groupId>
                        <artifactId>liquibase-maven-plugin</artifactId>
                        <version>4.6.2</version>
                        <configuration>
                            <changeLogFile>${docker.liquibase.changeLogFile}</changeLogFile>
                            <url>${docker.liquibase.db.url}</url>
                            <username>${docker.liquibase.db.user}</username>
                            <password>${docker.liquibase.db.passwd}</password>
                        </configuration>
                        <executions>
                            <execution>
                                <phase>${docker.liquibase.phase}</phase>                                                                  
                                <goals>
                                    <goal>update</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>docker-start</id>
            <properties>
                <docker.dev.start.phase>validate</docker.dev.start.phase>
                <docker.dev.stop.phase>none</docker.dev.stop.phase>
                <docker.dev.prestop.phase>none</docker.dev.prestop.phase>
            </properties>
        </profile>
        <profile>
            <id>docker-stop</id>
            <properties>
                <docker.dev.start.phase>none</docker.dev.start.phase>
                <docker.dev.stop.phase>validate</docker.dev.stop.phase>
                <docker.dev.prestop.phase>validate</docker.dev.prestop.phase>
            </properties>
        </profile>
        <profile>
            <id>liquibase</id>
            <properties>
                <docker.liquibase.phase>validate</docker.liquibase.phase>
            </properties>
        </profile>
    </profiles>
</project>