<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>user-rest</artifactId>
    <name>${project.parent.artifactId}-rest</name>
    <packaging>war</packaging>

    <parent>
        <groupId>fish.focus.uvms.user</groupId>
        <artifactId>user</artifactId>
        <version>2.2.6</version>
    </parent>

    <dependencies>
        <!-- EJB DEPENDENCIES -->
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>user-model</artifactId>
            <version>${project.parent.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>user-service</artifactId>
            <version>${project.parent.version}</version>
            <scope>provided</scope>
            <exclusions>
            	<exclusion>
            		<groupId>com.sun.xml.bind</groupId>
    				<artifactId>jaxb-impl</artifactId>            		
            	</exclusion>
            </exclusions>
        </dependency>
        <dependency>
			<groupId>fish.focus.uvms.maven</groupId>
			<artifactId>uvms-pom-monitoring-deps</artifactId>
			<type>pom</type>
		</dependency>
        <dependency>
            <groupId>fish.focus.uvms.commons</groupId>
            <artifactId>uvms-commons-date</artifactId>
            <version>${uvms.commons.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.12.0</version>
        </dependency>
		<dependency>
			<groupId>fish.focus.uvms.maven</groupId>
			<artifactId>uvms-pom-arquillian-deps</artifactId>
			<type>pom</type>
			<scope>test</scope>
		</dependency>				                
    </dependencies>

    <build>
        <finalName>${project.name}-${project.parent.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <!-- USE following command to run this profile: mvn clean install -P generate-rest-doc -Dhostname=127.0.0.1 -Dport=8080  -->
    <profiles>
        <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>
                                        <additionalparam>
                                            -apiVersion ${project.version}
                                            -docBasePath /${project.parent.artifactId}/apidocs
                                            -apiBasePath /${project.parent.artifactId}/rest
                                        </additionalparam>
                                    </docletArtifact>
                                    <reportOutputDirectory>src/main/webapp</reportOutputDirectory>
                                    <useStandardDocletOptions>false</useStandardDocletOptions>
                                </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>
