<?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>
    <groupId>org.eurekaclinical</groupId>
    <artifactId>eurekaclinical-parent</artifactId>
    <version>3</version>
    <packaging>pom</packaging>
    <name>Eureka! Clinical Parent</name>
    <description>Parent pom.xml for all Eureka! Clinical projects.</description>
    <inceptionYear>2015</inceptionYear>
    <url>https://github.com/eurekaclinical/eurekaclinical-parent.git</url>
    
    <licenses>
        <license>
            <name>Apache License, Version 2.0</name>
            <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
            <distribution>repo</distribution>
        </license>
    </licenses>
    
    <properties>
        <eurekaclinical.stage>DEVELOPMENT</eurekaclinical.stage>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <liquibase-version>3.4.2</liquibase-version>
        <!-- Don't upgrade h2 yet. There is a bug causing ORDER BY to be 
        ignored in SELECT queries with a WHERE clause. -->
        <h2-version>1.4.193</h2-version>
    </properties>
    
    <organization>
        <name>Emory University</name>
        <url>http://www.emory.edu</url>
    </organization>
    
    <scm>
        <connection>scm:git:https://github.com/eurekaclinical/eurekaclinical-parent.git</connection>
        <developerConnection>scm:git:https://github.com/eurekaclinical/eurekaclinical-parent.git</developerConnection>
        <url>https://github.com/eurekaclinical/eurekaclinical-parent.git</url>
        <tag>eurekaclinical-parent-3</tag>
    </scm>
    
    <!-- Both repositories are password protected for deploys. -->
    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
        <repository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
        </repository>
    </distributionManagement>
    <repositories>
        <repository>
            <id>java.net-Public</id>
            <name>Maven Java Net Snapshots and Releases</name>
            <url>https://maven.java.net/content/groups/public/</url>
            <layout>default</layout>
        </repository>
        <repository>
            <id>jboss-releases</id>
            <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
        </repository>
        <repository>
            <id>oracleReleases</id>
            <name>Oracle Released Java Packages</name>
            <url>http://download.oracle.com/maven</url>
            <layout>default</layout>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>java.net-Public</id>
            <name>Maven Java Net Snapshots and Releases</name>
            <url>https://maven.java.net/content/groups/public/</url>
            <layout>default</layout>
        </pluginRepository>
        <pluginRepository>
            <id>jboss-releases</id>
            <url>https://repository.jboss.org/nexus/content/repositories/releases/</url>
        </pluginRepository>
    </pluginRepositories>
    
    <developers>
        <developer>
            <id>arpost</id>
            <name>Andrew Post</name>
            <email>arpost@emory.edu</email>
            <roles>
                <role>Faculty Project Lead</role>
            </roles>
            <organization>
                Department of Biomedical Informatics, Emory University
            </organization>
        </developer>
        <developer>
            <id>mai</id>
            <name>Miao Ai</name>
            <email>miao.ai@emory.edu</email>
            <roles>
                <role>Systems Software Engineer (Contractor)</role>
            </roles>
            <organization>
                Department of Biomedical Informatics, Emory University
            </organization>
        </developer>
        <developer>
            <id>nita.deshpande</id>
            <name>Nita Deshpande</name>
            <email>nita.deshpande@emory.edu</email>
            <roles>
                <role>Senior Systems Software Engineer (Contractor)</role>
            </roles>
            <organization>
                Department of Biomedical Informatics, Emory University
            </organization>
        </developer>
    </developers>
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>appassembler-maven-plugin</artifactId>
                    <version>1.6</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-assembly-plugin</artifactId>
                    <!-- Versions > 2.4.1 break filtering. -->
                    <version>2.4.1</version>
                    <configuration>
                        <tarLongFileMode>gnu</tarLongFileMode>
                    </configuration>
                    <executions>
                        <execution>
                            <phase>package</phase>
                            <goals>
                                <goal>single</goal>
                            </goals>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                </plugin>
                <plugin>
                    <groupId>net.alchim31.maven</groupId>
                    <artifactId>yuicompressor-maven-plugin</artifactId>
                    <version>1.5.1</version>
                    <executions>
                        <execution>
                            <goals>
                                <goal>compress</goal>
                            </goals>
                        </execution>
                    </executions>  
                    <configuration>
                        <suffix>${maven.build.timestamp}</suffix>
                        <includes>
                            <include>assets/css/eureka.css</include>
                        </includes>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>sql-maven-plugin</artifactId>
                    <version>1.5</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.h2database</groupId>
                            <artifactId>h2</artifactId>
                            <version>${h2-version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.liquibase</groupId>
                    <artifactId>liquibase-maven-plugin</artifactId>
                    <version>${liquibase-version}</version>
                    <configuration>
                        <logging>WARNING</logging>
                        <outputFileEncoding>${project.build.sourceEncoding}</outputFileEncoding>
                    </configuration>
                    <dependencies>
                        <dependency>
                            <groupId>com.h2database</groupId>
                            <artifactId>h2</artifactId>
                            <version>${h2-version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.cargo</groupId>
                    <artifactId>cargo-maven2-plugin</artifactId>
                    <version>1.6.7</version>
                    <configuration>
                        <container>
                            <containerId>tomcat7x</containerId>
                            <zipUrlInstaller>
                                <url>http://repo1.maven.org/maven2/org/apache/tomcat/tomcat/7.0.53/tomcat-7.0.53.zip</url>
                            </zipUrlInstaller>
                            <dependencies>
                                <dependency>
                                    <groupId>org.jasig.cas.client</groupId>
                                    <artifactId>cas-client-core</artifactId>                                
                                </dependency>
                                <dependency>
                                    <groupId>commons-logging</groupId>
                                    <artifactId>commons-logging</artifactId>
                                </dependency>
                                <dependency>
                                    <groupId>com.sun.mail</groupId>
                                    <artifactId>javax.mail</artifactId>
                                </dependency>
                                <dependency>
                                    <groupId>log4j</groupId>
                                    <artifactId>log4j</artifactId>
                                </dependency>
                                <dependency>
                                    <groupId>com.h2database</groupId>
                                    <artifactId>h2</artifactId>
                                </dependency>
                            </dependencies>
                            <systemProperties>
                                <org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH>true</org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH>
                                <eureka.config.dir>${project.build.directory}/eureka-config/eureka</eureka.config.dir>
                                <java.util.logging.config.file>${project.build.directory}/eureka-config/logging.properties</java.util.logging.config.file>
                                <javax.net.ssl.trustStore>conf/localhost.truststore</javax.net.ssl.trustStore>
                                <javax.net.ssl.trustStorePass>changeit</javax.net.ssl.trustStorePass>
                            </systemProperties>
                        </container>
                        <configuration>
                            <home>${project.build.directory}/catalina-base</home>
                            <properties>
                                <cargo.servlet.port>${tomcat.httpsPort}</cargo.servlet.port>
                                <cargo.protocol>https</cargo.protocol>
                                <cargo.tomcat.connector.clientAuth>false</cargo.tomcat.connector.clientAuth>
                                <cargo.tomcat.connector.sslProtocol>TLS</cargo.tomcat.connector.sslProtocol>
                                <cargo.tomcat.connector.keystoreFile>conf/localhost.keystore</cargo.tomcat.connector.keystoreFile>
                                <cargo.tomcat.connector.keystorePass>changeit</cargo.tomcat.connector.keystorePass>
                                <cargo.tomcat.connector.keyAlias>tomcat</cargo.tomcat.connector.keyAlias>
                                <cargo.tomcat.httpSecure>true</cargo.tomcat.httpSecure>
                            </properties>
                            <configfiles>
                                <configfile>
                                    <file>${project.build.directory}/tomcat-config/context.xml</file>
                                    <todir>conf</todir>
                                    <tofile>context.xml</tofile>
                                </configfile>
                            </configfiles>
                            <files>
                                <file>
                                    <file>${project.build.directory}/tomcat-config/localhost.truststore</file>
                                    <todir>conf</todir>
                                    <tofile>localhost.truststore</tofile>
                                </file>
                                <file>
                                    <file>${project.build.directory}/tomcat-config/localhost.keystore</file>
                                    <todir>conf</todir>
                                    <tofile>localhost.keystore</tofile>
                                </file>
                            </files>
                        </configuration>
                        <deployables>
                            <deployable>
                                <location>${project.build.directory}/${project.build.finalName}.${project.packaging}</location>
                            </deployable>
                        </deployables>
                    </configuration>
                </plugin>
                <plugin>
                    <groupId>org.apache.tomcat.maven</groupId>
                    <artifactId>tomcat7-maven-plugin</artifactId>
                    <version>2.2</version>
                    <dependencies>
                        <dependency>
                            <groupId>com.h2database</groupId>
                            <artifactId>h2</artifactId>
                            <version>${h2-version}</version>
                            <exclusions>
                                <exclusion>
                                    <groupId>javax.servlet</groupId>
                                    <artifactId>servlet-api</artifactId>
                                </exclusion>
                            </exclusions>
                        </dependency>
                        <dependency>
                            <groupId>com.sun.mail</groupId>
                            <artifactId>javax.mail</artifactId>
                            <version>${javamail-version}</version>
                        </dependency>
                        <dependency>
                            <groupId>commons-logging</groupId>
                            <artifactId>commons-logging</artifactId>
                            <version>${commons-logging-version}</version>
                            <exclusions>
                                <exclusion>
                                    <groupId>javax.servlet</groupId>
                                    <artifactId>servlet-api</artifactId>
                                </exclusion>
                            </exclusions>
                        </dependency>
                        <dependency>
                            <groupId>log4j</groupId>
                            <artifactId>log4j</artifactId>
                            <version>${log4j-version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
            </plugins>
        </pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>versions-maven-plugin</artifactId>
                <version>2.2</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.5.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.sonatype.plugins</groupId>
                <artifactId>nexus-staging-maven-plugin</artifactId>
                <version>1.6.6</version>
                <extensions>true</extensions>
                <configuration>
                    <serverId>ossrh</serverId>
                    <nexusUrl>https://oss.sonatype.org/</nexusUrl>
                    <autoReleaseAfterClose>false</autoReleaseAfterClose>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-release-plugin</artifactId>
                <version>2.5.3</version>
                <configuration>
                    <autoVersionSubmodules>true</autoVersionSubmodules>
                    <useReleaseProfile>false</useReleaseProfile>
                    <releaseProfiles>release-sign-artifacts</releaseProfiles>
                    <goals>deploy</goals>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>1.9</version>
                <configuration>
                    <licenseName>apache_v2</licenseName>
                </configuration>
                <executions>
                    <execution>
                        <id>first</id>
                        <goals>
                            <goal>update-file-header</goal>
                        </goals>
                        <phase>process-sources</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <version>2.10.3</version>
                <executions>
                    <execution>
                        <id>attach-javadocs</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.jasig.maven</groupId>
                <artifactId>maven-notice-plugin</artifactId>
                <version>1.0.6.1</version>
                <executions>
                    <execution>	
                        <id>checkontest</id>
                        <goals>
                            <goal>check</goal>
                        </goals>
                        <phase>test</phase>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>1.4.1</version>
                <executions>
                    <execution>
                        <id>enforce-maven</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireMavenVersion>
                                    <version>3.2.5</version>
                                </requireMavenVersion>
                            </rules>    
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.4</version>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.19</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.6</version>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <version>1.10</version>
                <executions>
                    <execution>
                        <id>parse-version</id>
                        <goals>
                            <goal>parse-version</goal>
                        </goals>
                    </execution>
                    <execution>
                        <id>timestamp-property</id>
                        <goals>
                            <goal>timestamp-property</goal>
                        </goals>
                        <configuration>
                            <locale>en,US</locale>
                            <name>currentYear</name>
                            <pattern>yyyy</pattern>
                            <units>year</units>
                            <offset>0</offset>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
    <profiles>
        <profile>
            <id>release-sign-artifacts</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-gpg-plugin</artifactId>
                        <version>1.6</version>
                        <executions>
                            <execution>
                                <id>sign-artifacts</id>
                                <phase>verify</phase>
                                <goals>
                                    <goal>sign</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>stage-production</id>
            <properties>
                <eurekaclinical.stage>PRODUCTION</eurekaclinical.stage>
            </properties>
        </profile>
        <profile>
            <id>tomcat</id>
            <properties>
                <tomcat.httpsPort>8443</tomcat.httpsPort>
            </properties>
            <dependencies>
                <dependency>
                    <groupId>org.jasig.cas.client</groupId>
                    <artifactId>cas-client-core</artifactId>
                    <version>${cas-client-version}</version>                          
                    <exclusions>
                        <exclusion>
                            <groupId>javax.servlet</groupId>
                            <artifactId>servlet-api</artifactId>
                        </exclusion>
                    </exclusions>         
                    <scope>runtime</scope>                    
                </dependency>
                <dependency>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </dependency>
                <dependency>
                    <groupId>com.sun.mail</groupId>
                    <artifactId>javax.mail</artifactId>
                </dependency>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                </dependency>
                <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <exclusions>
                        <exclusion>
                            <groupId>javax.servlet</groupId>
                            <artifactId>servlet-api</artifactId>
                        </exclusion>
                    </exclusions>
                </dependency>
            </dependencies>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-context.xml</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/tomcat-config</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/main/resources/tomcat-server-config</directory>
                                            <filtering>true</filtering>
                                            <includes>
                                                <include>context.xml</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-cert</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/tomcat-config</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/main/resources/tomcat-server-config</directory>
                                            <filtering>false</filtering>
                                            <includes>
                                                <include>localhost.keystore</include>
                                                <include>localhost.truststore</include>
                                            </includes>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-logging.properties-file</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/eureka-config</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/main/resources/tomcat-eureka-config</directory>
                                            <includes>
                                                <include>logging.properties</include>
                                            </includes>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-application.properties-file</id>
                                <phase>process-resources</phase>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/eureka-config/eureka</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${basedir}/src/main/resources/tomcat-eureka-config/eureka</directory>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.cargo</groupId>
                        <artifactId>cargo-maven2-plugin</artifactId>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>docker</id>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>com.spotify</groupId>
                            <artifactId>dockerfile-maven-plugin</artifactId>
                            <version>1.3.7</version>
                            <executions>
                                <execution>
                                    <id>default</id>
                                    <goals>
                                        <!--
                                            bind:  mojo "build" is bound to "package" phase
                                            docker-hub:  "mvn dockerfile:push" to deploy
                                        -->
                                        <goal>build</goal>
                                    </goals>
                                </execution>
                            </executions>
                            <configuration>
                                <buildArgs>
                                    <IMAGE_VERSION>0.0.1</IMAGE_VERSION>
                                </buildArgs>
                                <repository>ihawke/test</repository>
                                <tag>latest</tag>
                                <useMavenSettingsForAuth>true</useMavenSettingsForAuth>
                            </configuration>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
    </profiles>
</project>
