<?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>
    <artifactId>audit-module</artifactId>
    <name>audit-module</name>
    <packaging>war</packaging>

    <parent>
        <groupId>fish.focus.uvms.audit</groupId>
        <artifactId>audit</artifactId>
        <version>4.3.12</version>
    </parent>

    <properties>
        <docker.dev.start.phase>test-compile</docker.dev.start.phase>
        <docker.liquibase.phase>test-compile</docker.liquibase.phase>
        <docker.dev.prestop.phase>validate</docker.dev.prestop.phase>
        <docker.dev.stop.phase>verify</docker.dev.stop.phase>
        <docker.liquibase.changeLogFile>../LIQUIBASE/changelog/db-changelog-master.xml</docker.liquibase.changeLogFile>
    </properties>

    <dependencies>
        <dependency>
            <groupId>fish.focus.uvms.maven</groupId>
            <artifactId>uvms-pom-gis-deps</artifactId>
            <type>pom</type>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>fish.focus.uvms.maven</groupId>
            <artifactId>uvms-pom-monitoring-deps</artifactId>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>fish.focus.uvms.audit</groupId>
            <artifactId>audit-model</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>fish.focus.uvms.lib</groupId>
            <artifactId>uvms-config</artifactId>
            <version>${uvms.config.version}</version>
        </dependency>
        <dependency>
            <groupId>fish.focus.uvms.commons</groupId>
            <artifactId>uvms-commons-message</artifactId>
        </dependency>
        <dependency>
            <groupId>fish.focus.uvms.commons</groupId>
            <artifactId>uvms-commons-date</artifactId>
        </dependency>
        <dependency>
            <groupId>fish.focus.uvms.lib</groupId>
            <artifactId>usm4uvms</artifactId>
            <version>${usm4uvms.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>fish.focus.uvms</groupId>
                    <artifactId>uvms-commons</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>fish.focus.uvms.maven</groupId>
            <artifactId>uvms-pom-arquillian-deps</artifactId>
            <type>pom</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.eclipse</groupId>
            <artifactId>yasson</artifactId>
            <version>2.0.4</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.name}-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <webResources>
                        <resource>
                            <directory>src/main/webapp</directory>
                            <filtering>true</filtering>
                        </resource>
                    </webResources>
                    <archive>
                        <manifestEntries>
                            <Logging-Profile>audit</Logging-Profile>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- USE following command to run this profile: mvn clean install -P wildfly-deploy wildfly:deploy -Dhostname=127.0.0.1 -Dport=9990 -Dusername=admin -Dpassword=asdf  -->
    <profiles>
        <profile>
            <id>wildfly-deploy</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.wildfly.plugins</groupId>
                        <artifactId>wildfly-maven-plugin</artifactId>
                        <version>2.1.0.Final</version>
                        <configuration>
                            <filename>${project.build.finalName}.${project.packaging}</filename>
                            <targetDir>${project.build.directory}</targetDir>
                            <hostname>${hostname}</hostname>
                            <port>${port}</port>
                            <username>${username}</username>
                            <password>${password}</password>
                            <force>true</force>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- USE following command to run this profile: mvn clean install -P generate-rest-doc -Dhostname=127.0.0.1 -Dport=8080  -->
        <profile>
            <id>generate-rest-doc</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>3.3.2</version>
                        <executions>
                            <execution>
                                <id>generate-service-docs</id>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <doclet>com.carma.swagger.doclet.ServiceDoclet</doclet>
                                    <docletArtifact>
                                        <groupId>com.carma</groupId>
                                        <artifactId>swagger-doclet</artifactId>
                                        <version>1.1.2</version>
                                    </docletArtifact>
                                    <reportOutputDirectory>src/main/webapp</reportOutputDirectory>
                                    <useStandardDocletOptions>false</useStandardDocletOptions>
                                    <additionalparam>
                                        -apiVersion ${project.version}
                                        -docBasePath /${project.parent.artifactId}/apidocs
                                        -apiBasePath /${project.parent.artifactId}/rest
                                    </additionalparam>
                                </configuration>
                                <goals>
                                    <goal>javadoc</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>com.google.code.maven-replacer-plugin</groupId>
                        <artifactId>replacer</artifactId>
                        <version>1.5.3</version>
                        <executions>
                            <execution>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>replace</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <file>rest/src/main/webapp/apidocs/index.html</file>
                            <replacements>
                                <replacement>
                                    <token>new ApiKeyAuthorization\("api_key", key, "query"\)</token>
                                    <value>new ApiKeyAuthorization("Authorization", key, "header")</value>
                                </replacement>
                            </replacements>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
