<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-share</artifactId>
   <name>Alfresco Records Management Community Share</name>
   <description>Alfresco Record Management Community Share Extension</description>
   <packaging>amp</packaging>

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

   <properties>
      <app.amp.client.war.artifactId>${alfresco.share.artifactId}</app.amp.client.war.artifactId>
      <maven.tomcat.port>8181</maven.tomcat.port>
      <alfresco.repo.url>http://localhost:8080/alfresco</alfresco.repo.url>
      <alfresco.share.artifactId>share</alfresco.share.artifactId>
      <alfresco.rm.artifactId>alfresco-rm-community-share</alfresco.rm.artifactId>
      <alfresco.aikau.version>1.0.103</alfresco.aikau.version>
   </properties>

   <build>
      <sourceDirectory>source/java</sourceDirectory>
      <resources>
         <resource>
            <directory>config</directory>
            <filtering>${app.filtering.enabled}</filtering>
         </resource>
         <resource>
            <directory>source/web</directory>
         </resource>
      </resources>
      <plugins>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <executions>
               <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>
                        <move todir="${project.build.directory}/${project.build.finalName}/web/components">
                           <fileset dir="${project.build.outputDirectory}/components" />
                        </move>
                        <move todir="${project.build.directory}/${project.build.finalName}/web/rm">
                           <fileset dir="${project.build.outputDirectory}/rm" />
                        </move>
                        <move todir="${project.build.directory}/${project.build.finalName}/web/js">
                           <fileset dir="${project.build.outputDirectory}/js" />
                        </move>
                        <move file="${project.build.directory}/${project.build.finalName}/config/alfresco/module/org_alfresco_module_rm_share/file-mapping.properties" todir="${project.build.directory}/${project.build.finalName}" />
                        <move file="${project.build.directory}/${project.build.finalName}/config/alfresco/module/org_alfresco_module_rm_share/module.properties" todir="${project.build.directory}/${project.build.finalName}" />
                     </target>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>net.alchim31.maven</groupId>
            <artifactId>yuicompressor-maven-plugin</artifactId>
         </plugin>
         <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>${app.amp.client.war.artifactId}</artifactId>
                           <type>war</type>
                           <version>${share.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>
            </executions>
            <configuration>
               <includeWebResources>true</includeWebResources>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <executions>
               <execution>
                  <goals>
                     <goal>test-jar</goal>
                  </goals>
               </execution>
            </executions>
         </plugin>

         <!-- License header generation -->
         <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>license-maven-plugin</artifactId>
            <configuration>
               <licenseName>alfresco_community</licenseName>
               <roots>
                  <root>source/java</root>
                  <root>config</root>
                  <root>source/web</root>
                  <root>unit-test/java</root>
               </roots>
            </configuration>
         </plugin>

      </plugins>
      <pluginManagement>
         <plugins>
            <!--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.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>org.alfresco</groupId>
         <artifactId>aikau</artifactId>
         <version>${alfresco.aikau.version}</version>
         <exclusions>
            <exclusion>
               <groupId>*</groupId>
               <artifactId>*</artifactId>
            </exclusion>
         </exclusions>
      </dependency>
      <dependency>
         <groupId>${alfresco.groupId}</groupId>
         <artifactId>share</artifactId>
         <version>${share.version}</version>
         <classifier>classes</classifier>
         <scope>provided</scope>
      </dependency>
      <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <scope>test</scope>
      </dependency>
      <dependency>
         <groupId>org.mockito</groupId>
         <artifactId>mockito-all</artifactId>
         <scope>test</scope>
      </dependency>
   </dependencies>

   <profiles>
      <profile>
         <id>start-share</id>
         <build>
            <plugins>
               <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>
                           <warSourceDirectory>${app.amp.client.war.folder}</warSourceDirectory>
                        </configuration>
                     </execution>
                  </executions>
               </plugin>
            </plugins>
         </build>
      </profile>
   </profiles>
</project>
