<?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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.alfresco.services</groupId>
        <artifactId>alfresco-repo-extensions-parent</artifactId>
        <version>1.2.9</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>alfresco-services-amp-parent</artifactId>
    <packaging>pom</packaging>
    <name>Alfresco Services AMP Parent Project</name>
    
    <properties>
        <buildNumber>0</buildNumber>
        <dependency.commons-logging.version>1.1.1</dependency.commons-logging.version>
        <alfresco.repository.properties.file>${project.build.testOutputDirectory}/alfresco-global.properties</alfresco.repository.properties.file>
        <war.artifactId.repo>alfresco-enterprise</war.artifactId.repo>
        <war.artifactId.share>share-enterprise</war.artifactId.share>
        <ampFinalName>${project.artifactId}-${distribution.version}-${buildNumber}</ampFinalName>
    </properties>

    <dependencies>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>${dependency.commons-logging.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${dependency.sl4j.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>${dependency.spring.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>${dependency.spring.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${dependency.spring.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>${dependency.spring.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>${dependency.spring.version}</version>
            <scope>provided</scope>
        </dependency>
        
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-core</artifactId>
            <version>${alfresco.core.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-data-model</artifactId>
            <version>${alfresco.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-repository</artifactId>
            <version>${alfresco.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-remote-api</artifactId>
            <version>${alfresco.version}</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.slf4j</groupId>
                    <artifactId>slf4j-log4j12</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        
        <!-- Test dependencies -->
        
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>${dependency.postgresqlconnector.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>${dependency.mysqlconnector.version}</version>
            <scope>test</scope>
        </dependency>
        
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-mbeans</artifactId>
            <version>${alfresco.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-repository</artifactId>
            <version>${alfresco.version}</version>
            <type>test-jar</type>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${dependency.spring.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
            <version>1.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.6</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>3.2.10.RELEASE</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.4.01</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <!-- Adds the non-standard config directory for alfresco-maven-plugin to pick up -->
                    <execution>
                        <id>add-config-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
	                                <directory>src/main/config</directory>
	                                <targetPath>${project.build.directory}/${project.artifactId}-${project.version}/config</targetPath>
	                            </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>amp-module-version-regex-property</id>
                        <goals>
                            <goal>regex-property</goal>
                        </goals>
                        <configuration>
                            <name>amp.module.version</name>
                            <value>${project.version}</value>
                            <regex>-alf\d*</regex>
                            <replacement />
                            <failIfNoMatch>false</failIfNoMatch>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
        <!--
            Copies and filters resources in build folder so alfresco-maven-plugin can
            pick them up
        -->
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <excludes>
                    <exclude>**README-*</exclude>
                </excludes>
            </resource>
            <resource>
                <filtering>true</filtering>
                <directory>src/main/amp</directory>
                <targetPath>../${project.build.finalName}</targetPath>
                <excludes>
                    <exclude>**README-*</exclude>
                </excludes>
            </resource>
        </resources>
        <testResources>
            <testResource>
                <filtering>true</filtering>
                <directory>src/test/resources</directory>
            </testResource>
            <testResource>
                <filtering>true</filtering>
                <directory>src/main/amp</directory>
                <includes>
                    <include>module.properties</include>
                </includes>
                <targetPath>alfresco/module/${project.artifactId}</targetPath>
            </testResource>
            <testResource>
                <directory>src/main/config</directory>
            </testResource>
        </testResources>
        <pluginManagement>
            <plugins>
                <plugin>
                    <groupId>org.alfresco.maven.plugin</groupId>
                    <artifactId>alfresco-maven-plugin</artifactId>
                    <version>1.1.1</version>
                    <extensions>true</extensions>
                    <configuration>
                        <snapshotToTimestamp>true</snapshotToTimestamp>
                        <verbose>true</verbose>
                        <skipWarManifestCheck>true</skipWarManifestCheck>
                        <ampFinalDir>${project.build.directory}/amps</ampFinalDir>
                        <ampFinalName>${ampFinalName}</ampFinalName>
                        <attachClasses>true</attachClasses>
                        <attachConfig>true</attachConfig>
                        <version>${amp.module.version}</version>
                    </configuration>
                    <executions>
                        <execution>
                            <id>apply-amp-to-war</id>
                            <phase>pre-integration-test</phase>
                            <goals>
                                <goal>install</goal>
                            </goals>
                            <configuration>
                                <ampLocation>${project.build.directory}/amps</ampLocation>
                                <warLocation>${war.file}</warLocation>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
                <!-- Disables warnings in Eclipse -->
                <plugin>
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-dependency-plugin</artifactId>
                                        <versionRange>[2.0,)</versionRange>
                                        <goals>
                                            <goal>copy-dependencies</goal>
                                            <goal>unpack</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-surefire-plugin</artifactId>
                                        <versionRange>[2.0,)</versionRange>
                                        <goals>
                                            <goal>test</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.alfresco.maven.plugin</groupId>
                                        <artifactId>alfresco-maven-plugin</artifactId>
                                        <versionRange>[0.0,)</versionRange>
                                        <goals>
                                            <goal>set-version</goal>
                                            <goal>add-amp-resources</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-antrun-plugin</artifactId>
                                        <versionRange>[0.0,)</versionRange>
                                        <goals>
                                            <goal>run</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.maven.plugins</groupId>
                                        <artifactId>maven-enforcer-plugin</artifactId>
                                        <versionRange>[0.0,)</versionRange>
                                        <goals>
                                            <goal>enforce</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>net.alchim31.maven</groupId>
                                        <artifactId>yuicompressor-maven-plugin</artifactId>
                                        <versionRange>[0.0,)</versionRange>
                                        <goals>
                                            <goal>compress</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.codehaus.mojo</groupId>
                                        <artifactId>build-helper-maven-plugin</artifactId>
                                        <versionRange>[0.0,)</versionRange>
                                        <goals>
                                            <goal>regex-property</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore />
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
         <profile>
            <id>alf42</id>
            <properties>
                <war.artifactId.repo>alfresco</war.artifactId.repo>
                <war.artifactId.share>share</war.artifactId.share>
            </properties>
        </profile>
         <profile>
            <id>skip-amp-apply-by-default</id>
            <activation>
                <property><name>!applyAmps</name></property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.alfresco.maven.plugin</groupId>
                        <artifactId>alfresco-maven-plugin</artifactId>
                        <configuration>
                            <skipAmpInstallation>true</skipAmpInstallation>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>skip-integration-tests-by-default</id>
            <activation>
                <property><name>!runIntegrationTests</name></property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <configuration>
                            <excludes>
                                <exclude>**/*IntegrationTest.*</exclude>
                            </excludes>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>run-integration-tests</id>
            <activation>
                <property>
                    <name>runIntegrationTests</name>
                </property>
            </activation>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-antrun-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>copy</id>
                                    <phase>process-test-resources</phase>
                                    <goals>
                                        <goal>run</goal>
                                    </goals>
                                    <configuration>
                                        <tasks>
                                            <copy file="${alfresco.repository.properties.file}" tofile="${project.build.directory}/test-classes/alfresco-global.properties" />
                                        </tasks>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                        <!-- Unpack the test resources from the jar as the current 
                            loading in AbstractContentTransformerTest doesn't like things in jars -->
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-dependency-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>unpack-test-resources</id>
                                    <phase>generate-test-resources</phase>
                                    <goals>
                                        <goal>unpack</goal>
                                    </goals>
                                    <configuration>
                                        <artifactItems>
                                            <artifactItem>
                                                <groupId>${alfresco.groupId}</groupId>
                                                <artifactId>alfresco-repository</artifactId>
                                                <version>${alfresco.version}</version>
                                                <type>test-jar</type>
                                                <overWrite>false</overWrite>
                                                <includes>**/org/alfresco/RepositoryStartupTest.*,quick/**</includes>
                                                <outputDirectory>${project.build.directory}/test-classes</outputDirectory>
                                            </artifactItem>
                                        </artifactItems>
                                        <overWriteReleases>false</overWriteReleases>
                                        <overWriteSnapshots>false</overWriteSnapshots>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-surefire-plugin</artifactId>
                            <configuration>
                                <argLine>-Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m</argLine>
                            </configuration>
                            <executions>
                                <execution>
                                    <id>pre-startup-test</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>process-test-classes</phase>
                                    <configuration>
                                        <forkMode>always</forkMode>
                                        <includes>
                                            <include>**/org/alfresco/RepositoryStartupTest.*</include>
                                        </includes>
                                    </configuration>
                                </execution>
                                <execution>
                                    <id>default-test</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>test</phase>
                                    <configuration>
                                        <excludes>
                                            <exclude>**/*IntegrationTest.*</exclude>
                                            <exclude>**/org/alfresco/RepositoryStartupTest.*</exclude>
                                        </excludes>
                                    </configuration>
                                </execution>
                                <execution>
                                    <id>integ-test</id>
                                    <goals>
                                        <goal>test</goal>
                                    </goals>
                                    <phase>test</phase>
                                    <configuration>
                                        <includes>
                                            <include>**/*IntegrationTest.*</include>
                                        </includes>
                                    </configuration>
                                </execution>                                
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
        <profile>
            <id>no-username</id>
            <activation>
                <property>
                    <name>!db.username</name>
                </property>
            </activation>
            <properties>
                <db.username>alfresco</db.username>
                <db.password>alfresco</db.password>
            </properties>
        </profile>
        <profile>
            <id>no-name</id>
            <activation>
                <property>
                    <name>!db.name</name>
                </property>
            </activation>
            <properties>
                <db.name>alfresco</db.name>
            </properties>
        </profile>
        <profile>
            <!-- Wipe the database before starting tests -->
            <id>wipe-db</id>
            <activation>
                <property>
                    <name>wipeDB</name>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>properties-maven-plugin</artifactId>
                        <version>1.0-alpha-2</version>
                        <executions>
                            <execution>
                                <id>read-db-properties</id>
                                <phase>validate</phase>
                                <goals>
                                    <goal>read-project-properties</goal>
                                </goals>
                                <configuration>
                                    <files>
                                        <file>${alfresco.repository.properties.file}</file>
                                    </files>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>build-helper-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>regex-property-db-master-url</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>regex-property</goal>
                                </goals>
                                <configuration>
                                    <name>db.master.url</name>
                                    <value>${db.url}</value>
                                    <regex>${db.name}</regex>
                                    <replacement>template1</replacement>
                                    <failIfNoMatch>false</failIfNoMatch>
                                </configuration>
                            </execution>
                            <execution>
                                <id>regex-property-db-sql-create-mysql</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>regex-property</goal>
                                </goals>
                                <configuration>
                                    <name>db.sql.create.clause</name>
                                    <value>${db.driver}</value>
                                    <regex>com\.mysql\.jdbc\.Driver</regex>
                                    <replacement>CHARACTER SET utf8 COLLATE utf8_bin</replacement>
                                    <failIfNoMatch>false</failIfNoMatch>
                                </configuration>
                            </execution>
                            <execution>
                                <id>regex-property-db-sql-create-pgsql</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>regex-property</goal>
                                </goals>
                                <configuration>
                                    <name>db.sql.create.clause</name>
                                    <value>${db.driver}</value>
                                    <regex>org\.postgresql\.Driver</regex>
                                    <replacement>OWNER ${db.username} ENCODING 'unicode'</replacement>
                                    <failIfNoMatch>false</failIfNoMatch>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <configuration>
                            <autocommit>true</autocommit>
                            <driver>${db.driver}</driver>
                            <url>${db.master.url}</url>
                            <username>${db.username}</username>
                            <password>${db.password}</password>
                        </configuration>
                        <executions>
                            <execution>
                                <id>wipe-database</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <sqlCommand>drop database if exists ${db.name}</sqlCommand>
                                </configuration>
                            </execution>
                            <execution>
                                <id>create-database</id>
                                <phase>process-test-resources</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <sqlCommand>create database ${db.name} ${db.sql.create.clause}</sqlCommand>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>postgresql</groupId>
                                <artifactId>postgresql</artifactId>
                                <version>${dependency.postgresqlconnector.version}</version>
                            </dependency>
                            <dependency>
                                <groupId>mysql</groupId>
                                <artifactId>mysql-connector-java</artifactId>
                                <version>${dependency.mysqlconnector.version}</version>
                            </dependency>
                        </dependencies>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
            <id>wars-from-devenv</id>
            <properties>
                <alfresco.repository.properties.file>${user.home}/Development/projects/${env.CURRENT_PROJECT}/data/repository.properties</alfresco.repository.properties.file>
                <war.file.repo>${user.home}/Development/projects/${env.CURRENT_PROJECT}/software/tomcat/webapps/alfresco.war</war.file.repo>
                <war.file.share>${user.home}/Development/projects/${env.CURRENT_PROJECT}/software/tomcat-app/webapps/share.war</war.file.share>
            </properties>
        </profile>
        <profile>
            <id>wars-from-devenv-exploded</id>
            <properties>
                <alfresco.repository.properties.file>${user.home}/Development/projects/${env.CURRENT_PROJECT}/data/repository.properties</alfresco.repository.properties.file>
                <war.file.repo>${user.home}/Development/projects/${env.CURRENT_PROJECT}/software/tomcat/webapps/alfresco</war.file.repo>
                <war.file.share>${user.home}/Development/projects/${env.CURRENT_PROJECT}/software/tomcat-app/webapps/share</war.file.share>
            </properties>
        </profile>
        <profile>
            <id>wars-from-maven</id>
            <properties>
                <war.file.repo>${project.build.directory}/wars/${war.artifactId.repo}.war</war.file.repo>
                <war.file.share>${project.build.directory}/wars/${war.artifactId.share}.war</war.file.share>
            </properties>
            <build>
                <pluginManagement>
                    <plugins>
                        <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-dependency-plugin</artifactId>
                            <executions>
                                <execution>
                                    <id>copy</id>
                                    <phase>package</phase>
                                    <goals>
                                        <goal>copy</goal>
                                    </goals>
                                    <configuration>
                                        <artifactItems>
                                            <artifactItem>
                                                <groupId>${alfresco.groupId}</groupId>
                                                <artifactId>${war.artifactId}</artifactId>
                                                <version>${alfresco.version}</version>
                                                <type>war</type>
                                                <destFileName>${war.artifactId}.war</destFileName>
                                            </artifactItem>
                                        </artifactItems>
                                        <outputDirectory>${project.build.directory}/wars</outputDirectory>
                                        <overWriteReleases>false</overWriteReleases>
                                        <overWriteSnapshots>true</overWriteSnapshots>
                                    </configuration>
                                </execution>
                            </executions>
                        </plugin>
                    </plugins>
                </pluginManagement>
            </build>
        </profile>
    </profiles>

</project>
