<!-- ****************************************************** -->
<!-- ** Experimental Maven build - use at your own risk! ** -->
<!-- ****************************************************** -->

<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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.alfresco</groupId>
        <artifactId>alfresco-parent</artifactId>
        <version>4.2.f</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>
    <artifactId>alfresco</artifactId>
    <packaging>war</packaging>
    <name>Alfresco Web Client</name>
    <description>Alfresco Web Client</description>

    <properties>
        <maven.tomcat.path>/alfresco</maven.tomcat.path>
        <maven.tomcat.port>${tomcat.default.alfresco.port}</maven.tomcat.port>
        <maven.webapp.classifier>webapp</maven.webapp.classifier>
        <project.build.patchesDirectory>${project.build.directory}/patches</project.build.patchesDirectory>
    </properties>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>alfresco-remote-api</artifactId>
            <version>${project.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>org.apache.abdera</groupId>
                    <artifactId>abdera-extensions-main</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.abdera</groupId>
                    <artifactId>abdera-extensions-html</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.abdera</groupId>
                    <artifactId>abdera-server</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.axis</groupId>
                    <artifactId>axis-jaxrpc</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.apache.axis</groupId>
                    <artifactId>axis-saaj</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>alfresco-repository</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>alfresco-web-framework-commons</artifactId>
            <version>${project.version}</version>
            <classifier>classes</classifier>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>alfresco-jndi-client</artifactId>
            <version>${project.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlgraphics</groupId>
            <artifactId>fop</artifactId>
            <version>0.94</version>
        </dependency>
        <dependency>
            <groupId>xalan</groupId>
            <artifactId>xalan</artifactId>
            <version>2.7.0</version>
            <exclusions>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-jxpath</groupId>
            <artifactId>commons-jxpath</artifactId>
            <version>1.2</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-beanutils</groupId>
                    <artifactId>commons-beanutils</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-collections</groupId>
                    <artifactId>commons-collections</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>junit</groupId>
                    <artifactId>junit</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xerces</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>commons-modeler</groupId>
            <artifactId>commons-modeler</artifactId>
            <version>1.1</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging-api</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xml-apis</groupId>
                    <artifactId>xml-apis</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>commons-digester</groupId>
                    <artifactId>commons-digester</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
			<groupId>commons-logging</groupId>
			<artifactId>commons-logging</artifactId>
			<version>1.1.1</version>
		</dependency>
        <dependency>
            <groupId>net.sf.chiba</groupId>
            <artifactId>chiba</artifactId>
            <version>1.3.0-alfresco-patched</version>
        </dependency>
        <dependency>
            <groupId>org.apache.james</groupId>
            <artifactId>apache-mime4j-dom</artifactId>
            <version>0.7.2</version>
        </dependency>
        <dependency>
            <groupId>avalon-framework</groupId>
            <artifactId>avalon-framework-api</artifactId>
            <version>4.2.0</version>
        </dependency>
        <dependency>
            <groupId>avalon-framework</groupId>
            <artifactId>avalon-framework-impl</artifactId>
            <version>4.2.0</version>
        </dependency>
        <dependency>
            <groupId>bcel</groupId>
            <artifactId>bcel</artifactId>
            <version>5.1</version>
        </dependency>
        <dependency>
            <groupId>taglibs</groupId>
            <artifactId>standard</artifactId>
            <version>1.1.0</version>
        </dependency>
        <dependency>
            <groupId>org.apache.chemistry.opencmis</groupId>
            <artifactId>chemistry-opencmis-test-browser</artifactId>
            <version>${dependency.opencmis.version}</version>
        </dependency>

        <!-- 'provided' dependencies, not packaged in war -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.4</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.portlet</groupId>
            <artifactId>portlet-api</artifactId>
            <version>2.0</version>
            <scope>provided</scope>
        </dependency>

        <!-- Test dependencies -->
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-core</artifactId>
            <version>${project.version}</version>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-repository</artifactId>
            <version>${project.version}</version>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-deployment</artifactId>
            <version>${project.version}</version>
            <classifier>tests</classifier>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>${dependency.spring.version}</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.mockito</groupId>
            <artifactId>mockito-all</artifactId>
            <version>1.8.0</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.shale</groupId>
            <artifactId>shale-test</artifactId>
            <version>1.0.4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>9.1-901.jdbc4</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.14</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.3.167</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Wipe the database before starting tests -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>sql-maven-plugin</artifactId>
                <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>

            <!-- CLOUD-1967 Put core log4j config in WEB-INF/classes, so that it's first in classloader -->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>fetch-log4j-config</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>alfresco-core</artifactId>
                                    <version>${project.version}</version>
                                </artifactItem>
                            </artifactItems>
                            <includes>log*.properties</includes>
                            <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
					<attachClasses>true</attachClasses>
                    <archiveClasses>false</archiveClasses>
                    <!-- Temporary ugly hack until we can really move the public_api file out of remote-api without breaking the Ant build -->
                    <webResources>
                        <resource>
                            <directory>../../projects/remote-api/source/web</directory>
                            <includes>
                            	<include>WEB-INF/server-config.wsdd</include>
                            </includes>
                        </resource>
                    </webResources>
                </configuration>
                <!-- This allows overlays to be prepared on the FS for minification and faster run -->
				<executions>
					<execution>
						<id>pre-exploded-war</id>
						<goals>
							<goal>exploded</goal>
						</goals>
						<phase>prepare-package</phase>
					</execution>
				</executions>
            </plugin>
        </plugins>
    </build>

    <!-- NOTE: Profiles' order is IMPORTANT as defines the order plugins are executed -->
    <profiles>
		<profile>
			<id>solr-http</id>
			<build>
				<plugins>
					<plugin>
						<artifactId>maven-resources-plugin</artifactId>
						<executions>
							<execution>
								<id>copy-web-xml</id>
								<phase>process-resources</phase>
								<goals>
									<goal>copy-resources</goal>
								</goals>
								<configuration>
									<outputDirectory>${project.build.patchesDirectory}</outputDirectory>
									<resources>
										<resource>
	                  						<directory>source/web</directory>
	                  						<filtering>false</filtering>
	                  						<includes>
	                  							<include>WEB-INF/web.xml</include>
	                  						</includes>
	                					</resource>
                					</resources>
								</configuration>
							</execution>
						</executions>
					</plugin>
					<!-- Replaces web.xml where applicable, commenting out the security-constraints -->
					<plugin>
						<groupId>com.google.code.maven-replacer-plugin</groupId>
						<artifactId>replacer</artifactId>
						<executions>
							<execution>
								<id>disable-securecomms</id>
								<phase>process-resources</phase>
								<goals>
									<goal>replace</goal>
								</goals>
							</execution>
						</executions>
						<configuration>
							<ignoreErrors>true</ignoreErrors>
							<file>${project.build.patchesDirectory}/WEB-INF/web.xml</file>
							<replacements>
								<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>
					<!-- Configures the war-plugin to use the patches web.xml -->
					<plugin>
                		<artifactId>maven-war-plugin</artifactId>
                		<configuration>
                			<webResources>
                				<resource>
                					<directory>${project.build.patchesDirectory}</directory>
                				</resource>
                			</webResources>
                		</configuration>
                	</plugin>
				</plugins>
			</build>
		</profile>    
	    <profile>
			<id>run</id>
			<build>
				<plugins>
					<plugin>
						<groupId>org.apache.tomcat.maven</groupId>
						<artifactId>tomcat7-maven-plugin</artifactId>
						<executions>
							<execution>
								<id>run-exploded-webapp</id>
								<phase>prepare-package</phase>
								<goals>
									<goal>run-war-only</goal>
								</goals>
							</execution>
						</executions>
					</plugin>
				</plugins>
			</build>
		</profile>
		<!-- Tweaks required to make the build work in Eclipse -->
		<profile>
			<id>m2e</id>
			<dependencies>
			    <dependency>
			       <groupId>commons-logging</groupId>
			       <artifactId>commons-logging</artifactId>
			       <version>1.1.1</version>
			       <!-- This is needed for Maven tomcat run -->
			       <scope>runtime</scope>
		        </dependency>
				<dependency>
					<groupId>mysql</groupId>
					<artifactId>mysql-connector-java</artifactId>
					<version>5.1.14</version>
				</dependency>			
			</dependencies>
	   </profile>
    </profiles>   
</project>
