<?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>alfresco-sdk-parent</artifactId>
  <name>Maven Alfresco SDK - Parent POM</name>
  <description>
     The Maven Alfresco SDK Parent POM exposes the developer features of the Maven Alfresco SDK.
     Declare this POM as parent for your project and select the Alfresco version/edition by defining
     the alfresco.groupId and alfresco.version in your POM.
  </description>
  <packaging>pom</packaging>

  <!-- This parent is only needed for SDK release purposes. It does not add behaviors -->
  <parent>
    <groupId>org.alfresco.maven</groupId>
    <artifactId>alfresco-sdk-aggregator</artifactId>
    <version>2.0.0-beta-4</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>

  <!-- This defines the version of the SDK in terms of features -->
  <version>2.0.0-beta-4</version>

  <prerequisites>
    <maven>3.2.2</maven>
  </prerequisites>

  <properties>
    <!--  Default Alfresco version this SDK version has been tested with:
        |
        | alfresco.groupId can be
        | org.alfresco ==> Alfresco community
        | org.alfresco.enterprise ==> Alfresco Enterprise
        |
        | NOTE: You can / should override these properties in you POM to select the proper version
        |
        | For available versions please search on https://artifacts.alfresco.com/nexus/index.html
        -->
    <alfresco.groupId>org.alfresco</alfresco.groupId>
    <alfresco.version>5.0.a</alfresco.version>

    <!--  Values can be "alfresco" or "share". Default value is 'alfresco' assuming you are developing a repository AMP, change to share for share AMPs
        | This impact (in AMP projects) the choice of the WAR project for embedded run
         -->
    <alfresco.client.war>alfresco</alfresco.client.war>
    <alfresco.client.war.groupId>${alfresco.groupId}</alfresco.client.war.groupId>
    <alfresco.client.war.version>${alfresco.version}</alfresco.client.war.version>
    <alfresco.client.contextPath>/${alfresco.client.war}</alfresco.client.contextPath>

    <!-- IMPORTANT! Override this only if you know what you're doing; it could break amp-to-war overlay -->
    <alfresco.client.war.folder>${project.build.directory}/${project.build.finalName}-war</alfresco.client.war.folder>

    <!-- Alfresco Repo disk storage folder (relative path) -->
    <alfresco.data.location>alf_data_dev</alfresco.data.location>
    <!-- Alfresco Repo configuration with embedded DB -->
    <alfresco.db.name>alf_dev</alfresco.db.name>
    <alfresco.db.username>alfresco</alfresco.db.username>
    <alfresco.db.password>alfresco</alfresco.db.password>
    <alfresco.db.params>MODE=PostgreSQL;AUTO_SERVER=TRUE;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=10000;MVCC=FALSE;LOCK_MODE=0</alfresco.db.params>
    <!-- By default the H2 embedded database datafile is created under the alfresco.data.location folder -->
    <alfresco.db.url>jdbc:h2:./${alfresco.data.location}/h2_data/${alfresco.db.name};${alfresco.db.params}</alfresco.db.url>
    <alfresco.db.datasource.class>org.h2.jdbcx.JdbcDataSource</alfresco.db.datasource.class>

    <!-- SDK Properties -->
    <!--
    Built-in multi-environment property placeholding support (also for testing); to enable it on your sub-modules
    * create app.properties.folder (default=src/main/properties/${env}) folder structure
    * place properties files in that folder with the correct name
    Both 'alfresco' and 'share' sub-modules currently use it.
    -->
    <env>local</env>
    <!--  Be default we assume to we load all properties files under ${app.properties.folder}
        | and
        | This can be overridden your pom
     -->
    <app.amp.folder>src/main/amp</app.amp.folder>
    <app.amp.output.folder>../${project.build.finalName}</app.amp.output.folder>
    <!-- AMP excludes when installing into a WAR, by default empty (i.e. everything is included) -->
    <app.amp.overlay.excludes />
    <!-- Empty AMP source excludes by default, see the amp-to-war profile for usage example -->
    <app.amp.excludes />
    <app.properties.folder>src/main/properties/${env}</app.properties.folder>
    <app.properties.test.folder>src/test/properties/${env}</app.properties.test.folder>
    <app.properties.include>**</app.properties.include>
    <app.properties.test.include>**</app.properties.test.include>

    <!--  Turns on/off POM properties filtering globally. By default filtering is on.
        | This can be overridden in your POM, but do it at your own risk
        | as it may break SDK functionalities
         -->
    <app.filtering.enabled>true</app.filtering.enabled>
    <app.testing.jvm.args>-Xms256m -Xmx1524m -XX:MaxPermSize=256m -Duser.language=en</app.testing.jvm.args>

    <!--  Logging in project's target folder by default
        | NOTE: Remember the trailing slash when overriding this.
         -->
    <app.log.dir>${project.build.directory}/</app.log.dir>
    <app.log.root.level>WARN</app.log.root.level>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

    <!-- Maven Plugins Versions used by the SDK -->
    <maven.compiler.version>3.1</maven.compiler.version>
    <maven.clean.version>2.5</maven.clean.version>
    <maven.dependency.version>2.8</maven.dependency.version>
    <maven.enforcer.plugin>1.3.1</maven.enforcer.plugin>
    <maven.resources.version>2.6</maven.resources.version>
    <maven.surefire.version>2.16</maven.surefire.version>
    <maven.install.version>2.5.1</maven.install.version>
    <maven.jar.version>2.4</maven.jar.version>
    <maven.war.version>2.4</maven.war.version>
    <maven.release.version>2.4.2</maven.release.version>
    <maven.buildhelper.version>1.8</maven.buildhelper.version>
    <maven.replacer.version>1.5.3</maven.replacer.version>
    <maven.tomcat.version>2.1</maven.tomcat.version>
    <!-- This is used for the site deployment procedure (override in your POM as needed) -->
    <stagingDirectory>../../target/staging/poms/alfresco-sdk-parent</stagingDirectory>
    <!-- Maven Alfresco plugin in use throughout the SDK -->
    <maven.alfresco.version>2.0.0-beta-4</maven.alfresco.version>
    <h2.version>1.3.174</h2.version>
    <h2-support.version>1.5</h2-support.version>
    <junit.version>4.11</junit.version>
  </properties>

  <!-- This repository is only needed to retrieve Alfresco parent POM. 
        NOTE: This can be removed when/if Alfresco will be on Maven Central 
        
        NOTE: The repository to be used for Alfresco Enterprise artifacts is
        https://artifacts.alfresco.com/nexus/content/groups/private/. Please check
        with Alfresco Support to get credentials to add to your ~/.m2/settings.xml
        if you are a Enterprise customer or Partner  
        -->
    <repositories>
        <repository>
            <id>alfresco-public</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
        </repository>
        <repository>
            <id>alfresco-public-snapshots</id>
            <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
            <snapshots>
                <enabled>true</enabled>
                <updatePolicy>daily</updatePolicy>
            </snapshots>
        </repository>
    </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>alfresco-plugin-public</id>
      <url>https://artifacts.alfresco.com/nexus/content/groups/public</url>
    </pluginRepository>
    <pluginRepository>
      <id>alfresco-plugin-public-snapshots</id>
      <url>https://artifacts.alfresco.com/nexus/content/groups/public-snapshots</url>
      <snapshots>
        <enabled>true</enabled>
        <updatePolicy>daily</updatePolicy>
      </snapshots>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <finalName>${project.artifactId}</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.alfresco.maven.plugin</groupId>
          <artifactId>alfresco-maven-plugin</artifactId>
          <version>${maven.alfresco.version}</version>
          <extensions>true</extensions>
          <configuration>
              <snapshotToTimestamp>true</snapshotToTimestamp>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven.compiler.version}</version>
          <configuration>
            <source>1.7</source>
            <target>1.7</target>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-resources-plugin</artifactId>
          <version>${maven.resources.version}</version>
          <configuration>
            <encoding>UTF-8</encoding>
            <nonFilteredFileExtensions>
              <nonFilteredFileExtension>ftl</nonFilteredFileExtension>
              <nonFilteredFileExtension>acp</nonFilteredFileExtension>
              <nonFilteredFileExtension>jpg</nonFilteredFileExtension>
              <nonFilteredFileExtension>png</nonFilteredFileExtension>
              <nonFilteredFileExtension>gif</nonFilteredFileExtension>
              <nonFilteredFileExtension>pdf</nonFilteredFileExtension>
              <nonFilteredFileExtension>doc</nonFilteredFileExtension>
              <nonFilteredFileExtension>docx</nonFilteredFileExtension>
              <nonFilteredFileExtension>xls</nonFilteredFileExtension>
              <nonFilteredFileExtension>xlsx</nonFilteredFileExtension>
              <nonFilteredFileExtension>ppt</nonFilteredFileExtension>
              <nonFilteredFileExtension>pptx</nonFilteredFileExtension>
              <nonFilteredFileExtension>bin</nonFilteredFileExtension>
              <nonFilteredFileExtension>lic</nonFilteredFileExtension>
              <nonFilteredFileExtension>swf</nonFilteredFileExtension>
              <nonFilteredFileExtension>zip</nonFilteredFileExtension>
              <nonFilteredFileExtension>msg</nonFilteredFileExtension>
            </nonFilteredFileExtensions>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>${maven.war.version}</version>
          <configuration>
            <archiveClasses>false</archiveClasses>
            <archive>
                <manifest>
                    <addClasspath>true</addClasspath>
                </manifest>
            </archive>
          </configuration>
          <dependencies>
                <dependency>
                    <groupId>org.alfresco.maven.plugin</groupId>
                    <artifactId>alfresco-maven-plugin</artifactId>
                    <version>${maven.alfresco.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-archiver</artifactId>
                    <version>2.3</version>
                </dependency>
          </dependencies>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-clean-plugin</artifactId>
          <version>${maven.clean.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>${maven.dependency.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-surefire-plugin</artifactId>
          <version>${maven.surefire.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-install-plugin</artifactId>
          <version>${maven.install.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven.jar.version}</version>
        </plugin>
        <plugin>
          <groupId>com.google.code.maven-replacer-plugin</groupId>
          <artifactId>replacer</artifactId>
          <version>${maven.replacer.version}</version>
        </plugin>
        <!-- Configures tomcat with proper deps and performance fixes -->
        <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <version>${maven.tomcat.version}</version>
            <configuration>
                <useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>com.h2database</groupId>
                    <artifactId>h2</artifactId>
                    <version>${h2.version}</version>
                </dependency>
                <dependency>
                    <groupId>tk.skuro.alfresco</groupId>
                    <artifactId>h2-support</artifactId>
                    <version>${h2-support.version}</version>
                </dependency>
                <!-- Major performance improvement,
                see http://mindthegab.com/2013/06/20/maven-is-not-so-evil-plexus-archives-2-3-is-a-life-saver-for-the-speed-of-your-war-development-with-maven/ -->
                <dependency>
                    <groupId>org.codehaus.plexus</groupId>
                    <artifactId>plexus-archiver</artifactId>
                    <version>2.3</version>
                </dependency>
            </dependencies>
        </plugin>
		<!--m2e configuration only to prevent errors in import.
			NOTE: This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself. -->
        <plugin>
            <groupId>org.eclipse.m2e</groupId>
            <artifactId>lifecycle-mapping</artifactId>
            <version>1.0.0</version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>org.alfresco.maven.plugin</groupId>
                                <artifactId>alfresco-maven-plugin</artifactId>
                                <versionRange>[0.0,)</versionRange>
                                <goals>
                                    <goal>set-version</goal>
                                </goals>
                            </pluginExecutionFilter>
                            <action>
                                <execute>
                                    <runOnIncremental>true</runOnIncremental>
                                    <runOnConfiguration>true</runOnConfiguration>
                                </execute>
                            </action>
                        </pluginExecution>
                    </pluginExecutions>
                </lifecycleMappingMetadata>
            </configuration>
        </plugin>
      </plugins>
    </pluginManagement>

    <resources>
        <resource>
            <directory>src/main/resources</directory>
            <filtering>${app.filtering.enabled}</filtering>
        </resource>
		<resource>
			<directory>${app.amp.folder}</directory>
			<targetPath>${app.amp.output.folder}</targetPath>
			<filtering>${app.filtering.enabled}</filtering>
		</resource>
    </resources>
    <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <filtering>${app.filtering.enabled}</filtering>
        </testResource>
    </testResources>
  </build>

  <!-- Feature / behavioral profiles -->
  <profiles>
    <!-- Enable environment properties filtering based on the env property -->
    <profile>
        <id>enable-properties-filtering</id>
        <activation>
            <file>
                <!-- No properties allowed here. Only hardcoded values are properly interpreted -->
                <exists>src/main/properties</exists>
            </file>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>${maven.buildhelper.version}</version>
                    <executions>
                        <execution>
                            <id>add-env-properties</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>add-resource</goal>
                            </goals>
                            <configuration>
                                <resources>
                                    <resource>
                                        <directory>${app.properties.folder}</directory>
                                        <includes>
                                            <include>${app.properties.include}</include>
                                        </includes>
                                        <filtering>${app.filtering.enabled}</filtering>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

    <!-- Enable environment test properties filtering based on the env property -->
    <profile>
        <id>enable-test-properties-filtering</id>
        <activation>
            <file>
                <!-- No properties allowed here. Only hardcoded values are properly interpreted -->
                <exists>src/test/properties</exists>
            </file>
        </activation>
        <build>
            <plugins>
                <plugin>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>build-helper-maven-plugin</artifactId>
                    <version>${maven.buildhelper.version}</version>
                    <executions>
                        <execution>
                            <id>add-env-test-properties</id>
                            <phase>generate-resources</phase>
                            <goals>
                                <goal>add-test-resource</goal>
                            </goals>
                            <configuration>
                                <resources>
                                    <resource>
                                        <directory>${app.properties.test.folder}</directory>
                                        <includes>
                                            <include>${app.properties.test.include}</include>
                                        </includes>
                                        <filtering>${app.filtering.enabled}</filtering>
                                    </resource>
                                </resources>
                            </configuration>
                        </execution>
                    </executions>
                </plugin>
            </plugins>
        </build>
    </profile>

    <!-- Enable AMP lifecycle if finds a module.properties, including unit testing support -->
    <profile>
      <id>enable-amp</id>
      <activation>
        <file>
          <exists>src/main/amp/module.properties</exists>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.alfresco.maven.plugin</groupId>
            <artifactId>alfresco-maven-plugin</artifactId>
            <extensions>true</extensions>
          </plugin>
          <!-- Copies module properties to the test classpath in the right location, so that it can be picked up by tests and tomcat embedded -->
          <plugin>
              <artifactId>maven-resources-plugin</artifactId>
              <executions>
                  <execution>
                      <id>add-module-properties-to-test-classpath</id>
                      <phase>process-test-resources</phase>
                      <goals>
                          <goal>copy-resources</goal>
                      </goals>
                      <configuration>
                          <outputDirectory>${project.build.testOutputDirectory}</outputDirectory>
                          <resources>
                              <resource>
                                  <directory>${app.amp.folder}</directory>
                                  <includes>
                                      <include>module.properties</include>
                                  </includes>
                                  <filtering>${app.filtering.enabled}</filtering>
                                  <targetPath>alfresco/module/${project.artifactId}</targetPath>
                              </resource>
                          </resources>
                      </configuration>
                  </execution>
              </executions>
            </plugin>
        </plugins>        
      </build>
      
    </profile>
    
    <!-- Enables alfresco testing dependencies if a src/test/java folder is found, by adding appropriate dependencies -->
    <profile>
    	<id>enable-alfresco-testing</id>
        <activation>
            <file>
                <exists>src/test/java</exists>
            </file>
        </activation>
        <build>
            <plugins>
                <plugin>
                  <groupId>org.apache.maven.plugins</groupId>
                  <artifactId>maven-surefire-plugin</artifactId>
                  <version>${maven.surefire.version}</version>
                  <configuration>
                      <argLine>${app.testing.jvm.args}</argLine>
                      <additionalClasspathElements>
                         <!-- Adds both the module config to test classpath --> 
                         <additionalClasspathElement>${project.build.directory}/${project.build.finalName}/config</additionalClasspathElement>
                      </additionalClasspathElements>
                  </configuration>
                </plugin>
            </plugins>
        </build>
    	<dependencies>
        	<dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <scope>test</scope>
              </dependency>
              <!-- Add RAD capabilities for remote JUnit test running. Scope=test so the custom JUnit remote runner is found in the Maven test classpath -->
              <dependency>
                  <groupId>org.alfresco.maven</groupId>
                  <artifactId>alfresco-rad</artifactId>
                  <version>${maven.alfresco.version}</version>
                  <scope>test</scope>
              </dependency>
              <!--
              |    Requires this explicit test dependency, for a Spring 3.0.5 bug
              |    See https://jira.springsource.org/browse/SPR-8527
              -->
              <dependency>
                  <groupId>org.springframework</groupId>
                  <artifactId>spring-context</artifactId>
                  <version>3.0.6.RELEASE</version>
                  <scope>provided</scope>
              </dependency>
              <!-- SDK AMP Testing Dependencies -->
              <dependency>
                <groupId>com.h2database</groupId>
                <artifactId>h2</artifactId>
                <version>${h2.version}</version>
                <scope>test</scope>
              </dependency>
              <dependency>
                <groupId>tk.skuro.alfresco</groupId>
                <artifactId>h2-support</artifactId>
                <version>${h2-support.version}</version>
                <scope>test</scope>
              </dependency>
    	</dependencies>
    </profile>

    <!-- Profile to enable rapid application development with JRebel. Automatically generates rebel.xml files. 
    	 NOTE: This experimental feature added in the SDK 1.1.0 is now deprecated as of version 2.x in favor of spring-loaded.
         Use at your own risk. This profile needs to be called explicitly with -Pjrebel -->
    <profile>
      <id>jrebel</id>
      <build>
        <plugins>
            <plugin>
                <groupId>org.zeroturnaround</groupId>
                <artifactId>jrebel-maven-plugin</artifactId>
                <version>1.1.5</version>
                <executions>
                  <execution>
                    <id>generate-rebel-xml</id>
                    <phase>prepare-package</phase>
                    <goals>
                      <goal>generate</goal>
                    </goals>
                  </execution>
                </executions>
                <configuration>
                    <packaging>war</packaging>
                    <generateDefaultElements>false</generateDefaultElements>
                    <classpath>
                        <resources>
                            <resource>
                                <directory>${project.build.outputDirectory}</directory>
                            </resource>
                            <resource>
                                <directory>${project.build.testOutputDirectory}</directory>
                            </resource>
                        </resources>
                    </classpath>
                    <web>
                        <resources>
                            <resource>
                                <target>/</target>
                                <directory>${project.build.directory}/${project.build.finalName}</directory>
                            </resource>
                            <resource>
                                <target>/</target>
                                <directory>${project.build.directory}/${project.build.finalName}-war</directory>
                            </resource>
                        </resources>
                    </web>
                </configuration>
            </plugin>
        </plugins>
      </build>
    </profile>

    <!-- Enable AMP project packing on a WAR and run embedded in Tomcat -->
    <profile>
      <id>amp-to-war</id>
      <properties>
        <skipTests>true</skipTests>
      </properties>
      <build>
        <plugins>
          <!-- Fetch and unpack Alfresco Repository / Share in the target / folder -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>unpack-alfresco</id>
                <phase>prepare-package</phase>
                <goals><goal>unpack</goal></goals>
                <configuration>
                  <outputDirectory>${alfresco.client.war.folder}</outputDirectory>
                  <artifactItems>
                    <artifactItem>
                      <groupId>${alfresco.client.war.groupId}</groupId>
                      <artifactId>${alfresco.client.war}</artifactId>
                      <type>war</type>
                      <version>${alfresco.client.war.version}</version>
                    </artifactItem>
                  </artifactItems>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <!-- The current AMP artifact is installed into the Alfresco folder using alfresco-maven-plugin -->
          <plugin>
            <groupId>org.alfresco.maven.plugin</groupId>
            <artifactId>alfresco-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>amps-to-war-overlay</id>
                <phase>package</phase>
                <goals>
                  <goal>install</goal>
                </goals>
              </execution>
            </executions>
            <configuration>
                <!-- We need to selectively not install web resources so to enable rapid dev -->
                <includeWebResources>false</includeWebResources>
            </configuration>
          </plugin>
          <!-- Configures tomcat to run against the Alfresco WAR with Tomcat7 virtual webapp features. 
               (http://tomcat.apache.org/tomcat-7.0-doc/config/context.html#Virtual_webapp)	 	
          	   The target/classes and target/test-classes (containing tests and the amp config for test purposes) are prepended to the 
          	   running webapp context, so changes from the IDE are automatically picked up first. See context.xml for details. 
          -->
          <plugin>
            <groupId>org.apache.tomcat.maven</groupId>
            <artifactId>tomcat7-maven-plugin</artifactId>
            <executions>
                <execution>
                    <id>run-embedded</id>
                    <goals>
                        <goal>run</goal>
                    </goals>
                    <phase>integration-test</phase>
                    <configuration>
                          <useTestClasspath>false</useTestClasspath>
                          <ignorePackaging>true</ignorePackaging>
                          <useSeparateTomcatClassLoader>true</useSeparateTomcatClassLoader>
                          <systemProperties>
                            <java.io.tmpdir>${project.build.directory}</java.io.tmpdir>
                          </systemProperties>
                          <delegate>true</delegate>
                          <contextFile>${project.basedir}/tomcat/context.xml</contextFile>
                    </configuration>
                </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
      <dependencies>
        <!-- Needed to fix http://code.google.com/p/maven-alfresco-archetypes/issues/detail?id=150 -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>1.5.11</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.5.11</version>
        </dependency>
		<dependency>
			<groupId>org.alfresco.maven</groupId>
			<artifactId>alfresco-rad</artifactId>
			<version>${maven.alfresco.version}</version>
		</dependency>
      </dependencies>
    </profile>

    <!-- Cleans Alfresco data folder, embedded DB and any log file found -->
    <profile>
        <id>purge</id>
        <build>
            <plugins>
                  <!-- Cleaning Alfresco Repository storage/log folders/files -->
                  <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-clean-plugin</artifactId>
                    <configuration>
                      <filesets>
                        <fileset>
                          <directory>${project.basedir}/${alfresco.data.location}</directory>
                        </fileset>
                        <fileset>
                          <directory>${project.basedir}/solr_home</directory>
                        </fileset>
                        <fileset>
                          <directory>${project.basedir}</directory>
                          <includes>
                            <include>**/*.log</include>
                          </includes>
                        </fileset>
                      </filesets>
                    </configuration>
                  </plugin>
            </plugins>
        </build>
    </profile>
    <!-- Enforce SDK rules for clearer fast fail error messaging and safer usage  -->
    <profile>
        <id>enforce-sdk-rules</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <build>
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>${maven.enforcer.plugin}</version>
                <executions>
                  <execution>
                    <id>enforce-sdk-requirements</id>
                    <goals>
                      <goal>enforce</goal>
                    </goals>
                    <configuration>
                      <rules>
                         <!-- Test for Alfresco version -->
                         <requireProperty>
                            <property>alfresco.version</property>
                            <message>The SDK 2.x is supported only for Alfresco 5.x Community and Enterprise versions</message>
                            <regex>^5\..*</regex>
                         </requireProperty>
                         <!-- Test for JDK version -->
                         <requireJavaVersion>
                            <version>[1.7.0,)</version>
                            <message>Alfresco 5+ requires Java 7</message>
                         </requireJavaVersion>
                      </rules>
                      <fail>true</fail>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
            </plugins>
        </build>
    </profile>
    <!-- Does any SDK dev environment preparation (e.g. spring-loaded download)  -->
    <profile>
        <id>setup</id>
        <activation>
            <activeByDefault>false</activeByDefault>
        </activation>
       <build>
             <!-- This simply downloads the spring-loaded jar to ~/.m2/repository/org/springframework/spring-loaded/${springloaded.version}/spring-loaded-${springloaded.version}.jar -->
            <plugins>
              <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                  <execution>
                    <id>get-spring-loaded</id>
                    <phase>validate</phase>
                    <goals><goal>get</goal></goals>
                    <configuration>
                      <artifact>org.springframework:springloaded:${springloaded.version}</artifact>
                    </configuration>
                  </execution>
                </executions>
              </plugin>
            </plugins>
       </build>
    </profile>
  </profiles>
</project>
