<?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>
    <artifactId>download-limit-repo</artifactId>
    <name>download-limit-repo AMP project</name>
    <packaging>amp</packaging>
    <description>Manages the lifecycle of the download-limit-repo AMP (Alfresco Module Package) allowing to limit user downloads of content</description>

    <parent>
        <groupId>org.alfresco.consulting</groupId>
        <artifactId>download-limit-parent</artifactId>
        <version>1.0-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <!-- 
       | SDK properties have sensible defaults in the SDK parent,
       | but you can override the properties below to use another version. 
       | For more available properties see the alfresco-sdk-parent POM. 
       -->
    <properties>
        <alfresco.data.location>alf_data_dev</alfresco.data.location>
        <!-- Defines the target WAR artifactId to run this amp, only used with the -Pamp-to-war switch
        .    | Allowed values: alfresco | share. Defaults to a repository AMP, but could point to your foundation WAR -->
        <alfresco.client.war>alfresco</alfresco.client.war>
    </properties>

    <!-- Following dependencies are needed for compiling Java code in src/main/java; 
         <scope>provided</scope> is inherited for each of the following; 
         for more info, please refer to alfresco-platform-distribution POM -->
    <dependencies>
        <dependency>
            <groupId>${alfresco.groupId}</groupId>
            <artifactId>alfresco-repository</artifactId>
        </dependency>
		<dependency>
			<groupId>${alfresco.groupId}</groupId>
			<artifactId>alfresco-remote-api</artifactId>
			<scope>provided</scope>
		</dependency>
		<dependency>
			<groupId>org.springframework</groupId>
			<artifactId>spring-context</artifactId>
			<version>3.0.5.RELEASE</version>
			<scope>provided</scope>
		</dependency>
    </dependencies>
    
    <profiles>
		<profile>
			<id>amp-to-war</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.mortbay.jetty</groupId>
						<artifactId>maven-jetty-plugin</artifactId>
						<executions>
							<execution>
								<id>run-amp-to-war</id>
									<configuration>
										<contextPath>/alfresco</contextPath>
									</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<!-- Integration test - Installs the WAR to an external Alfresco OOTB install and restarts -->
		<profile>
			<id>it</id>
			<properties>
				<alf.home>/Users/mindthegab/Dev/alfresco/workspace-cisco/alfresco-ootb</alf.home>
			</properties>
			<build>
				<plugins>
					<plugin>
						<groupId>org.alfresco.maven.plugin</groupId>
						<artifactId>alfresco-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>install-to-external-alf</id>
								<goals>
									<goal>install</goal>
								</goals>
								<phase>integration-test</phase>
								<configuration>
									<warLocation>${alf.home}/tomcat/webapps/${alfresco.client.war}.war</warLocation>
									<verbose>true</verbose>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<plugin>
        				<groupId>org.codehaus.mojo</groupId>
        				<artifactId>exec-maven-plugin</artifactId>
        				<version>1.2.1</version>
						<executions>
							<execution>
								<id>stop-external-alfresco</id>
								<goals>
              						<goal>exec</goal>
            					</goals>
								<phase>pre-integration-test</phase>
								<configuration>
									<executable>${alf.home}/alfresco.sh</executable>
									<arguments>
            							<argument>stop</argument>
            						</arguments>
								</configuration>
							</execution>
							<execution>
								<id>clean-exploded-webapp</id>
								<goals>
              						<goal>exec</goal>
            					</goals>
								<phase>integration-test</phase>
								<configuration>
									<executable>rm</executable>
									<arguments>
            							<argument>-rf</argument>
            							<argument>${alf.home}/tomcat/webapps/${alfresco.client.war}</argument>
            						</arguments>
								</configuration>
							</execution>
							<execution>
								<id>start-external-alfresco</id>
								<goals>
              						<goal>exec</goal>
            					</goals>
								<phase>post-integration-test</phase>
								<configuration>
									<executable>${alf.home}/alfresco.sh</executable>
									<arguments>
            							<argument>start</argument>
            						</arguments>
								</configuration>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
	</profiles>

</project>
