<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.alfresco</groupId>
        <artifactId>alfresco-share-packaging</artifactId>
        <version>-SNAPSHOT</version>
    </parent>
    <artifactId>alfresco-content-services-share-distribution</artifactId>
    <name>Distribution of Alfresco Share</name>
    <packaging>pom</packaging>

    <!-- To replace in share-config-custom.xml -->
    <properties>
        <BITROCK_TOMCAT_PORT>8080</BITROCK_TOMCAT_PORT>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>share</artifactId>
            <version>${project.version}</version>
            <type>war</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>alfresco-share-services</artifactId>
            <version>${project.version}</version>
            <type>amp</type>
        </dependency>
    </dependencies>

    <build>
        <finalName>${project.artifactId}-${project.version}</finalName>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>true</filtering>
            </resource>
            <resource>
                <directory>${project.build.directory}/dependency/bitrock/bitrock/alfresco/shared/web-extension</directory>
                <targetPath>${project.build.outputDirectory}/web-extension-samples</targetPath>
                <filtering>true</filtering>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <!-- Copies local files: README, ... -->
                    <execution>
                        <id>default-resources</id>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                        <configuration>
                            <delimiters>
                                <delimiter>${*}</delimiter>
                                <delimiter>@@</delimiter> <!-- To replace Tomcat port in share-config-custom.xml -->
                            </delimiters>
                            <useDefaultDelimiters>false</useDefaultDelimiters>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <!-- Extract share-config-custom.xml -->
                    <execution>
                        <id>extract-share-config-custom</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>alfresco-installer-resources</artifactId>
                                    <version>6.0.2.1-ea</version>
                                    <includes>**/share-config-custom.xml</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>

                    <!-- Extract keystore from alfresco-repository -->
                    <execution>
                        <id>extract-keystore</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>alfresco-repository</artifactId>
                                    <version>${dependency.alfresco-repository.version}</version>
                                    <includes>alfresco/keystore/**</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>

                    <!-- Extract licenses and bin from distribution resources 
					Assuming this is not necessary for ACS 6.0+
                    <execution>
                        <id>unpack-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-platform-community-distributionzip</artifactId>
                                    <version>${alfresco.platform.version}</version>
                                    <outputDirectory>${project.build.outputDirectory}</outputDirectory>
                                    <includes>bin/**,licenses/**</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
-->
                    <!-- Copy MMT jar -->
                    <execution>
                        <id>fetch-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-mmt</artifactId>
                                    <version>6.0</version>
                                    <outputDirectory>${project.build.outputDirectory}/bin</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                            <stripVersion>true</stripVersion>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                 <executions>
                    <execution>
                        <id>package-share</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <appendAssemblyId>false</appendAssemblyId>
                    <descriptors>
                        <descriptor>src/assembly/share-distribution.xml</descriptor>
                    </descriptors>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
