<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-share-parent</artifactId>
    <version>14.27</version>
    <packaging>pom</packaging>
    <name>Alfresco Share Parent</name>

    <parent>
        <groupId>org.alfresco</groupId>
        <artifactId>alfresco-super-pom</artifactId>
        <version>12</version>
    </parent>

    <modules>
        <module>share</module>
        <module>web-framework-commons</module>
        <module>web-editor</module>
        <module>web-editor-plugin</module>
        <module>web-editor-samples/customer-site</module>
        <module>wcmquickstart-module</module>
        <module>share-encryption</module>
        <module>packaging</module>
        <module>amps</module>
    </modules>

    <properties>
        <version.major>7</version.major>
        <version.minor>1</version.minor>
        <version.revision>0</version.revision>
        <amp.min.version>${version.major}.0.0</amp.min.version>

        <!-- Version of Alfresco Community Repo to depend on -->
        <dependency.alfresco-community-repo.version>14.39</dependency.alfresco-community-repo.version>
        <dependency.alfresco-enterprise-repo.version>14.41</dependency.alfresco-enterprise-repo.version>
        <alfresco.api-explorer.version>7.1.0.1</alfresco.api-explorer.version>

        <image.registry>quay.io</image.registry>
        <image.tag>latest</image.tag>

        <!-- Java 11 compatibility -->
        <java.version>11</java.version>
        <maven.compiler.source>${java.version}</maven.compiler.source>
        <maven.compiler.target>${java.version}</maven.compiler.target>
        <maven.build.sourceVersion>${java.version}</maven.build.sourceVersion>
        <argLine>-Xmx2G -Duser.language=en -Dcom.sun.management.jmxremote</argLine>

        <!-- common dependencies-->
        <dependency.spring.version>5.3.7</dependency.spring.version>
        <dependency.yui.version>2.9.0-alfresco-20141223</dependency.yui.version>

        <dependency.aikau.version>1.0.114</dependency.aikau.version>
        <dependency.freemarker.version>2.3.30</dependency.freemarker.version>
        <dependency.rhino.version>1.7.13</dependency.rhino.version>
        <dependency.httpcomponents.version>4.5.13</dependency.httpcomponents.version>
        <dependency.alfresco-jlan.version>7.1</dependency.alfresco-jlan.version>

        <dependency.webscripts.version>8.26</dependency.webscripts.version>
        <dependency.surf.version>8.17</dependency.surf.version>
        <dependency.alfresco-sdk.version>2.2.0</dependency.alfresco-sdk.version>
        <dependency.dom4j.version>2.1.3</dependency.dom4j.version>
        <dependency.slf4j.version>1.7.30</dependency.slf4j.version>
        <dependency.cxf.version>3.4.1</dependency.cxf.version>
        <dependency.beanutils.version>1.9.4</dependency.beanutils.version>
        <dependency.keycloak.version>15.0.2</dependency.keycloak.version>
        <dependency.apache.taglibs.version>1.2.5</dependency.apache.taglibs.version>
        <dependency.jackson.version>2.12.2</dependency.jackson.version>
        <dependency.jakarta-jaxb-api.version>2.3.3</dependency.jakarta-jaxb-api.version>
        <dependency.org-json.version>20210307</dependency.org-json.version>

        <alfresco.googledrive.version>3.2.1</alfresco.googledrive.version>

        <!-- Developer's runtime environment configuration -->
        <runtime.parent.folder>${basedir}/..</runtime.parent.folder>
        <runtime.data.folder>${runtime.parent.folder}/runtime</runtime.data.folder>
        <runtime.tomcat.conf.folder>${runtime.parent.folder}/tomcat</runtime.tomcat.conf.folder>
        <runtime.solr.folder>${runtime.data.folder}/solr4-instance</runtime.solr.folder>
        <alfresco.properties.file>${runtime.tomcat.conf.folder}/shared/classes/alfresco-global.properties</alfresco.properties.file>
        <!-- Define the location where alfresco will store its content files, i.e. *.bin) -->
        <dir.root>${runtime.data.folder}/alf_data</dir.root>

        <db.skip>true</db.skip>
        <test.working.dir>${project.build.directory}</test.working.dir>
        <img.exe>convert</img.exe>
        <swf.exe>pdf2swf</swf.exe>

        <license-maven-plugin.version>3.0</license-maven-plugin.version>
        <license-header-location>${maven.multiModuleProjectDirectory}</license-header-location>

        <repo.image.tag>${dependency.alfresco-enterprise-repo.version}</repo.image.tag>
        <docker.quay-expires.value>1w</docker.quay-expires.value>
    </properties>

    <scm>
        <connection>scm:git:https://github.com/Alfresco/alfresco-enterprise-share.git/</connection>
        <developerConnection>scm:git:https://github.com/Alfresco/alfresco-enterprise-share.git</developerConnection>
        <url>https://github.com/Alfresco/alfresco-enterprise-share</url>
        <tag>14.27</tag>
    </scm>

    <distributionManagement>
        <repository>
            <id>alfresco-internal</id>
            <url>https://artifacts.alfresco.com/nexus/content/repositories/releases</url>
        </repository>
    </distributionManagement>

    <dependencyManagement>
        <dependencies>
            <!-- Override dependencies with the locally defined versions -->
            <dependency>
                <groupId>org.alfresco</groupId>
                <artifactId>alfresco-jlan-embed</artifactId>
                <version>${dependency.alfresco-jlan.version}</version>
            </dependency>
            <dependency>
                <groupId>org.alfresco.surf</groupId>
                <artifactId>spring-webscripts</artifactId>
                <version>${dependency.webscripts.version}</version>
            </dependency>
            <dependency>
                <groupId>org.alfresco.surf</groupId>
                <artifactId>spring-webscripts-api</artifactId>
                <version>${dependency.webscripts.version}</version>
            </dependency>
            <dependency>
                <groupId>org.alfresco.surf</groupId>
                <artifactId>spring-surf-core</artifactId>
                <version>${dependency.webscripts.version}</version>
            </dependency>
            <dependency>
                <groupId>org.alfresco.surf</groupId>
                <artifactId>spring-surf-core-configservice</artifactId>
                <version>${dependency.webscripts.version}</version>
            </dependency>
            <dependency>
                <groupId>org.alfresco.surf</groupId>
                <artifactId>spring-surf</artifactId>
                <version>${dependency.surf.version}</version>
                <exclusions>
                    <!-- surf pulls in a an un-patched version, MNT-20234 -->
                    <exclusion>
                        <groupId>com.asual.lesscss</groupId>
                        <artifactId>lesscss-engine</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
            <dependency>
                <groupId>org.alfresco.surf</groupId>
                <artifactId>spring-surf-api</artifactId>
                <version>${dependency.surf.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpclient</artifactId>
                <version>${dependency.httpcomponents.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.httpcomponents</groupId>
                <artifactId>httpmime</artifactId>
                <version>${dependency.httpcomponents.version}</version>
            </dependency>
            <dependency>
                <groupId>javax.servlet</groupId>
                <artifactId>javax.servlet-api</artifactId>
                <version>4.0.1</version>
                <scope>provided</scope>
            </dependency>
            <dependency>
                <groupId>commons-fileupload</groupId>
                <artifactId>commons-fileupload</artifactId>
                <version>1.4</version>
            </dependency>
            <!-- Newer cxf libs, see MNT-20520 -->
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-core</artifactId>
                <version>${dependency.cxf.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-frontend-jaxws</artifactId>
                <version>${dependency.cxf.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-transports-http</artifactId>
                <version>${dependency.cxf.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.cxf</groupId>
                <artifactId>cxf-rt-ws-policy</artifactId>
                <version>${dependency.cxf.version}</version>
            </dependency>
            <dependency>
                <groupId>commons-beanutils</groupId>
                <artifactId>commons-beanutils</artifactId>
                <version>${dependency.beanutils.version}</version>
            </dependency>
            <!-- SHA-2404 -->
            <dependency>
                <groupId>org.keycloak</groupId>
                <artifactId>keycloak-servlet-filter-adapter</artifactId>
                <version>${dependency.keycloak.version}</version>
            </dependency>
            <dependency>
                <groupId>org.keycloak</groupId>
                <artifactId>keycloak-authz-client</artifactId>
                <version>${dependency.keycloak.version}</version>
            </dependency>
            <dependency>
                <groupId>org.keycloak</groupId>
                <artifactId>keycloak-core</artifactId>
                <version>${dependency.keycloak.version}</version>
            </dependency>
            <dependency>
                <groupId>org.keycloak</groupId>
                <artifactId>keycloak-adapter-core</artifactId>
                <version>${dependency.keycloak.version}</version>
            </dependency>
            <dependency>
                <groupId>org.keycloak</groupId>
                <artifactId>keycloak-adapter-spi</artifactId>
                <version>${dependency.keycloak.version}</version>
            </dependency>
            <dependency>
                <groupId>org.keycloak</groupId>
                <artifactId>keycloak-servlet-adapter-spi</artifactId>
                <version>${dependency.keycloak.version}</version>
            </dependency>
            <!-- SHA-2400 -->
            <dependency>
                <groupId>org.apache.maven</groupId>
                <artifactId>maven-artifact</artifactId>
                <version>3.6.3</version>
            </dependency>
            <!-- SHA-2432 -->
            <dependency>
                <groupId>org.apache.taglibs</groupId>
                <artifactId>taglibs-standard-spec</artifactId>
                <version>${dependency.apache.taglibs.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.taglibs</groupId>
                <artifactId>taglibs-standard-impl</artifactId>
                <version>${dependency.apache.taglibs.version}</version>
            </dependency>
            <dependency>
                <groupId>org.apache.taglibs</groupId>
                <artifactId>taglibs-standard-jstlel</artifactId>
                <version>${dependency.apache.taglibs.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-databind</artifactId>
                <version>${dependency.jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-core</artifactId>
                <version>${dependency.jackson.version}</version>
            </dependency>
            <dependency>
                <groupId>com.fasterxml.jackson.core</groupId>
                <artifactId>jackson-annotations</artifactId>
                <version>${dependency.jackson.version}</version>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-api</artifactId>
                <version>${dependency.slf4j.version}</version>
            </dependency>

            <dependency>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
                <version>${dependency.slf4j.version}</version>
            </dependency>

            <dependency>
                <groupId>junit</groupId>
                <artifactId>junit</artifactId>
                <version>4.13.1</version>
                <scope>test</scope>
            </dependency>

            <dependency>
                <groupId>org.alfresco</groupId>
                <artifactId>alfresco-mmt</artifactId>
                <version>${dependency.alfresco-community-repo.version}</version>
            </dependency>

            <dependency>
                <groupId>org.alfresco.integrations</groupId>
                <artifactId>alfresco-googledrive-share</artifactId>
                <version>${alfresco.googledrive.version}</version>
                <type>amp</type>
            </dependency>

            <!-- Jakarta... -->
            <dependency>
                <groupId>jakarta.xml.bind</groupId>
                <artifactId>jakarta.xml.bind-api</artifactId>
                <version>${dependency.jakarta-jaxb-api.version}</version>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>${dependency.jakarta-jaxb-api.version}</version>
            </dependency>

            <dependency>
                <groupId>org.json</groupId>
                <artifactId>json</artifactId>
                <version>${dependency.org-json.version}</version>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>com.mycila</groupId>
                <artifactId>license-maven-plugin</artifactId>
                <version>${license-maven-plugin.version}</version>
<!--                TODO: fix me-->
<!--                <configuration>-->
<!--                    <aggregate>true</aggregate>-->
<!--                    &lt;!&ndash; DO NOT ALIGN or FORMAT the license header as it would mess up the license check! &ndash;&gt;-->
<!--                    <header>${license-header-location}/license-header.txt</header>-->
<!--                    <includes>-->
<!--                        <include>**/*.java</include>-->
<!--                        <include>**/*.jsp</include>-->
<!--                    </includes>-->
<!--                    <mapping>-->
<!--                        <java>SLASHSTAR_STYLE</java>-->
<!--                    </mapping>-->
<!--                </configuration>-->
<!--                <executions>-->
<!--                    <execution>-->
<!--                        <id>validate-license</id>-->
<!--                        <phase>validate</phase>-->
<!--                        <goals>-->
<!--                            <goal>check</goal>-->
<!--                        </goals>-->
<!--                    </execution>-->
<!--                </executions>-->
            </plugin>
            <plugin>
                <groupId>org.alfresco.maven.plugin</groupId>
                <artifactId>alfresco-maven-plugin</artifactId>
                <version>${dependency.alfresco-sdk.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <version>3.0.0-M3</version>
                <executions>
                    <execution>
                        <id>enforcer</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <configuration>
                            <rules>
                                <requireJavaVersion>
                                    <version>[1.8.0,)</version>
                                </requireJavaVersion>
                            </rules>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>properties-maven-plugin</artifactId>
                <executions>
                    <!-- Read alfresco-global.properties if it exists, to use it for cleaning runtime data (e.g. which database?) -->
                    <execution>
                        <id>read-alfresco-global-properties</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>read-project-properties</goal>
                        </goals>
                        <configuration>
                            <files>
                                <file>${alfresco.properties.file}</file>
                            </files>
                            <quiet>true</quiet>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>set-default-db-props-on-initialize</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <exportAntProperties>true</exportAntProperties>
                            <target>
                                <property name="db.driver" value="org.postgresql.Driver" />
                                <property name="db.name" value="alfresco" />
                                <property name="db.url" value="jdbc:postgresql:${db.name}" />
                                <property name="db.master.url" value="jdbc:postgresql:template1" />
                                <property name="db.username" value="alfresco" />
                                <property name="db.password" value="alfresco" />
                                <property name="db.master.username" value="alfresco" />
                                <property name="db.master.password" value="alfresco" />
                                <property name="db.drop.command" value="drop database if exists ${db.name}" />
                                <property name="db.create.command" value="create database ${db.name}" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Create a jar of test classes -->
            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <executions>
                    <execution>
                        <id>create-test-jar</id>
                        <goals>
                            <goal>test-jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>

            <!--
               Add tomcat's shared/classes as a test source. This is not a nice solution
               to getting alfresco-global.properties onto the classpath, but since additionalClasspathElements
               for the surefire plugin does NOT work, we have to do something else.
               The problem with doing it this way is that the resources are copied to the target folder,
               rather than being referenced directly.
            -->
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-shared-classes</id>
                        <phase>generate-test-sources</phase>
                        <goals>
                            <goal>add-test-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${runtime.tomcat.conf.folder}/shared/classes</directory>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>net.alchim31.maven</groupId>
                <artifactId>yuicompressor-maven-plugin</artifactId>
                <version>1.5.1</version>
            </plugin>
        </plugins>

        <pluginManagement>
            <plugins>
                <!-- Ensure consistent maven-release-plugin version-->
                <plugin>
                    <artifactId>maven-release-plugin</artifactId>
                    <version>2.5.3</version>
                    <configuration>
                        <tagNameFormat>@{project.version}</tagNameFormat>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-jar-plugin</artifactId>
                    <version>3.2.0</version>
                    <configuration>
                        <archive>
                            <manifestEntries>
                                <Specification-Version>${version.major}.${version.minor}.${version.revision}</Specification-Version>
                                <Implementation-Version>${project.version}</Implementation-Version>
                                <Build-Number>${env.TRAVIS_BUILD_NUMBER}</Build-Number>
                            </manifestEntries>
                        </archive>
                    </configuration>
                </plugin>
                <plugin>
                    <artifactId>maven-war-plugin</artifactId>
                    <configuration>
                        <archive>
                            <manifestEntries>
                                <Specification-Version>${version.major}.${version.minor}.${version.revision}</Specification-Version>
                                <Implementation-Version>${project.version}</Implementation-Version>
                                <Build-Number>${env.TRAVIS_BUILD_NUMBER}</Build-Number>
                            </manifestEntries>
                        </archive>
                        <warSourceDirectory>src/main/webapp</warSourceDirectory>
                    </configuration>
                    <!-- Add dependency to alfresco-maven-plugin, to allow AMP overlays -->
                    <dependencies>
                        <dependency>
                            <groupId>org.alfresco.maven.plugin</groupId>
                            <artifactId>alfresco-maven-plugin</artifactId>
                            <version>${dependency.alfresco-sdk.version}</version>
                        </dependency>
                    </dependencies>
                </plugin>
                <plugin>
                    <artifactId>maven-surefire-plugin</artifactId>
                    <configuration>
                        <!-- To prevent tests alfresco.log to be created in project roots -->
                        <workingDirectory>${project.build.directory}</workingDirectory>
                        <systemPropertyVariables>
                            <!-- Allow FTP server unit test to run unprivileged -->
                            <ftp.port>50521</ftp.port>
                            <transferservice.receiver.enabled>true</transferservice.receiver.enabled>
                            <!-- Database related properties -->
                            <db.url>${db.url}</db.url>
                            <db.driver>${db.driver}</db.driver>
                            <db.name>${db.name}</db.name>
                            <db.username>${db.username}</db.username>
                            <db.password>${db.password}</db.password>
                            <dir.root>${dir.root}</dir.root>
                            <img.exe>${img.exe}</img.exe>
                            <swf.exe>${swf.exe}</swf.exe>
                            <index.subsystem.name>${index.subsystem.name}</index.subsystem.name>
                        </systemPropertyVariables>
                    </configuration>
                </plugin>

                <plugin>
                    <groupId>io.fabric8</groupId>
                    <artifactId>docker-maven-plugin</artifactId>
                    <version>0.34.1</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-resources-plugin</artifactId>
                    <version>3.2.0</version>
                </plugin>
                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-dependency-plugin</artifactId>
                    <version>3.1.2</version>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

    <profiles>
        <profile>
            <properties>
                <!-- Filter solrcore.properties -->
                <ALFRESCO_SOLR4_DATA_DIR>${runtime.solr.folder}/data</ALFRESCO_SOLR4_DATA_DIR>
            </properties>
            <id>run</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <!-- Download and unpack the tomcat config zip file -->
                            <execution>
                                <id>unpack-tomcat-config</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/tomcat-conf</outputDirectory>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.alfresco</groupId>
                                            <artifactId>alfresco-dev-tomcat</artifactId>
                                            <version>5.2.3</version>
                                            <classifier>config</classifier>
                                            <overWrite>true</overWrite>
                                            <type>zip</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>

                            <!-- Download and unpack the solr4 config zip file -->
                            <execution>
                                <id>unpack-solr4-config</id>
                                <phase>generate-resources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <outputDirectory>${project.build.directory}/solr4</outputDirectory>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.alfresco</groupId>
                                            <artifactId>alfresco-solr4</artifactId>
                                            <version>5.2.3</version>
                                            <!--<artifactId>alfresco-solrclient</artifactId>-->
                                            <!--<artifactId>alfresco-solr4</artifactId>-->
                                            <!--<version>6.7</version>-->
                                            <classifier>config</classifier>
                                            <overWrite>true</overWrite>
                                            <type>zip</type>
                                        </artifactItem>
                                    </artifactItems>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-resources-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>filter-copy-solr4-config</id>
                                <goals>
                                    <goal>copy-resources</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <outputDirectory>${runtime.solr.folder}</outputDirectory>
                                    <resources>
                                        <resource>
                                            <directory>${project.build.directory}/solr4</directory>
                                            <excludes>
                                                <exclude>workspace-SpacesStore/conf/solrcore.properties</exclude>
                                                <exclude>archive-SpacesStore/conf/solrcore.properties</exclude>
                                            </excludes>
                                            <filtering>false</filtering>
                                        </resource>
                                        <resource>
                                            <directory>${project.build.directory}/solr4</directory>
                                            <includes>
                                                <include>workspace-SpacesStore/conf/solrcore.properties</include>
                                                <include>archive-SpacesStore/conf/solrcore.properties</include>
                                            </includes>
                                            <filtering>true</filtering>
                                        </resource>
                                    </resources>
                                    <useDefaultDelimiters>false</useDefaultDelimiters>
                                    <delimiters>
                                        <delimiter>@@</delimiter>
                                    </delimiters>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>

                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <executions>
                            <!-- Copy tomcat config from build directory to correct location -->
                            <!--
                                Q. Why not unpack directly to ${runtime.tomcat.conf.folder} ?
                                A. There is no way of telling maven NOT to overwrite the directory if it is already there.
                                   overWrite doesn't work, overWriteIfNewer doesn't work either. The plugin uses marker files
                                   to determine whether the zip has already been unpacked, rather than using the actual folder
                                   where the contents are being unpacked - so if a clean is performed the marker files disappear
                                   and the zip is unpacked regardless (overwriting your customised tomcat config). Whilst you
                                   can change the location of the marker files, doing things this way really is going to be more
                                   reliable, since the existing directory will be respected properly.
                             -->
                            <execution>
                                <id>copy-tomcat-config</id>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <phase>generate-resources</phase>
                                <configuration>
                                    <target>
                                        <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
                                        <if>
                                            <available file="${runtime.tomcat.conf.folder}" type="dir" />
                                            <then>
                                                <echo message="Skipping creation of tomcat configuration, already exists: ${runtime.tomcat.conf.folder}" />
                                            </then>
                                            <else>
                                                <echo message="Creating tomcat runtime configuration: ${runtime.tomcat.conf.folder}" />
                                                <copy todir="${runtime.tomcat.conf.folder}">
                                                    <fileset dir="${project.build.directory}/tomcat-conf" />
                                                </copy>
                                            </else>
                                        </if>
                                    </target>
                                </configuration>
                            </execution>
                        </executions>
                        <dependencies>
                            <dependency>
                                <groupId>ant-contrib</groupId>
                                <artifactId>ant-contrib</artifactId>
                                <version>20020829</version>
                            </dependency>
                        </dependencies>
                    </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</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>

        <!--
            Use "mvn initialize -Ppurge" to drop repo, solr and DB data, then re-create an empty DB.
            Or use with a later phase to build and start a fresh repo all in one go, e.g.
            "mvn [clean] install -Ppurge,run"
          -->
        <profile>
            <id>purge</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-clean-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>delete-runtime-folders</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>clean</goal>
                                </goals>
                                <configuration>
                                    <excludeDefaultDirectories>true</excludeDefaultDirectories>
                                    <filesets>
                                        <fileset>
                                            <directory>${runtime.data.folder}</directory>
                                        </fileset>
                                    </filesets>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.codehaus.mojo</groupId>
                        <artifactId>sql-maven-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>drop-db</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <skip>false</skip><!-- always run -->
                                    <sqlCommand>${db.drop.command}</sqlCommand>
                                </configuration>
                            </execution>
                            <execution>
                                <id>create-db</id>
                                <phase>initialize</phase>
                                <goals>
                                    <goal>execute</goal>
                                </goals>
                                <configuration>
                                    <skip>false</skip><!-- always run -->
                                    <sqlCommand>${db.create.command}</sqlCommand>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>
