<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>
    <groupId>org.alfresco</groupId>
    <artifactId>alfresco-search-services</artifactId>
    <name>Alfresco Search Services</name>
    <description>Alfresco Search Services Solr distribution zip</description>
    <packaging>jar</packaging>
    <properties>
      <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
      <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
      <project.timestamp>${maven.build.timestamp}</project.timestamp>
      <project.build.key>${bamboo_fullBuildKey}</project.build.key>
      <project.revision.key>${bamboo_repository_revision_number}</project.revision.key>
    </properties>
    <parent>
        <groupId>org.alfresco</groupId>
        <artifactId>alfresco-search-parent</artifactId>
        <version>1.0.0.1-SNAPSHOT</version>
        <relativePath>../pom.xml</relativePath>
    </parent>
    <dependencies>
      <dependency>
          <groupId>org.alfresco</groupId>
          <artifactId>alfresco-search</artifactId>
          <version>${project.version}</version>
      </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-search</artifactId>
            <version>${project.version}</version>
            <classifier>libs</classifier>
        </dependency>

        <!-- Test dependencies. -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>27.0.1-jre</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>alfresco-search-services-${project.version}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-failsafe-plugin</artifactId>
                <version>2.22.1</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>integration-test</goal>
                            <goal>verify</goal>
                        </goals>
                    </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>config.properties</file>
                            </files>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-solr-war</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.solr</groupId>
                                    <artifactId>solr</artifactId>
                                    <version>${solr.version}</version>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}</outputDirectory>
                                    <excludes>**/*solr.xml</excludes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-solr-config</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-search</artifactId>
                                    <version>${project.version}</version>
                                    <outputDirectory>${project.build.directory}/alfresco-search</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-solr-libs</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-search</artifactId>
                                    <version>${project.version}</version>
                                    <classifier>libs</classifier>
                                    <outputDirectory>${project.build.directory}/solr-libs</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-search</artifactId>
                                    <version>${project.version}</version>
                                    <outputDirectory>${project.build.directory}/solr-libs/libs</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                            <outputDirectory>${project.build.directory}/wars</outputDirectory>
                            <overWriteReleases>false</overWriteReleases>
                            <overWriteSnapshots>true</overWriteSnapshots>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Set the default solr home directory to solrhome -->
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>prepare-package</phase>
                        <configuration>
                            <target>
                                <replace token="SOLR_SERVER_DIR/solr" value="SOLR_TIP/../solrhome" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr" />
                                </replace>
                                <replace token="%SOLR_SERVER_DIR%\solr" value="%SOLR_TIP%\..\solrhome" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.cmd" />
                                </replace>
                                <replace token="HOME/.solr.in.sh" value="SOLR_TIP/../solr.in.sh" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr" />
                                </replace>
                                <replace token="\bin\solr.in.cmd" value="\..\solr.in.cmd" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.cmd" />
                                </replace>
                                <replace token="SOLR_SSL_OPTS=%SOLR_SSL_OPTS%" value="SOLR_SSL_OPTS=!SOLR_SSL_OPTS!" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.cmd" />
                                </replace>
                                <replace token="#SOLR_LOGS_DIR=logs" value="${alfresco.search.logs}" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.in.sh" />
                                </replace>
                                <replace token="REM set SOLR_LOGS_DIR=logs" value="${alfresco.search.logs.win}" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.in.cmd" />
                                </replace>
                                <replace token="GC logging" value="GC logging${line.separator}${alfresco.gc.logs}" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.in.sh" />
                                </replace>
                                <replace token="GC logging" value="GC logging${line.separator}${alfresco.gc.logs.win}" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.in.cmd" />
                                </replace>
                                <replace token="# Anything you add to the SOLR_OPTS" value="${alfresco.search.config}${line.separator}${line.separator}# Anything you add to the SOLR_OPTS" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.in.sh" />
                                </replace>
                                <replace token="REM Anything you add to the SOLR_OPTS" value="${alfresco.search.config.win}${line.separator}${line.separator}REM Anything you add to the SOLR_OPTS" dir="target/solr-${solr.version}">
                                    <include name="**/bin/solr.in.cmd" />
                                </replace>
                                <replace token="${alfresco.search.ssl.token}" value="${alfresco.search.ssl}${line.separator} ${alfresco.search.ssl.token}" dir="target/solr-${solr.version}">
                                    <include name="**/server/etc/jetty*.xml" />
                                </replace>
                                <replace token="${alfresco.search.ssl.need.token}" value="${alfresco.search.ssl.need}" dir="target/solr-${solr.version}">
                                    <include name="**/server/etc/jetty-ssl.xml" />
                                </replace>
                                <replace token="wantClientAuth" value="wantclientauth" dir="target/solr-${solr.version}">
                                    <include name="**/server/etc/jetty-ssl.xml" />
                                </replace>
                                <chmod file="target/solr-${solr.version}/bin/solr" perm="755" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>make-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/assembly/solr-distribution.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-docker-resources</id>
                        <phase>package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/docker-resources</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>src/docker</directory>
                                    <filtering>true</filtering>
                                </resource>
                                <resource>
                                    <directory>${project.build.directory}</directory>
                                    <includes>
                                        <include>${project.build.finalName}.zip</include>
                                    </includes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy-solr-licenses</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/classes/licenses/solr</outputDirectory>
                            <resources>
                                <resource>
                                    <directory>${solr.directory}/licenses</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
