<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-rm-community-repo</artifactId>
   <name>Alfresco Records Management Community Repo</name>
   <description>Alfresco Record Management Community Repository Extension</description>
   <packaging>amp</packaging>

   <parent>
      <groupId>org.alfresco</groupId>
      <artifactId>alfresco-rm-community</artifactId>
      <version>2.6.b</version>
   </parent>

   <properties>
      <alfresco.data.location>${basedir}/target/alf_test_data</alfresco.data.location>
      <alfresco.db.hibernate.dialect>org.hibernate.dialect.H2Dialect</alfresco.db.hibernate.dialect>
      <alfresco.db.name>alfresco</alfresco.db.name>
      <alfresco.db.username>alfresco</alfresco.db.username>
      <alfresco.db.password>alfresco</alfresco.db.password>
      <alfresco.db.host>localhost</alfresco.db.host>
      <alfresco.repo.artifactId>alfresco-platform</alfresco.repo.artifactId>
      <alfresco.postgres.version>9.1-901.jdbc4</alfresco.postgres.version>
      <alfresco.mysql.version>5.1.31</alfresco.mysql.version>
      <alfresco.rm.artifactId>alfresco-rm-community-repo</alfresco.rm.artifactId>
      <skip.integrationtests>true</skip.integrationtests>
      <alfresco.solr.home>${project.build.directory}/solr/home</alfresco.solr.home>
      <api.explorer.version>1.4</api.explorer.version>
   </properties>

   <build>
      <sourceDirectory>source/java</sourceDirectory>
      <testSourceDirectory>test/java</testSourceDirectory>
      <resources>
         <resource>
            <directory>config</directory>
            <filtering>${app.filtering.enabled}</filtering>
         </resource>
      </resources>
      <testResources>
         <testResource>
            <directory>unit-test/resources</directory>
         </testResource>
         <testResource>
            <directory>test/resources</directory>
         </testResource>
      </testResources>
      <plugins>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
               <execution>
                  <id>add-source</id>
                  <goals>
                     <goal>add-source</goal>
                  </goals>
                  <configuration>
                     <sources>
                        <source>source/compatibility</source>
                     </sources>
                  </configuration>
               </execution>
               <execution>
                  <id>add-test-source</id>
                  <goals>
                     <goal>add-test-source</goal>
                  </goals>
                  <configuration>
                     <sources>
                        <source>unit-test/java</source>
                     </sources>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <artifactId>maven-antrun-plugin</artifactId>
            <executions>
               <execution>
                  <phase>prepare-package</phase>
                  <goals>
                     <goal>run</goal>
                  </goals>
                  <configuration>
                     <target>
                        <move todir="${project.build.directory}/${project.build.finalName}/config/alfresco">
                           <fileset dir="${project.build.outputDirectory}/alfresco" />
                        </move>
                        <copy file="${project.build.directory}/${project.build.finalName}/config/alfresco/module/org_alfresco_module_rm/module.properties" todir="${project.build.directory}/${project.build.finalName}" />
                     </target>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <executions>
               <execution>
                  <phase>initialize</phase>
                  <goals>
                     <goal>read-project-properties</goal>
                  </goals>
                  <configuration>
                     <files>
                        <file>${basedir}/src/main/resources/local.properties</file>
                     </files>
                     <quiet>true</quiet>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
               <includes>
                  <include>**/AllUnitTestSuite.class</include>
               </includes>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-failsafe-plugin</artifactId>
            <executions>
               <execution>
                  <id>integration-tests</id>
                  <goals>
                     <goal>integration-test</goal>
                     <goal>verify</goal>
                  </goals>
                  <configuration>
                     <skipTests>${skip.integrationtests}</skipTests>
                     <includes>
                        <include>**/AllTestSuite.class</include>
                     </includes>
                     <additionalClasspathElements>
                        <additionalClasspathElement>${project.build.directory}/${project.build.finalName}/config</additionalClasspathElement>
                     </additionalClasspathElements>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
               <execution>
                  <id>fetch-share-services-amp</id>
                  <phase>process-test-resources</phase>
                  <goals>
                     <goal>copy</goal>
                  </goals>
                  <configuration>
                     <artifactItems>
                        <artifactItem>
                           <groupId>org.alfresco</groupId>
                           <artifactId>alfresco-share-services</artifactId>
                           <version>${share.version}</version>
                           <type>amp</type>
                        </artifactItem>
                     </artifactItems>
                     <outputDirectory>${project.build.directory}</outputDirectory>
                  </configuration>
               </execution>
               <execution>
                  <id>unpack-alfresco</id>
                  <phase>prepare-package</phase>
                  <goals>
                     <goal>unpack</goal>
                  </goals>
                  <configuration>
                     <outputDirectory>${app.amp.client.war.folder}</outputDirectory>
                     <artifactItems>
                        <artifactItem>
                           <groupId>${alfresco.groupId}</groupId>
                           <artifactId>${app.amp.client.war.artifactId}</artifactId>
                           <type>war</type>
                           <version>${alfresco.version}</version>
                        </artifactItem>
                     </artifactItems>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.alfresco.maven.plugin</groupId>
            <artifactId>alfresco-maven-plugin</artifactId>
            <executions>
               <execution>
                  <id>attach-rm-jar</id>
                  <goals>
                     <goal>amp</goal>
                  </goals>
                  <configuration>
                     <attachClasses>true</attachClasses>
                     <attachConfig>true</attachConfig>
                     <includeDependencies>true</includeDependencies>
                  </configuration>
               </execution>
               <execution>
                  <id>amps-to-war-overlay</id>
                  <phase>package</phase>
                  <goals>
                     <goal>install</goal>
                  </goals>
               </execution>
               <execution>
                  <id>install-share-services-amp</id>
                  <goals>
                     <goal>install</goal>
                  </goals>
                  <phase>prepare-package</phase>
                  <configuration>
                     <backup>true</backup>
                     <ampLocation>${project.build.directory}/alfresco-share-services-${share.version}.amp</ampLocation>
                     <warLocation>${app.amp.client.war.folder}</warLocation>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
               <execution>
                  <goals>
                     <goal>test-jar</goal>
                  </goals>
               </execution>
            </executions>
            <configuration>
               <excludes>
                  <exclude>**/alfresco-global.properties</exclude>
               </excludes>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <configuration>
               <licenseName>alfresco_community</licenseName>
               <roots>
                  <root>source/java</root>
                  <root>unit-test/java</root>
                  <root>source/compatibility</root>
                  <root>config</root>
                  <root>test/java</root>
                  <root>test/resources</root>
               </roots>
            </configuration>
         </plugin>
      </plugins>
      <pluginManagement>
         <plugins>
            <plugin>
               <groupId>org.eclipse.m2e</groupId>
               <artifactId>lifecycle-mapping</artifactId>
               <configuration>
                  <lifecycleMappingMetadata>
                     <pluginExecutions>
                        <pluginExecution>
                           <pluginExecutionFilter>
                              <groupId>org.codehaus.mojo</groupId>
                              <artifactId>properties-maven-plugin</artifactId>
                              <versionRange>[1.0-alpha-2,)</versionRange>
                              <goals>
                                 <goal>read-project-properties</goal>
                              </goals>
                           </pluginExecutionFilter>
                           <action>
                              <ignore />
                           </action>
                        </pluginExecution>
                        <pluginExecution>
                           <pluginExecutionFilter>
                              <groupId>org.codehaus.mojo</groupId>
                              <artifactId>license-maven-plugin</artifactId>
                              <versionRange>[1.8,)</versionRange>
                              <goals>
                                 <goal>update-file-header</goal>
                              </goals>
                           </pluginExecutionFilter>
                           <action>
                              <ignore />
                           </action>
                        </pluginExecution>
                     </pluginExecutions>
                  </lifecycleMappingMetadata>
               </configuration>
            </plugin>
         </plugins>
      </pluginManagement>
   </build>

   <dependencies>
      <dependency>
         <groupId>${alfresco.groupId}</groupId>
         <artifactId>alfresco-remote-api</artifactId>
         <version>${alfresco.version}</version>
         <scope>provided</scope>
      </dependency>
      <dependency>
          <groupId>javax.servlet</groupId>
          <artifactId>javax.servlet-api</artifactId>
          <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>io.takari.junit</groupId>
         <artifactId>takari-cpsuite</artifactId>
         <version>1.2.7</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.alfresco.surf</groupId>
         <artifactId>spring-webscripts</artifactId>
         <classifier>tests</classifier>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-all</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.springframework</groupId>
         <artifactId>spring-test</artifactId>
         <version>2.5</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>${alfresco.groupId}</groupId>
         <artifactId>alfresco-repository</artifactId>
         <version>${alfresco.version}</version>
         <classifier>tests</classifier>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>${alfresco.groupId}</groupId>
         <artifactId>alfresco-remote-api</artifactId>
         <version>${alfresco.version}</version>
         <classifier>tests</classifier>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>postgresql</groupId>
         <artifactId>postgresql</artifactId>
         <version>${alfresco.postgres.version}</version>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>mysql</groupId>
         <artifactId>mysql-connector-java</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>${alfresco.groupId}</groupId>
         <artifactId>alfresco-repository</artifactId>
         <version>${alfresco.version}</version>
         <classifier>h2scripts</classifier>
         <exclusions>
            <exclusion>
               <groupId>*</groupId>
               <artifactId>*</artifactId>
            </exclusion>
         </exclusions>
         <scope>test</scope>
      </dependency>
      <dependency>
          <groupId>org.reflections</groupId>
          <artifactId>reflections</artifactId>
          <version>0.9.10</version>
          <scope>test</scope>
      </dependency>
   </dependencies>

   <profiles>
      <profile>
         <id>use-mysql</id>
         <properties>
            <alfresco.db.name>${my.db.name}</alfresco.db.name>
            <alfresco.db.port>${my.db.port}</alfresco.db.port>
            <alfresco.db.hibernate.dialect>org.hibernate.dialect.MySQLInnoDBDialect</alfresco.db.hibernate.dialect>
            <alfresco.db.params />
            <alfresco.db.master.url>jdbc:mysql://${alfresco.db.host}:${alfresco.db.port}/${alfresco.db.name}</alfresco.db.master.url>
            <alfresco.db.url>jdbc:mysql://${alfresco.db.host}:${alfresco.db.port}/${alfresco.db.name}</alfresco.db.url>
            <alfresco.db.datasource.class>org.gjt.mm.mysql.Driver</alfresco.db.datasource.class>
         </properties>
      </profile>
      <profile>
         <id>use-postgres</id>
         <properties>
            <alfresco.db.name>${my.db.name}</alfresco.db.name>
            <alfresco.db.port>${my.db.port}</alfresco.db.port>
            <alfresco.db.hibernate.dialect>org.hibernate.dialect.PostgreSQLDialect</alfresco.db.hibernate.dialect>
            <alfresco.db.params />
            <alfresco.db.master.url>jdbc:postgresql:template1</alfresco.db.master.url>
            <alfresco.db.url>jdbc:postgresql:${alfresco.db.name}</alfresco.db.url>
            <alfresco.db.datasource.class>org.postgresql.Driver</alfresco.db.datasource.class>
         </properties>
      </profile>
      <profile>
         <id>start-repo</id>
         <build>
            <plugins>
               <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>${app.amp.client.war.folder}</outputDirectory>
                           <artifactItems>
                              <artifactItem>
                                 <groupId>${alfresco.groupId}</groupId>
                                 <artifactId>${alfresco.repo.artifactId}</artifactId>
                                 <type>war</type>
                                 <version>${alfresco.version}</version>
                              </artifactItem>
                           </artifactItems>
                        </configuration>
                     </execution>
                     <execution>
                        <id>unpack-alfresco-config</id>
                        <goals>
                           <goal>unpack</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                           <outputDirectory>${alfresco.solr.home}</outputDirectory>
                           <artifactItems>
                              <artifactItem>
                                 <artifactId>alfresco-solr4</artifactId>
                                 <groupId>${alfresco.groupId}</groupId>
                                 <classifier>config</classifier>
                                 <version>${alfresco.version}</version>
                                 <type>zip</type>
                              </artifactItem>
                           </artifactItems>
                        </configuration>
                     </execution>
                  </executions>
               </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>
                     <includeWebResources>false</includeWebResources>
                  </configuration>
               </plugin>
               <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>build-helper-maven-plugin</artifactId>
                  <executions>
                     <execution>
                        <id>regex-property</id>
                        <phase>generate-resources</phase>
                        <goals>
                           <goal>regex-property</goal>
                        </goals>
                        <configuration>
                           <name>solrHomePath</name>
                           <value>${alfresco.solr.home}</value>
                           <regex>\\</regex>
                           <replacement>\\\\</replacement>
                           <failIfNoMatch>false</failIfNoMatch>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
               <plugin>
                  <groupId>com.google.code.maven-replacer-plugin</groupId>
                  <artifactId>replacer</artifactId>
                  <executions>
                     <execution>
                        <id>setup-solr-config</id>
                        <phase>generate-resources</phase>
                        <goals>
                           <goal>replace</goal>
                        </goals>
                     </execution>
                  </executions>
                  <configuration>
                     <regex>false</regex>
                     <includes>
                        <include>${alfresco.solr.home}/context.xml</include>
                        <include>${alfresco.solr.home}/archive-SpacesStore/conf/solrcore.properties</include>
                        <include>${alfresco.solr.home}/workspace-SpacesStore/conf/solrcore.properties</include>
                        <include>${app.amp.client.war.folder}/WEB-INF/web.xml</include>
                     </includes>
                     <replacements>
                        <replacement>
                           <token>@@ALFRESCO_SOLR4_DIR@@</token>
                           <value>${solrHomePath}/</value>
                        </replacement>
                        <replacement>
                           <token>@@ALFRESCO_SOLR4_MODEL_DIR@@</token>
                           <value>${solrHomePath}/alfrescoModels/</value>
                        </replacement>
                        <replacement>
                           <token>@@ALFRESCO_SOLR4_CONTENT_DIR@@</token>
                           <value>${solrHomePath}/data/content/</value>
                        </replacement>
                        <replacement>
                           <token>@@ALFRESCO_SOLR4_DATA_DIR@@</token>
                           <value>${solrHomePath}/data/index/</value>
                        </replacement>
                        <replacement>
                           <token><![CDATA[<!-- Toggle securecomms placeholder start -->]]></token>
                           <value><![CDATA[<!--]]></value>
                        </replacement>
                        <replacement>
                           <token><![CDATA[<!-- Toggle securecomms placeholder end -->]]></token>
                           <value><![CDATA[-->]]></value>
                        </replacement>
                     </replacements>
                  </configuration>
               </plugin>
               <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>false</delegate>
                           <contextFile>${project.basedir}/tomcat/context.xml</contextFile>
                           <webapps>
                              <webapp>
                                 <groupId>${alfresco.groupId}</groupId>
                                 <artifactId>alfresco-solr4</artifactId>
                                 <version>${alfresco.version}</version>
                                 <type>war</type>
                                 <asWebapp>true</asWebapp>
                                 <contextPath>/solr4</contextPath>
                                 <contextFile>${alfresco.solr.home}/context.xml</contextFile>
                              </webapp>
                              <webapp>
                                 <groupId>org.alfresco</groupId>
                                 <artifactId>api-explorer</artifactId>
                                 <version>${api.explorer.version}</version>
                                 <contextPath>/api-explorer</contextPath>
                                 <type>war</type>
                                 <asWebapp>true</asWebapp>
                              </webapp>
                              <webapp>
                                 <groupId>org.alfresco</groupId>
                                 <artifactId>alfresco-rm-community-rest-api-explorer</artifactId>
                                 <version>${project.version}</version>
                                 <contextPath>/gs-api-explorer</contextPath>
                                 <type>war</type>
                                 <asWebapp>true</asWebapp>
                              </webapp>
                           </webapps>
                        </configuration>
                     </execution>
                  </executions>
                  <dependencies>
                     <dependency>
                        <groupId>postgresql</groupId>
                        <artifactId>postgresql</artifactId>
                        <version>${alfresco.postgres.version}</version>
                     </dependency>
                     <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>${alfresco.mysql.version}</version>
                     </dependency>
                     <dependency>
                        <groupId>${alfresco.groupId}</groupId>
                        <artifactId>alfresco-repository</artifactId>
                        <version>${alfresco.version}</version>
                        <classifier>h2scripts</classifier>
                        <exclusions>
                           <exclusion>
                              <groupId>*</groupId>
                              <artifactId>*</artifactId>
                           </exclusion>
                        </exclusions>
                     </dependency>
                  </dependencies>
               </plugin>
            </plugins>
         </build>
      </profile>

      <profile>
         <id>wipeDB</id>
         <build>
            <plugins>
               <plugin>
                  <groupId>org.codehaus.mojo</groupId>
                  <artifactId>sql-maven-plugin</artifactId>
                  <configuration>
                     <autocommit>true</autocommit>
                     <driver>${alfresco.db.datasource.class}</driver>
                     <url>${alfresco.db.master.url}</url>
                     <username>${alfresco.db.username}</username>
                     <password>${alfresco.db.password}</password>
                  </configuration>
                  <dependencies>
                     <dependency>
                        <groupId>postgresql</groupId>
                        <artifactId>postgresql</artifactId>
                        <version>${alfresco.postgres.version}</version>
                     </dependency>
                     <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>${alfresco.mysql.version}</version>
                     </dependency>
                  </dependencies>
                  <executions>
                     <execution>
                        <id>wipe-database</id>
                        <phase>process-test-resources</phase>
                        <goals>
                           <goal>execute</goal>
                        </goals>
                        <configuration>
                           <sqlCommand>drop database if exists alfresco</sqlCommand>
                        </configuration>
                     </execution>
                     <execution>
                        <id>create-database</id>
                        <phase>process-test-resources</phase>
                        <goals>
                           <goal>execute</goal>
                        </goals>
                        <configuration>
                           <sqlCommand>create database alfresco</sqlCommand>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
</project>