<!-- ****************************************************** -->
<!-- ** 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>
    <artifactId>alfresco-solr4</artifactId>
    <name>Alfresco Solr 4</name>
    <packaging>war</packaging>

    <parent>
        <artifactId>alfresco-parent</artifactId>
        <groupId>org.alfresco</groupId>
        <version>5.0.c</version>
        <relativePath>../../pom.xml</relativePath>
    </parent>

    <properties>
        <maven.tomcat.path>/solr4</maven.tomcat.path>
        <m2eclipse.wtp.contextRoot>${maven.tomcat.path}</m2eclipse.wtp.contextRoot>
        <maven.tomcat.port>${tomcat.default.solr4.port}</maven.tomcat.port>
        <maven.tomcat.httpsPort>${tomcat.default.solr4.ssl.port}</maven.tomcat.httpsPort>
        <solr.instance.source.folder>source/solr/instance</solr.instance.source.folder>
        <!-- This gets filtered in the solr-tomcat-context.xml and in solrcore.properties when running embedded -->
        <solr.ssl.instance.target.folder>${project.build.directory}/solr-instance-ssl</solr.ssl.instance.target.folder>
        <solr.nossl.instance.target.folder>${project.build.directory}/solr-instance-nossl</solr.nossl.instance.target.folder>
        <solr.ssl.war.target.folder>${project.build.directory}/${project.build.finalName}-ssl</solr.ssl.war.target.folder>
        <solr.nossl.war.target.folder>${project.build.directory}/${project.build.finalName}-nossl</solr.nossl.war.target.folder>

        <!-- We configure the WAR exploded to point to the customized no-ssl folder -->
        <solr.war.exploded.folder>${solr.nossl.war.target.folder}</solr.war.exploded.folder>
        <!-- We configure the solr config to point to the customized no-ssl folder -->
        <solr.config.folder>${solr.nossl.instance.target.folder}</solr.config.folder>
        
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-solrclient</artifactId>
            <version>${project.version}</version>
        </dependency>
        <!-- provided dependencies -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.lucene</groupId>
            <artifactId>lucene-analyzers-common</artifactId>
            <version>4.9.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-core</artifactId>
            <version>4.9.1</version>
            <scope>provided</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.jetty.orbit</groupId>
                    <artifactId>javax.servlet</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>jdk.tools</groupId>
                    <artifactId>jdk.tools</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr-analysis-extras</artifactId>
            <version>4.9.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.jetty.orbit</groupId>
                    <artifactId>javax.servlet</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
	    <groupId>org.apache.solr</groupId>
	    <artifactId>solr-langid</artifactId>
	    <version>4.9.1</version>
            <exclusions>
                <exclusion>
                    <groupId>org.eclipse.jetty.orbit</groupId>
                    <artifactId>javax.servlet</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.6.6</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.6.6</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
        </dependency>
        <dependency>
	    <groupId>com.spatial4j</groupId>
	    <artifactId>spatial4j</artifactId>
	    <version>0.4.1</version>
        </dependency>
        <dependency>
            <groupId>com.vividsolutions</groupId>
            <artifactId>jts</artifactId>
            <version>1.13</version>
            <exclusions>
                <exclusion>
                    <groupId>xerces</groupId>
                    <artifactId>xercesImpl</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <!-- War dependency on the Vanilla Solr WAR -->
        <dependency>
            <groupId>org.apache.solr</groupId>
            <artifactId>solr</artifactId>
            <version>4.9.1</version>
            <type>war</type>
        </dependency>

        <!-- Test dependencies -->
        <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>

    <build>
        <finalName>solr4</finalName>
        <plugins>
            <plugin>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <attachClasses>true</attachClasses>
                    <archiveClasses>true</archiveClasses>
                </configuration>
                <!-- This allows overlays to be prepared on the FS for minification and faster run -->
                <executions>
                    <execution>
                        <id>prepare-exploded-war</id>
                        <goals>
                            <goal>exploded</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <webappDirectory>${solr.nossl.war.target.folder}</webappDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-instance-resources</id>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <phase>generate-resources</phase>
                        <configuration>
                            <outputDirectory>${solr.nossl.instance.target.folder}</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${solr.instance.source.folder}</directory>
                                    <excludes>
                                        <exclude>**/ssl.repo*</exclude>
                                    </excludes>
                                    <filtering>true</filtering>
                                </resource>
                                <resource>
                                    <directory>${solr.instance.source.folder}</directory>
                                    <includes>
                                        <include>**/ssl.repo*</include>
                                    </includes>
                                    <filtering>false</filtering>
                                </resource>
                            </resources>
                            <useDefaultDelimiters>false</useDefaultDelimiters>
                            <delimiters>
                                <delimiter>@@</delimiter>
                            </delimiters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <inherited>false</inherited>
                <executions>
                    <execution>
                        <id>package-config-zip</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <attach>true</attach>
                            <descriptors>
                                <descriptor>
                                    source/assembly/solr-instance-zip-nossl.xml
                                </descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>


    <profiles>
        <!-- Profile to enable securecomms -->
        <profile>
            <id>solr4-ssl</id>
            <activation>
                <activeByDefault>true</activeByDefault>
            </activation>
            <properties>
                <!-- We selected the SSL enabled default Solr packaging -->
                <solr.war.exploded.folder>${solr.ssl.war.target.folder}</solr.war.exploded.folder>
                <!-- We selected the SSL enabled default Solr config -->
                <solr.config.folder>${solr.ssl.instance.target.folder}</solr.config.folder>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>copy-instance-ssl</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <outputDirectory>${solr.ssl.instance.target.folder}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${solr.nossl.instance.target.folder}</directory>
                                        </resource>
                                    </resources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>copy-war-ssl</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <outputDirectory>${solr.ssl.war.target.folder}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${solr.nossl.war.target.folder}</directory>
                                        </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>replace-archive-SpacesStore</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>replace</goal>
                                </goals>
                                <configuration>
                                    <ignoreErrors>true</ignoreErrors>
                                    <file>${solr.config.folder}/archive-SpacesStore/conf/solrcore.properties</file>
                                    <replacements>
                                        <replacement>
                                            <token><![CDATA[alfresco.secureComms=none]]></token>
                                            <value><![CDATA[alfresco.secureComms=https]]></value>
                                        </replacement>
                                    </replacements>
                                </configuration>
                            </execution>
                            <execution>
                                <id>replace-workspace-SpacesStore</id>
                                <phase>prepare-package</phase>
                                <goals>
                                    <goal>replace</goal>
                                </goals>
                                <configuration>
                                    <ignoreErrors>true</ignoreErrors>
                                    <file>${solr.config.folder}/workspace-SpacesStore/conf/solrcore.properties</file>
                                    <replacements>
                                        <replacement>
                                            <token><![CDATA[alfresco.secureComms=none]]></token>
                                            <value><![CDATA[alfresco.secureComms=https]]></value>
                                        </replacement>
                                    </replacements>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <artifactId>maven-war-plugin</artifactId>
                        <executions>
                            <!-- This allows overlays to be prepared on the FS for minification and faster run -->
                            <execution>
                                <id>prepare-exploded-ssl-war</id>
                                <goals>
                                    <goal>exploded</goal>
                                </goals>
                                <phase>prepare-package</phase>
                                <configuration>
                                    <webappDirectory>${solr.ssl.war.target.folder}</webappDirectory>
                                    <webResources>
                                        <!-- To include customized web.xml to enable comms -->
                                        <resource>
                                            <directory>source/test-web/WEB-INF</directory>
                                            <filtering>true</filtering>
                                            <targetPath>WEB-INF</targetPath>
                                        </resource>
                                    </webResources>
                                </configuration>
                            </execution>
                            <execution>
                                <id>package-ssl-war</id>
                                <goals>
                                    <goal>war</goal>
                                </goals>
                                <phase>package</phase>
                                <configuration>
                                    <webappDirectory>${solr.ssl.war.target.folder}</webappDirectory>
                                    <classifier>ssl</classifier>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    
                    <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <inherited>false</inherited>
                        <executions>
                            <execution>
                                <id>package-config-zip-ssl</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>single</goal>
                                </goals>
                                <configuration>
                                    <attach>true</attach>
                                    <descriptors>
                                        <descriptor>
                                            source/assembly/solr-instance-zip-ssl.xml
                                        </descriptor>
                                    </descriptors>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!-- Profile to run the webapp on HTTP -->
        <profile>
            <id>run</id>
            <build>
                <plugins>
                    <plugin>
                        <artifactId>maven-war-plugin</artifactId>
                        <configuration>
                            <webResources>
                                <!-- To add log4j.properties and other test run resources -->
                                <resource>
                                    <directory>source/test-resources</directory>
                                    <filtering>true</filtering>
                                    <targetPath>WEB-INF/classes</targetPath>
                                </resource>
                            </webResources>
                        </configuration>
                    </plugin>
                    <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>
                                <configuration>
                                    <warDirectory>${solr.war.exploded.folder}</warDirectory>
                                    <systemProperties>
                                        <solr.solr.home>${solr.config.folder}</solr.solr.home>
                                        <solr.solr.model.dir>${solr.config.folder}/alfrescoModels</solr.solr.model.dir>
                                        <solr.solr.content.dir>@@ALFRESCO_SOLR4_CONTENT_DIR@@</solr.solr.content.dir>
                                    </systemProperties>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
