<?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.alfresco</groupId>

    <artifactId>alfresco-an2</artifactId>
    <name>Alfresco AN2 Repository Services</name>
    <version>0.1.0-SNAPSHOT</version>
    <packaging>pom</packaging>

    <prerequisites>
       <maven>3.0.3</maven>
    </prerequisites>

    <properties>
        <maven.build.sourceVersion>1.8</maven.build.sourceVersion>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        
        <!-- Centralised dependency versions -->
        <dependency.servlet.version>3.0.1</dependency.servlet.version>
        <dependency.spring.version>4.1.6.RELEASE</dependency.spring.version>
        <dependency.spring-security.version>4.0.1.RELEASE</dependency.spring-security.version>
        <dependency.jersey.version>2.19</dependency.jersey.version>
        <dependency.tomcat.version>8.0.23</dependency.tomcat.version>
        <dependency.junit.version>4.12</dependency.junit.version>
        <dependency.log4j.version>2.3</dependency.log4j.version>
        <dependency.gson.version>2.3.1</dependency.gson.version>
        <dependency.commons.version>3.4</dependency.commons.version>
        
        <jetty.debug-args></jetty.debug-args>

    </properties>

    <profiles>
        <profile>
            <id>jettyDebug</id>
            <properties>
                <jetty.debug-args>-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000</jetty.debug-args>
            </properties>
        </profile>
    </profiles>
    
    <modules>
        <module>util</module>
        <module>apis</module>
        <module>rest</module>
        <module>client</module>
        <module>server</module>
        <module>cx-util</module>
        <module>cx1</module>
    </modules>
    
    <dependencies>
        
        <!-- Testing -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>${dependency.junit.version}</version>
        </dependency>

        <!-- Logging -->
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-core</artifactId>
            <version>${dependency.log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-jcl</artifactId>
            <version>${dependency.log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.logging.log4j</groupId>
            <artifactId>log4j-web</artifactId>
            <version>${dependency.log4j.version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.12</version>
        </dependency>
        
        <!-- Apache Commons -->
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>${dependency.commons.version}</version>
        </dependency>

    </dependencies>
    
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>org/alfresco/an2/config/*.properties</include>
                    <include>log4j2.*</include>
                </includes>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <version>2.2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>jar-no-fork</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${maven.build.sourceVersion}</source>
                    <target>${maven.build.sourceVersion}</target>
                    <debug>true</debug>
                    <debuglevel>lines,vars,source</debuglevel> 
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <failOnError>false</failOnError>
                    <additionalparam>-Xdoclint:none</additionalparam>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
            </plugin>
        </plugins>
        <pluginManagement>
            <plugins>
                <plugin>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.3</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-war-plugin</artifactId>
                    <version>2.6</version>
                    <configuration>
                        <attachClasses>true</attachClasses>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-javadoc-plugin</artifactId>
                    <version>2.10.3</version>
                </plugin>
                <plugin>
                    <artifactId>maven-clean-plugin</artifactId>
                    <version>2.5</version>
                </plugin>
                <plugin>
                    <artifactId>maven-deploy-plugin</artifactId>
                    <version>2.7</version>
                </plugin>
                <plugin>
                    <artifactId>maven-install-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>2.4</version>
                </plugin>
                <plugin>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>2.6</version>
                </plugin>
                <plugin>
                    <artifactId>maven-site-plugin</artifactId>
                    <version>3.2</version>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <version>2.13</version>
                </plugin>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>1.9.1</version>
                    <executions>
                        <execution>
                            <id>reserve-ports</id>
                            <goals>
                                <goal>reserve-network-port</goal>
                            </goals>
                            <phase>pre-integration-test</phase>
                            <configuration>
                                <!-- Find open ports and assign values to system properties -->
                                <portNames>
                                    <!-- Jetty -->
                                    <portName>jetty.port</portName>
                                    <portName>jetty.stopPort</portName>
                                    <!-- Cassandra -->
                                    <portName>cassandra.jmxPort</portName>
                                    <portName>cassandra.rpcPort</portName>
                                    <portName>cassandra.stopPort</portName>
                                    <portName>cassandra.storagePort</portName>
                                    <portName>cassandra.nativePort</portName>
                                </portNames>
                                <localIpProperty>cassandra.listenAddress</localIpProperty>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <artifactId>maven-failsafe-plugin</artifactId>
                    <version>2.18.1</version>
                    <configuration>
                        <dependenciesToScan>
                            <dependency>org.alfresco:alfresco-an2-client</dependency>
                        </dependenciesToScan>
                        <additionalClasspathElements>
                            <additionalClasspathElement>${project.build.testOutputDirectory}</additionalClasspathElement>
                        </additionalClasspathElements>
                    </configuration>
                    <executions>
                        <execution>
                            <id>integration-test</id>
                            <goals>
                                <goal>integration-test</goal>
                                <goal>verify</goal>
                            </goals>
                            <configuration>
                                <argLine>-Dalfresco.an2.apiUrl=http://localhost:${jetty.port}/${project.artifactId}/api -Dorg.alfresco.an2.cassandra.port=${cassandra.nativePort}</argLine>
                                <summaryFile>target/failsafe-reports/failsafe-it.xml</summaryFile>
                            </configuration>
                        </execution>
                        <execution>
                            <id>verify</id>
                            <goals>
                                <goal>verify</goal>
                            </goals>
                            <configuration>
                                <summaryFiles>
                                    <summaryFile>target/failsafe-reports/failsafe-it.xml</summaryFile>
                                </summaryFiles>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <plugin>
                    <groupId>org.eclipse.jetty</groupId>
                    <artifactId>jetty-maven-plugin</artifactId>
                    <version>9.3.0.v20150612</version>
                    <configuration>
                        <webApp>
                            <contextPath>/${project.artifactId}</contextPath>
                        </webApp>
                        <stopPort>${jetty.stopPort}</stopPort>
                        <stopKey>STOP</stopKey>
                        <scanIntervalSeconds>0</scanIntervalSeconds>
                        <daemon>true</daemon>
                        <waitForChild>false</waitForChild>
                        <dumpOnStart>true</dumpOnStart>
                    </configuration>
                    <executions>
                        <execution>
                            <id>start-jetty</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <!-- stop any previous instance to free up the port -->
                                <goal>stop</goal>
                                <goal>run-forked</goal>
                            </goals>
                            <configuration>
                                <jvmArgs>-Djetty.http.port=${jetty.port} -Dorg.alfresco.an2.cassandra.port=${cassandra.nativePort} ${jetty.debug-args}</jvmArgs>
                                <stopPort>${jetty.stopPort}</stopPort>
                                <stopKey>STOP</stopKey>
                            </configuration>
                        </execution>
                        <execution>
                            <id>stop-jetty</id>
                            <phase>post-integration-test</phase>
                            <goals>
                                <goal>stop</goal>
                            </goals>
                            <configuration>
                                <stopPort>${jetty.stopPort}</stopPort>
                                <stopKey>STOP</stopKey>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <distributionManagement>
        <repository>
            <id>alfresco-internal</id>
            <name>Alfresco Releases Repository</name>
            <url>https://artifacts.alfresco.com/nexus/content/repositories/releases</url>
        </repository>
        <snapshotRepository>
            <id>alfresco-internal-snapshots</id>
            <name>Alfresco Snapshots Repository </name>
            <url>https://artifacts.alfresco.com/nexus/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>

</project>
