<?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>share-po</artifactId>
    <parent>
        <groupId>org.alfresco</groupId>
        <artifactId>alfresco-parent</artifactId>
        <version>5.0.a</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <sonar.jacoco.reportPath>${project.build.directory}/jacoco.exec</sonar.jacoco.reportPath>
        <webdrone.page.render.wait.time>6000</webdrone.page.render.wait.time>
        <enterprise.build.plan>4.3</enterprise.build.plan>
        <testng.xml>src/test/resources/testng.xml</testng.xml>
        <test.exclude>nonEnterprise</test.exclude>
        <selenium.version>2.39.0</selenium.version>
    </properties>
    <repositories>
        <repository>
            <id>alfresco-public-snapshots</id>
            <releases>
                <enabled>false</enabled>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
             </snapshots>
             <name>Alfresco Public Snapshots Repository</name>
             <url>https://artifacts.alfresco.com/nexus/content/repositories/public-snapshots/</url>
        </repository>
        <repository>
            <id>alfresco-public</id>
            <releases>
                <updatePolicy>always</updatePolicy>
            </releases>
            <snapshots>
                <enabled>false</enabled>
                <updatePolicy>never</updatePolicy>
                <checksumPolicy>fail</checksumPolicy>
             </snapshots>
             <name>Alfresco Public Releases Repository</name>
             <url>https://artifacts.alfresco.com/nexus/content/groups/public/</url>
        </repository>
    </repositories>
    
    <dependencies>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>${selenium.version}</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-server</artifactId>
            <version>${selenium.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.mortbay.jetty</groupId>
                    <artifactId>servlet-api-2.5</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.10.0-alfresco-patched</version>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>webdrone</artifactId>
            <version>2.5</version>
            <exclusions>
                <exclusion>
                    <artifactId>xercesImpl</artifactId>
                    <groupId>xerces</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.8.8</version>
            <scope>runtime</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.hamcrest</groupId>
                    <artifactId>hamcrest-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.owasp.esapi</groupId>
            <artifactId>esapi</artifactId>
            <version>2.1.0</version>
            <exclusions>
                <exclusion>
                    <groupId>net.sourceforge.nekohtml</groupId>
                    <artifactId>nekohtml</artifactId>
                </exclusion>
                <exclusion>
                    <artifactId>javax.servlet</artifactId>
                    <groupId>servlet-api</groupId>
                </exclusion>
                <exclusion>
                    <artifactId>xercesImpl</artifactId>
                    <groupId>xerces</groupId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.4</version>
        </dependency>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.3</version>
        </dependency>
    </dependencies>
    
    <!-- Pacakge Application into a standalone  -->
    <build>
        <sourceDirectory>src/main/java</sourceDirectory>
        <testSourceDirectory>src/test/java</testSourceDirectory>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
            </resource>
        </resources>
        <testResources>
            <testResource>
                 <directory>src/test/resources</directory>
            </testResource>
        </testResources> 
        <plugins>
            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <tagNameFormat>V@{project.version}</tagNameFormat>
                    <tagBase>https://svn.alfresco.com/repos/alfresco-enterprise/benchmark/webdrone/share-po/tags</tagBase>
                </configuration>
            </plugin>
            <plugin>
               <artifactId>maven-compiler-plugin</artifactId>
               <configuration>
                  <source>1.7</source>
                  <target>1.7</target>
               </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-shade-plugin</artifactId>
                <version>2.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <shadedArtifactAttached>true</shadedArtifactAttached>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <suiteXmlFiles>
						<suiteXmlFile>src/test/resources/SearchSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/DashletSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/DocumentSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/DownloadSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/EnumSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/SiteContentSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/SitesSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/TasksSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/WorkflowSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/ShareSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/AdminConsoleSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/ContentRulesSuite.xml</suiteXmlFile>
						<suiteXmlFile>src/test/resources/BlogPageSuite.xml</suiteXmlFile>
						<suiteXmlFile>src/test/resources/DataListPageSuite.xml</suiteXmlFile>
						<suiteXmlFile>src/test/resources/DiscussionsPageSuite.xml</suiteXmlFile>
						<suiteXmlFile>src/test/resources/LinksPageSuite.xml</suiteXmlFile>						
						<suiteXmlFile>src/test/resources/CalendarPageSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/MyProfileSuite.xml</suiteXmlFile>
                        <suiteXmlFile>src/test/resources/AlfrescoTestSuite.xml</suiteXmlFile>
                    </suiteXmlFiles>
                    <argLine>-Xms512m -Xmx1024m</argLine>
                    <excludedGroups>
                        ${test.exclude}
                    </excludedGroups>
                    <groups>
                        ${test.include}
                    </groups>
                    <workingDirectory>target</workingDirectory>
                    <!--parallel>classes</parallel-->
                    <!--<systemPropertyVariables>-->
                        <!--<webdrone.element.wait.time>${webdrone.element.wait.time}</webdrone.element.wait.time>-->
                    <!--</systemPropertyVariables>-->
                   <redirectTestOutputToFile>false</redirectTestOutputToFile>
                </configuration>
            </plugin>

            <plugin>
                <artifactId>maven-release-plugin</artifactId>
                <configuration>
                    <tagNameFormat>V@{project.version}</tagNameFormat>
                    <tagBase>https://svn.alfresco.com/repos/alfresco-enterprise/benchmark/webdrone/share-po/tags</tagBase>
                </configuration>
            </plugin>

            <plugin>
                <!-- Configuration triggered by mvn antrun:run, used by Bamboo to stop server -->
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-cli</id>
                        <configuration>
                            <target>
                                <echo>Stopping Alfresco...</echo>
                                <exec executable="${basedir}/target/alf-installation/alfresco.sh" dir="target/alf-installation" failonerror="true">
                                    <arg value="stop" />
                                </exec>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>install-alfresco</id>
            <build>
                <plugins>
                    <!-- Download and install the latest enterprise alfresco installer -->
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>fetch-installer</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                  <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <echo>Recreating database...</echo>
                                        <sql driver="org.postgresql.Driver" url="jdbc:postgresql:template1" userid="alfresco" password="alfresco" autocommit="true">drop database if exists alfresco; create database alfresco</sql>
                                        <echo>Downloading Alfresco installer...</echo>
                                        <sshexec username="tomcat" host="pbld01.alfresco.com" keyfile="${user.home}/.ssh/id_rsa" outputproperty="installerPath" command="ls -rt /data/bamboo/artifacts/${enterprise.build.plan}/ALL/alfresco-enterprise-*-installer-linux-x64.??? | tail -1 | tr ' ' '?' " />
                                        <scp remoteFile="tomcat@pbld01.alfresco.com:${installerPath}" localTofile="target/alf-installer.bin" keyfile="${user.home}/.ssh/id_rsa" />
                                        <chmod file="target/alf-installer.bin" perm="a+x" verbose="true" />
                                        <echo>Installing Alfresco...</echo>
                                        <exec executable="${basedir}/target/alf-installer.bin" dir="target" failonerror="true">
                                            <arg line="--mode unattended --alfresco_admin_password admin --disable-components postgres,alfrescowcmqs --jdbc_username alfresco --jdbc_password alfresco --prefix ${basedir}/target/alf-installation --tomcat_server_domain ${HOSTNAME}" />
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>org.apache.ant</groupId>
                                <artifactId>ant-jsch</artifactId>
                                <version>1.8.2</version>
                            </dependency>
                            <dependency>
                                <groupId>org.postgresql</groupId>
                                <artifactId>postgresql</artifactId>
                                <version>9.3-1101-jdbc41</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>enable-hybrid</id>
            <build>
                <plugins>
                    <!-- Enable hybrid in the installation -->
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>modify-properties</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                  <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <property name="alf.prop" location="target/alf-installation/tomcat/shared/classes/alfresco-global.properties" />
                                        <echo append="true" output="${alf.prop}" />
                                        <echo append="true" output="${alf.prop}">
hybridworkflow.enabled=true
sync.cloud.url=https://webdronehwa.alfresco.me/alfresco/a/{network}/
                                        </echo>
                                        <echo append="true" output="${alf.prop}" />
                                        <copy failonerror="false" verbose="true" todir="target/alf-installation/tomcat/shared/classes/alfresco/extension/license" file="${user.home}/binaries/build-classpath/4.3/WEB-INF/alfresco/license/Enterprise43-All.lic" /> 
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>run-alfresco</id>
            <build>
                <plugins>
                    <!-- Fetch JaCoCo agent and set the argLine property accordingly -->
                    <plugin>
                        <groupId>org.jacoco</groupId>
                        <artifactId>jacoco-maven-plugin</artifactId>
                        <version>0.6.3.201306030806</version>
                        <executions>
                            <execution>
                                <id>prepare-jacoco</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <includes>
                                <include>org.alfresco.*</include>
                            </includes>
                        </configuration>
                    </plugin>

                    <!-- Starts/stop the installed Alfresco -->
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>start-alfresco</id>
                                <phase>process-test-classes</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <echo>Starting Alfresco...</echo>
                                        <exec executable="${basedir}/target/alf-installation/alfresco.sh" dir="target/alf-installation" failonerror="true">
                                            <arg value="start" />
                                            <env key="CATALINA_OPTS" value="${argLine}" />
                                        </exec>
                                        <sleep minutes="5" />
                                    </target>
                                </configuration>
                            </execution>
                            <execution>
                                <id>stop-alfresco</id>
                                <phase>post-integration-test</phase>
                                <goals>
                                  <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <echo>Stopping Alfresco...</echo>
                                        <exec executable="${basedir}/target/alf-installation/alfresco.sh" dir="target/alf-installation" failonerror="true">
                                            <arg value="stop" />
                                        </exec>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
