<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-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>
    </properties>
    <parent>
        <groupId>org.alfresco</groupId>
        <artifactId>alfresco-search-parent</artifactId>
        <version>2.0.3-RC2</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.13</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>alfresco-search-services-${project.version}</finalName>
        <plugins>
            <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>com.googlecode.maven-download-plugin</groupId>
                <artifactId>download-maven-plugin</artifactId>
                <version>1.6.0</version>
                <executions>
                    <execution>
                        <id>unpack-solr-war</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>wget</goal>
                        </goals>
                        <configuration>
                            <url>${solr.zip}</url>
                            <unpack>true</unpack>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-solr-config</id>
                        <phase>prepare-package</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>prepare-package</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>
                                    <excludes>**/jackson-dataformat-smile-*.jar,**/asm-3.3.1.jar,**/jackson-core-asl-*.jar,**/jackson-mapper-asl-*.jar,**/dom4j-1.6.1.jar,
                                        **/annotations-1.0.0.jar,**/spring-context-support-*.jar,**/spring-web-*.jar,**/woodstox-core-asl-4.4.1.jar, **/isoparser-1.1.18.jar,
                                        **/metadata-extractor-2.9.1.jar,**/org.restlet.ext.servlet-2.3.0.jar
                                    </excludes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy</id>
                        <phase>prepare-package</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>
                                <artifactItem>
                                    <groupId>org.restlet.jee</groupId>
                                    <artifactId>org.restlet.ext.servlet</artifactId>
                                    <version>${dependency.restlet.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>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <!-- Delete older versions of jars that have been overridden by us. -->
                    <execution>
                        <id>delete-duplicate-jars</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/jackson-annotations-2.5.4.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/jackson-core-2.5.4.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/jackson-databind-2.5.4.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/jackson-dataformat-smile-2.5.4.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/jackson-core-asl-1.9.13.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/jackson-mapper-asl-1.9.13.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/dom4j-1.6.1.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/woodstox-core-asl-4.4.1.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/calcite-core-1.11.0.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/calcite-linq4j-1.11.0.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/hadoop-annotations-2.7.4.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/hadoop-auth-2.7.4.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/hadoop-common-2.7.4.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/hadoop-hdfs-2.7.4.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/avatica-core-1.9.0.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/org.restlet-2.3.0.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/org.restlet.ext.servlet-2.3.0.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/WEB-INF/lib/httpclient-4.4.1.jar" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/libs/jquery-2.1.3.min.js" />
                                <delete file="${project.build.directory}/solr-${solr.version}/server/solr-webapp/webapp/js/lib/jquery-1.7.2.min.js" />
                            </target>

                        </configuration>
                    </execution>
                    <!-- Set the default solr home directory to solrhome -->
                    <execution>
                        <phase>prepare-package</phase>
                        <configuration>
                            <target>
                                <replace token="SOLR_SERVER_DIR/solr" value="SOLR_TIP/../solrhome" dir="${solr.directory}">
                                    <include name="**/bin/solr" />
                                </replace>
                                <replace token="%SOLR_SERVER_DIR%\solr" value="%SOLR_TIP%\..\solrhome" dir="${solr.directory}">
                                    <include name="**/bin/solr.cmd" />
                                </replace>
                                <replace token="HOME/.solr.in.sh" value="SOLR_TIP/../solr.in.sh" dir="${solr.directory}">
                                    <include name="**/bin/solr" />
                                </replace>
                                <replace token="\bin\solr.in.cmd" value="\..\solr.in.cmd" dir="${solr.directory}">
                                    <include name="**/bin/solr.cmd" />
                                </replace>
                                <replace token="SOLR_SSL_OPTS=%SOLR_SSL_OPTS%" value="SOLR_SSL_OPTS=!SOLR_SSL_OPTS!" dir="${solr.directory}">
                                    <include name="**/bin/solr.cmd" />
                                </replace>
                                <replace token="#SOLR_LOGS_DIR=logs" value="${alfresco.search.logs}" dir="${solr.directory}">
                                    <include name="**/bin/solr.in.sh" />
                                </replace>
                                <replace token="REM set SOLR_LOGS_DIR=logs" value="${alfresco.search.logs.win}" dir="${solr.directory}">
                                    <include name="**/bin/solr.in.cmd" />
                                </replace>
                                <replace token="(java9)" value="(java9)${line.separator}${alfresco.gc.logs}" dir="${solr.directory}">
                                    <include name="**/bin/solr.in.sh" />
                                </replace>
                                <replace token="GC logging" value="GC logging${line.separator}${alfresco.gc.logs.win}" dir="${solr.directory}">
                                    <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="${solr.directory}">
                                    <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="${solr.directory}">
                                    <include name="**/bin/solr.in.cmd" />
                                </replace>
                                <replace token="REM set SOLR_JAVA_MEM=-Xms512m -Xmx512m" value="set SOLR_JAVA_MEM=-Xms1g -Xmx1g" dir="${solr.directory}">
                                    <include name="**/bin/solr.in.cmd" />
                                </replace>
                                <replace token="#SOLR_JAVA_MEM=&quot;-Xms512m -Xmx512m&quot;" value="SOLR_JAVA_MEM=&quot;-Xms1g -Xmx1g&quot;" dir="${solr.directory}">
                                    <include name="**/bin/solr.in.sh" />
                                </replace>
                                <replace token="${alfresco.search.ssl.need.token}" value="${alfresco.search.ssl.need}" dir="${solr.directory}">
                                    <include name="**/server/etc/jetty-ssl.xml" />
                                </replace>
                                <replace token="wantClientAuth" value="wantclientauth" dir="${solr.directory}">
                                    <include name="**/server/etc/jetty-ssl.xml" />
                                </replace>
                                <replace token="STORE_TYPE=JKS" value="STORE_TYPE=JCEKS" dir="${solr.directory}">
                                    <include name="**/bin/solr.in.cmd" />
                                    <include name="**/bin/solr.in.sh" />
                                </replace>
                                <replace token="JKS" value="JCEKS" dir="${solr.directory}">
                                    <include name="**/server/etc/jetty-ssl.xml" />
                                </replace>
                                <chmod file="${solr.directory}/bin/solr" perm="755" />
                            </target>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
               <!-- DO NOT CHANGE THE FORMATTING FOR THIS PLUGIN CONFIGURATION -->
               <groupId>com.google.code.maven-replacer-plugin</groupId>
               <artifactId>replacer</artifactId>
               <executions>
                  <execution>
                     <id>alter-index.css</id>
                     <phase>prepare-package</phase>
                     <goals>
                        <goal>replace</goal>
                     </goals>
                     <configuration>
                        <file>${solr.directory}/server/solr-webapp/webapp/css/angular/index.css</file>
                        <replacements>
                           <replacement>
                              <token>property\.png \); }</token>
                              <value>property.png ); }
#content #index #versions .alfresco span { background-image: url( ../../img/alfresco-ico.png ); }</value>
                           </replacement>
                        </replacements>
                     </configuration>
                  </execution>
                  <execution>
                     <id>alter-index.html</id>
                     <phase>prepare-package</phase>
                     <goals>
                        <goal>replace</goal>
                     </goals>
                     <configuration>
                        <file>${solr.directory}/server/solr-webapp/webapp/partials/index.html</file>
                        <replacements>
                           <replacement>
                              <token>&lt;li class="solr solr_spec_version"&gt;</token>
                              <value>
              &lt;li class="alfresco"&gt;&lt;dl class="clearfix"&gt;
                &lt;dt&gt;&lt;span&gt;Search Services&lt;/span&gt;&lt;/dt&gt;
                  &lt;dd&gt;\${project.version}&lt;/dd&gt;
              &lt;/dl&gt;&lt;/li&gt;

              &lt;li&gt;&lt;dl class="clearfix"&gt;
                &lt;dt&gt;&lt;span&gt;&lt;/span&gt;&lt;/dt&gt;
                  &lt;dd&gt;\${project.revision.key} - \${project.timestamp}&lt;/dd&gt;
              &lt;/dl&gt;&lt;/li&gt;

              &lt;li class="solr solr_spec_version"&gt;
                              </value>
                           </replacement>
                        </replacements>
                     </configuration>
                  </execution>
                   <execution>
                       <id>jquery-upgrade</id>
                       <phase>prepare-package</phase>
                       <goals>
                           <goal>replace</goal>
                       </goals>
                       <configuration>
                           <file>${solr.directory}/server/solr-webapp/webapp/index.html</file>
                           <replacements>
                               <replacement>
                                   <token>libs/jquery-2.1.3.min.js</token>
                                   <value>libs/jquery-3.5.1.min.js</value>
                               </replacement>
                           </replacements>
                       </configuration>
                   </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>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <executions>
                   <execution>
                      <id>third-party-licenses</id>
                      <phase>none</phase>
                   </execution>
                </executions>
             </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>