<?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-share-parent</artifactId>
        <version>6.0.2-SNAPSHOT</version>
    </parent>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <testng.xml>src/test/resources/testng.xml</testng.xml>
        <test.exclude>nonEnterprise</test.exclude>
        <test.include>unit,alfresco-one,Enterprise4.2,Enterprise-only</test.include>
        <testng.suite.filename>src/test/resources/testng-alfresco-share.xml</testng.suite.filename>
        <argLine>-Xms512m -Xmx1024m</argLine>
        <skipTests>true</skipTests>
        <spring.version>5.0.4.RELEASE</spring.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>
    </repositories>
    <dependencies>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>selenium-grid</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>org.alfresco.test</groupId>
            <artifactId>alfresco-testng</artifactId>
            <version>1.1</version>
            <scope>test</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>
                    <groupId>commons-beanutils</groupId>
                    <artifactId>commons-beanutils-core</artifactId>
                </exclusion>
		      <exclusion>
                    <artifactId>xercesImpl</artifactId>
                    <groupId>xerces</groupId>
                </exclusion>
                <exclusion>
                    <groupId>batik</groupId>
                    <artifactId>batik-util</artifactId>
                </exclusion>
                <exclusion>
                     <groupId>org.apache.xmlgraphics</groupId>
                     <artifactId>batik-ext</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xom</groupId>
                    <artifactId>xom</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis-ext</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
			<version>1.10.19</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>${spring.version}</version>
        </dependency>
        <dependency>
             <groupId>org.springframework</groupId>
             <artifactId>spring-test</artifactId>
             <version>${spring.version}</version>
        </dependency>
        <dependency>
            <groupId>ru.yandex.qatools.htmlelements</groupId>
            <artifactId>htmlelements-java</artifactId>
            <version>1.13</version>
        </dependency>
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
			<version>2.9.4</version>
        </dependency>
        <dependency>
            <groupId>org.alfresco.test</groupId>
            <artifactId>dataprep</artifactId>
            <version>1.9</version>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>fetch</artifactId>
            <version>1.0</version>
        </dependency>
		<dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
           <version>3.1.0</version>
        </dependency>
	    <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.4.01</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    
    <!-- Package 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>
            <!-- Package source  -->
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <phase>package</phase>
                    </execution>
                </executions>
                <configuration>
                    <tarLongFileMode>posix</tarLongFileMode>
                    <finalName>share-po-src</finalName>
                    <descriptorRefs>
                        <descriptorRef>src</descriptorRef>
                    </descriptorRefs>
                </configuration>
            </plugin>
<!--             <plugin>
		        <groupId>org.apache.maven.plugins</groupId>
		        <artifactId>maven-jar-plugin</artifactId>
		        <version>2.6</version>
		        <executions>
		            <execution>
		                <goals>
		                    <goal>test-jar</goal>
		            	</goals>
		          	</execution>
		        </executions>
		    </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>
                                        <taskdef resource="net/sf/antcontrib/antlib.xml" />

                                        <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>
                                        <if>
                                            <not> <isset property="installer.location" /> </not>
                                            <then>
                                                <property name="installer.location" location="${basedir}/target/alf-installer.bin" />
                                                <echo>Downloading Alfresco installer to ${installer.location}...</echo>
                                                <sshexec username="tomcat" host="pbam01.alfresco.com" keyfile="${user.home}/.ssh/id_rsa" outputproperty="installerPath" command="ls -rt /data/bamboo/artifacts/${enterprise.build.plan}/ALL/alfresco-*-linux-x64.??? | tail -1 | tr ' ' '?' " />
                                                <scp file="tomcat@pbam01.alfresco.com:${installerPath}" localTofile="${installer.location}" keyfile="${user.home}/.ssh/id_rsa" />
                                            </then>
                                        </if>
                                        <chmod file="${installer.location}" perm="a+x" verbose="true" />
                                        <echo>Installing Alfresco...</echo>
                                        <exec executable="${installer.location}" 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>ant-contrib</groupId>
                                <artifactId>ant-contrib</artifactId>
                                <version>1.0b3</version>
                                <exclusions>
                                    <exclusion>
                                        <groupId>ant</groupId>
                                        <artifactId>ant</artifactId>
                                    </exclusion>
                                </exclusions>
                            </dependency>
                            <dependency>
                                <groupId>org.postgresql</groupId>
                                <artifactId>postgresql</artifactId>
                                <version>${dependency.postgresql.version}</version>
                            </dependency>
                        </dependencies>
                    </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>
                        <executions>
                            <execution>
                                <id>prepare-jacoco</id>
                                <goals>
                                    <goal>prepare-agent</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <includes>
                                <include>org.alfresco.*</include>
                            </includes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>alfresco-one-tests</id>
            <build>
                <plugins>
                    <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/ShareSuite.xml</suiteXmlFile>
                                <suiteXmlFile>src/test/resources/WorkflowSuite.xml</suiteXmlFile>
                                <suiteXmlFile>src/test/resources/AdminConsoleSuite.xml</suiteXmlFile>
                                <suiteXmlFile>src/test/resources/ContentRulesSuite.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/ShareStepsSuite.xml</suiteXmlFile>
                                <suiteXmlFile>src/test/resources/CmmSuite.xml</suiteXmlFile>
                            </suiteXmlFiles>
                            <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>
                </plugins>
            </build>
        </profile>
       <profile>
            <id>alfresco-one-e2e-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <skipTests>false</skipTests>
                            <suiteXmlFiles>
                            	<suiteXmlFile>src/test/resources/UseCasesSuite.xml</suiteXmlFile>
                            </suiteXmlFiles>
                            <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>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>upgrade-aikau</id>
            <properties>
                <aikau.version>RELEASE</aikau.version>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>     
                        <executions>
                            <execution>
                                <id>fetch-aikau</id>
                                <phase>generate-test-resources</phase>
                                <goals>
                                    <goal>copy</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.alfresco</groupId>
                                            <artifactId>aikau</artifactId>
                                            <version>${aikau.version}</version>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${basedir}/target</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>     
                        <executions>
                            <execution>
                                <id>change-aikau</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <target>
                                        <echo>Tweaking Aikau in share.war...</echo>
                                        <zip destfile="${basedir}/target/share.war">
                                            <zipfileset src="${basedir}/target/alf-installation/tomcat/webapps/share.war" excludes="WEB-INF/lib/aikau-*.jar" />
                                            <zipfileset dir="${basedir}/target" includes="aikau-*.jar" prefix="WEB-INF/lib" />
                                        </zip>
                                        <move file="${basedir}/target/share.war" todir="${basedir}/target/alf-installation/tomcat/webapps" verbose="true" />
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <profile>
            <id>sanity-tests</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>     
                        <configuration>
                        	<skipTests>false</skipTests>
                            <suiteXmlFiles>
                                <suiteXmlFile>${testng.suite.filename}</suiteXmlFile>
                            </suiteXmlFiles>
                            <excludedGroups>
                                ${test.exclude}
                            </excludedGroups>
                            <groups>
                                ${test.include}
                            </groups>
                            <workingDirectory>target</workingDirectory>
                            <redirectTestOutputToFile>false</redirectTestOutputToFile>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
