<?xml version="1.0" encoding="UTF-8"?>
<!--
  ~ Version: 1.0
  ~
  ~ The contents of this file are subject to the OpenVPMS License Version
  ~ 1.0 (the 'License'); you may not use this file except in compliance with
  ~ the License. You may obtain a copy of the License at
  ~ http://www.openvpms.org/license/
  ~
  ~ Software distributed under the License is distributed on an 'AS IS' basis,
  ~ WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  ~ for the specific language governing rights and limitations under the
  ~ License.
  ~
  ~ Copyright 2024 (C) OpenVPMS Ltd. All Rights Reserved.
  -->

<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">
    <parent>
        <artifactId>openvpms-web</artifactId>
        <groupId>org.openvpms</groupId>
        <version>2.4.0.14-beta-2</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>openvpms-web-app</artifactId>
    <packaging>war</packaging>

    <name>OpenVPMS Web App</name>

    <!-- ========================================================================== -->
    <!-- Deployment notes                                                           -->
    <!-- . rapid deployment can be done via jetty using                             -->
    <!--   mvn jetty:run                                                            -->
    <!-- . deployment via Tomcat 8 can be done using                                -->
    <!--   mvn package cargo:run                                                    -->
    <!-- ========================================================================== -->

    <!-- ========================================================================== -->
    <!-- Debugging notes:                                                           -->
    <!-- . p6spy can be enabled using:                                              -->
    <!--   mvn -Ddb.driver=com.p6spy.engine.spy.P6SpyDriver \                       -->
    <!--       -Ddb.url=jdbc:p6spy:mysql://localhost:3306/openvpms_dev jetty:run    -->
    <!-- ========================================================================== -->

    <build>
        <finalName>openvpms</finalName>
        <resources>
            <resource>
                <directory>${basedir}/src/conf/log4j</directory>
                <includes>
                    <include>log4j2.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>${basedir}/src/conf</directory>
                <includes>
                    <include>openvpms.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>${basedir}/src/conf/smartflow</directory>
                <includes>
                    <include>smartflow.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>${basedir}/src/conf/p6spy</directory>
                <includes>
                    <include>**/*.properties</include>
                </includes>
            </resource>
            <resource>
                <directory>${basedir}/src/conf/ehcache</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
            </resource>
            <resource>
                <directory>${basedir}/src/conf</directory>
                <includes>
                    <include>localisation/**</include>
                </includes>
                <excludes>
                    <exclude>**/help.properties</exclude>
                </excludes>
            </resource>
            <resource>
                <directory>${basedir}/src/conf</directory>
                <includes>
                    <include>localisation/help.properties</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>${basedir}/src/conf</directory>
                <includes>
                    <include>style/**</include>
                </includes>
            </resource>
            <resource>
                <directory>${basedir}/src/main/resources</directory>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <!-- extracts the messages*.properties files from openvpms-web-component to a staging area -->
                                    <groupId>org.openvpms</groupId>
                                    <artifactId>openvpms-web-component</artifactId>
                                    <version>${project.version}</version>
                                    <type>jar</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/localisation</outputDirectory>
                                    <includes>**/messages*.properties</includes>
                                </artifactItem>
                                <artifactItem>
                                    <!-- unpacks plugin support to /WEB-INF/plugins -->
                                    <groupId>org.openvpms</groupId>
                                    <artifactId>openvpms-plugin-framework-bundles</artifactId>
                                    <version>${project.version}</version>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}/webapp/WEB-INF/plugins</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <!-- unpacks webstart support to /webstart -->
                                    <groupId>org.openvpms</groupId>
                                    <artifactId>openvpms-webdav-launcher-package</artifactId>
                                    <version>${webdav.launcher.version}</version>
                                    <type>war</type>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${project.build.directory}/webapp/webstart</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- copies the messages*.properties files to classes/localisation -->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/classes/localisation</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/target/localisation/org/openvpms/web/resource/localisation/
                                    </directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <!-- copy webapp for tomcat plugin -->
                        <id>webapp</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${basedir}/target/webapp</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${basedir}/src/webapp/</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <warSourceDirectory>
                        ${basedir}/src/webapp
                    </warSourceDirectory>
                    <archive>
                        <addMavenDescriptor>false</addMavenDescriptor>
                    </archive>
                    <webResources>
                        <webResource>
                            <directory>${project.build.directory}/webapp/WEB-INF/plugins</directory>
                            <targetPath>WEB-INF/plugins</targetPath>
                        </webResource>
                    </webResources>
                    <overlays>
                        <overlay>
                            <groupId>org.openvpms</groupId>
                            <artifactId>openvpms-webdav-launcher-package</artifactId>
                            <targetPath>webstart</targetPath>
                        </overlay>
                    </overlays>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-source-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.tomcat.maven</groupId>
                <artifactId>tomcat7-maven-plugin</artifactId>
                <version>2.2</version>
                <configuration>
                    <server>openvpms-tomcat</server>
                    <!--port>${maven.tomcat.port}</port-->
                    <path>/${project.build.finalName}</path>
                    <warSourceDirectory>${basedir}/target/webapp</warSourceDirectory>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>${jdbc.groupId}</groupId>
                        <artifactId>${jdbc.artifactId}</artifactId>
                        <version>${jdbc.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>org.codehaus.cargo</groupId>
                <artifactId>cargo-maven2-plugin</artifactId>
                <version>1.6.4</version>
                <configuration>
                    <container>
                        <containerId>tomcat8x</containerId>
                        <artifactInstaller>
                            <groupId>org.apache.tomcat</groupId>
                            <artifactId>tomcat</artifactId>
                            <version>${tomcat.version}</version>
                        </artifactInstaller>
                    </container>
                    <deployables>
                        <deployable>
                            <groupId>${project.groupId}</groupId>
                            <artifactId>${project.artifactId}</artifactId>
                            <type>war</type>
                            <properties>
                                <context>/openvpms</context>
                            </properties>
                        </deployable>
                    </deployables>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>${jetty.version}</version>
                <configuration>
                    <webApp>
                        <descriptor>${basedir}/src/webapp/WEB-INF/web.xml</descriptor>
                        <contextPath>/openvpms</contextPath>
                        <resourceBases>
                            <resourceBase>src/webapp</resourceBase>
                            <resourceBase>${project.build.directory}/webapp</resourceBase>
                        </resourceBases>
                    </webApp>
                    <useTestScope>true</useTestScope>
                    <useTestClasspath>true</useTestClasspath>
                    <httpConnector>
                        <port>${jetty.port}</port>
                    </httpConnector>
                    <stopPort>9091</stopPort>
                    <stopKey>stop</stopKey>
                    <systemProperties>
                        <systemProperty>
                            <name>catalina.base</name>
                            <value>${project.build.directory}/tmp</value>
                        </systemProperty>
                    </systemProperties>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>${jdbc.groupId}</groupId>
                        <artifactId>${jdbc.artifactId}</artifactId>
                        <version>${jdbc.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>
    <dependencies>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-billing-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-laboratory-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-plugin-manager-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-plugin-services-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-web-security</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-web-workspaces</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-web-jobs</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-webdav</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-webdav-launcher-package</artifactId>
            <version>${webdav.launcher.version}</version>
            <type>war</type>
            <scope>provided</scope>
            <!-- copied to the webstart dir -->
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-db</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-booking-service</artifactId>
        </dependency>
        <dependency>
            <groupId>org.openvpms</groupId>
            <artifactId>openvpms-sms-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-slf4j-impl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>webstart-jnlp-servlet</artifactId>
            <version>1.0-beta-6</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
            <scope>runtime</scope>
        </dependency>
    </dependencies>

    <properties>
        <tomcat.version>8.0.45</tomcat.version>
        <jetty.port>8080</jetty.port>
        <jetty.sslport>8443</jetty.sslport>
    </properties>

</project>