<?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-developer-parent</artifactId>
  <name>Alfresco Developer Parent</name>
  <packaging>pom</packaging>
  <version>1</version>
  <groupId>org.alfresco.integration</groupId>

  <prerequisites>
    <maven>3.0.3</maven>
  </prerequisites>

  <properties>
    <!-- Maven Plugins Versions -->
    <maven.compiler.version>2.3.2</maven.compiler.version>
    <maven.clean.version>2.4.1</maven.clean.version>
    <maven.dependency.version>2.4</maven.dependency.version>
    <maven.resources.version>2.5</maven.resources.version>
    <maven.install.version>2.3.1</maven.install.version>
    <maven.jar.version>2.4</maven.jar.version>
    <maven.war.version>2.2</maven.war.version>
    <maven.release.version>2.2.2</maven.release.version>
    <alfresco.maven.version>0.6-SNAPSHOT</alfresco.maven.version>
    <maven.jetty.version>6.1.26</maven.jetty.version>
	<h2.version>1.3.158</h2.version>
    <h2-support.version>1.2</h2-support.version>

    <!-- Alfresco Repo disk storage folder (relative path) -->
    <alfresco.data.location>alf_data_jetty</alfresco.data.location>

    <!-- Context names used by webapps -->
    <webapp.name>${project.artifactId}</webapp.name>

    <!--
    Built-in multi-environment property placeholding support; to enable it on your sub-module
    * create src/main/properties/${env} folder structure
    * place <anyname>.properties and define <webapp.resource.filter> with the correct name
    Both 'alfresco' and 'share' sub-modules currently use it
    -->
    <env>local</env>
    <webapp.resource.filter>alfresco-global.properties</webapp.resource.filter>
    <webapp.resource.build.folder>${project.build.outputDirectory}</webapp.resource.build.folder>
  </properties>

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

  <build>
    <finalName>${webapp.name}</finalName>
    <pluginManagement>
      <plugins>
        <plugin>
          <groupId>org.alfresco.maven.plugin</groupId>
          <artifactId>alfresco-maven-plugin</artifactId>
          <version>${alfresco.maven.version}</version>
          <extensions>true</extensions>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-compiler-plugin</artifactId>
          <version>${maven.compiler.version}</version>
          <configuration>
            <source>1.6</source>
            <target>1.6</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>
            </nonFilteredFileExtensions>
          </configuration>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-war-plugin</artifactId>
          <version>${maven.war.version}</version>
          <configuration>
            <archiveClasses>false</archiveClasses>
            <warSourceExcludes>tools/**</warSourceExcludes>
          </configuration>
        </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-install-plugin</artifactId>
          <version>${maven.install.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-release-plugin</artifactId>
          <version>${maven.release.version}</version>
        </plugin>
        <plugin>
          <groupId>org.apache.maven.plugins</groupId>
          <artifactId>maven-jar-plugin</artifactId>
          <version>${maven.jar.version}</version>
        </plugin>
        <plugin>
          <groupId>org.mortbay.jetty</groupId>
          <artifactId>maven-jetty-plugin</artifactId>
          <version>${maven.jetty.version}</version>
        </plugin>
      </plugins>
    </pluginManagement>

    <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}</directory>
              <includes>
                <include>*.log</include>
              </includes>
            </fileset>
          </filesets>
        </configuration>
      </plugin>
      <!-- All artifacts with AMP extensions are unpacked
using a WAR layout on an empty 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>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>enable-filtering</id>
      <activation>
        <file>
          <exists>src/main/properties</exists>
        </file>
      </activation>
      <properties>
        <webapp.resource.filter.folder>src/main/properties/${env}</webapp.resource.filter.folder>
        <webapp.testresource.filter.folder>src/main/properties/${env}</webapp.testresource.filter.folder>
      </properties>
      <build>
        <filters>
          <filter>${webapp.resource.filter.folder}/${webapp.resource.filter}</filter>
        </filters>
        <pluginManagement>
          <plugins>
            <plugin>
              <groupId>org.apache.maven.plugins</groupId>
              <artifactId>maven-resources-plugin</artifactId>
              <executions>
                <execution>
                  <id>copy-filtered-resources</id>
                  <goals>
                    <goal>copy-resources</goal>
                  </goals>
                  <phase>process-resources</phase>
                  <configuration>
                    <outputDirectory>${webapp.resource.build.folder}</outputDirectory>
                    <resources>
                      <resource>
                        <directory>src/main/resources</directory>
                        <filtering>true</filtering>
                      </resource>
                      <resource>
                        <directory>${webapp.resource.filter.folder}</directory>
                        <includes>
                          <include>${webapp.resource.filter}</include>
                        </includes>
                        <filtering>true</filtering>
                        <targetPath>${webapp.resource.build.folder}</targetPath>
                      </resource>
                    </resources>
                  </configuration>
                </execution>
              </executions>
            </plugin>
          </plugins>
        </pluginManagement>
        <testResources>
          <testResource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
          </testResource>
          <testResource>
            <directory>${webapp.testresource.filter.folder}</directory>
            <filtering>true</filtering>
          </testResource>
        </testResources>
      </build>
    </profile>
    <profile>
      <id>enable-embedded-jetty</id>
      <activation>
        <file>
          <exists>jetty</exists>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-resources-plugin</artifactId>
            <executions>
              <execution>
                <id>filter-jetty-conf</id>
                <goals>
                  <goal>copy-resources</goal>
                </goals>
                <phase>process-resources</phase>
                <configuration>
                  <outputDirectory>target</outputDirectory>
                  <resources>
                    <resource>
                      <directory>${project.basedir}/jetty</directory>
                      <filtering>true</filtering>
                    </resource>
                  </resources>
                </configuration>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <groupId>org.mortbay.jetty</groupId>
            <artifactId>maven-jetty-plugin</artifactId>
            <configuration>
              <jettyConfig>${project.build.directory}/jetty.xml</jettyConfig>
            </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>
            </dependencies>
          </plugin>
        </plugins>
      </build>
    </profile>
    <profile>
      <id>enable-amp-packaging</id>
      <activation>
        <file>
          <exists>module.properties</exists>
        </file>
      </activation>
      <build>
        <plugins>
          <plugin>
            <groupId>org.alfresco.maven.plugin</groupId>
            <artifactId>alfresco-maven-plugin</artifactId>
            <executions>
              <execution>
                <id>add-resources</id>
                <phase>validate</phase>
                <goals>
                  <goal>add-resources</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <distributionManagement>
    <repository>
      <id>alfresco-releases</id>
      <url>https://artifacts.alfresco.com/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
      <name>alfresco snapshots repository</name>
      <id>alfresco-snapshots</id>
      <url>https://artifacts.alfresco.com/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
  </distributionManagement>

</project>
