<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.github.davidmoten</groupId>
    <artifactId>beanstalk-template</artifactId>
    <packaging>war</packaging>
    <version>0.1-SNAPSHOT</version>

    <properties>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.build.timestamp.format>yyyyMMddHHmmss</maven.build.timestamp.format>

        <aws.accessKeyId>${env.AWS_ACCESS_KEY}</aws.accessKeyId>
        <aws.secretKey>${env.AWS_SECRET_ACCESS_KEY}</aws.secretKey>
        <password.hash.key>${env.PASSWORD_HASH_KEY}</password.hash.key>
        <mode>dev</mode>
        <aws.sdk.version>1.11.8</aws.sdk.version>
        <proxy.host>proxy.amsa.gov.au</proxy.host>
        <proxy.port>8080</proxy.port>

        <application.name>beanstalk-template</application.name>
        <application.region>ap-southeast-2</application.region>
        <application.env>${mode}</application.env>
        <application.env.name>${application.name}-${application.env}</application.env.name>
        <application.version>${project.artifactId}-${project.version}-${maven.build.timestamp}</application.version>
        <application.version.label>${application.version}</application.version.label>

        <jetty.plugin.version>8.1.12.v20130726</jetty.plugin.version>
        <jetty.stop.port>9998</jetty.stop.port>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-s3</artifactId>
            <version>${aws.sdk.version}</version>
        </dependency>
        <dependency>
            <groupId>com.amazonaws</groupId>
            <artifactId>aws-java-sdk-sqs</artifactId>
            <version>${aws.sdk.version}</version>
        </dependency>
        <dependency>
            <groupId>com.github.davidmoten</groupId>
            <artifactId>authentication-util</artifactId>
            <version>0.1</version>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <version>3.1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>18.0</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish</groupId>
            <artifactId>javax.json</artifactId>
            <version>1.0.4</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-core</artifactId>
            <version>1.9.5</version>
            <scope>test</scope>
        </dependency>
        
    </dependencies>
    <build>
        <finalName>${project.artifactId}</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>${maven.compiler.target}</source>
                    <target>${maven.compiler.target}</target>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.davidmoten</groupId>
                <artifactId>decrypt-maven-plugin</artifactId>
                <version>0.1.2</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>decrypt</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <serverId>beanstalk-template-server-private-key-${mode}</serverId>
                            <!-- use mvn -ep "private-key.pem  
                                and store in your settings.xml against the above serverId. Note that a multiline password can be used 
                                with mvn -ep, you just have to start with double-quote, paste it, then terminate with double quote -->
                            <outputFile>${project.build.directory}/keys/${mode}/server-private-key.pem</outputFile>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.6</version>
                <configuration>
                    <nonFilteredFileExtensions>
                        <!-- jks exclusion is essential because otherwise gets corrupted -->
                        <nonFilteredFileExtension>jks</nonFilteredFileExtension>
                        <nonFilteredFileExtension>png</nonFilteredFileExtension>
                        <nonFilteredFileExtension>key</nonFilteredFileExtension>
                        <nonFilteredFileExtension>der</nonFilteredFileExtension>
                        <nonFilteredFileExtension>crt</nonFilteredFileExtension>
                        <nonFilteredFileExtension>p12</nonFilteredFileExtension>
                        <nonFilteredFileExtension>pem</nonFilteredFileExtension>
                    </nonFilteredFileExtensions>
                    <webResources>
                        <resource>
                            <!-- this is relative to the pom.xml directory -->
                            <directory>src/main/webapp</directory>
                            <filtering>true</filtering>
                        </resource>
                        <resource>
                            <directory>${project.build.directory}/keys</directory>
                            <targetPath>.ebextensions/certificates</targetPath>
                            <filtering>false</filtering>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
            <plugin>
                <groupId>com.github.davidmoten</groupId>
                <artifactId>aws-maven-plugin</artifactId>
                <version>0.2.1</version>
                <configuration>
                    <awsAccessKey>${aws.accessKeyId}</awsAccessKey>
                    <awsSecretAccessKey>${aws.secretKey}</awsSecretAccessKey>
                    <artifact>${project.build.directory}/${project.build.finalName}.war</artifact>
                    <applicationName>${application.name}</applicationName>
                    <environmentName>${application.env.name}</environmentName>
                    <region>${application.region}</region>
                    <httpsProxyHost>${proxy.host}</httpsProxyHost>
                    <httpsProxyPort>${proxy.port}</httpsProxyPort>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.3.7.v20160115</version>
                <configuration>
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <stopKey>foo</stopKey>
                    <stopPort>9998</stopPort>
                    <webAppConfig>
                        <contextPath>/</contextPath>
                    </webAppConfig>
                    <systemProperties>
                        <systemProperty>
                            <name>aws.accessKeyId</name>
                            <value>${aws.accessKeyId}</value>
                        </systemProperty>
                        <systemProperty>
                            <name>aws.secretKey</name>
                            <value>${aws.secretKey}</value>
                        </systemProperty>
                    </systemProperties>
                </configuration>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <!--This plugin's configuration is used to store Eclipse m2e settings only. It has no 
                    influence on the Maven build itself. -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>com.github.davidmoten</groupId>
                                        <artifactId>decrypt-maven-plugin</artifactId>
                                        <versionRange>[0.1.2,)</versionRange>
                                        <goals>
                                            <goal>decrypt</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore></ignore>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>
</project>
