<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>
    <parent>
        <groupId>org.alfresco</groupId>
        <artifactId>alfresco-share-packaging</artifactId>
        <version>5.2.f</version>
    </parent>
    <artifactId>alfresco-share-installer</artifactId>
    <packaging>pom</packaging>
    <name>Alfresco Share Installers</name>

    <properties>
        <binaries.folder>${user.home}/binaries</binaries.folder>
        <bitrock.folder>${project.build.directory}/installbuilder</bitrock.folder>
        <signing.key.location>${binaries.folder}/build-classpath/code-signing</signing.key.location>
        <license.file.location>${binaries.folder}/build-classpath/license.xml</license.file.location>
        <p12Password></p12Password> 
        <bitrock.arguments>
           project.outputDirectory=${project.build.directory} 
           project.version=${project.version} 
           project.fullName='Alfresco Content Services Share' 
           project.osxSigningPkcs12File=${signing.key.location}/Alfresco-Software-Ltd-osx.p12 
           project.osxSigningPkcs12Password=${p12Password} 
           project.windowsSigningPkcs12File=${signing.key.location}/Alfresco-Software-Ltd.p12 
           project.windowsSigningPkcs12Password=${p12Password} 
           alfresco_edition=enterprise 
           alfresco_package='${alfresco.package.name}' 
           postgres_component_enabled=0 
           alfrescocustomstacksettings_component_enabled=1 
           libreofficecomponent_component_enabled=0 
           libreofficevalidations_component_enabled=0 
           alfrescogoogledocs_component_enabled=0 
           alfrescosolr_component_enabled=0 
           alfrescosolr4_component_enabled=0 
           alfrescowcmqs_component_enabled=0 
           imagemagick_component_enabled=0 
           aosmodule_component_enabled=0 
        </bitrock.arguments>
        <shareInstaller>true</shareInstaller>
    </properties>

    <dependencies>
        <!-- These binaries are extracted using tar, to preserve symlinks -->

        <!-- Common -->
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>installer-common</artifactId>
            <version>${installer.common.version}</version>
            <classifier>linux</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>installer-common</artifactId>
            <version>${installer.common.version}</version>
            <classifier>osx</classifier>
            <type>tgz</type>
        </dependency>

        <!-- Tomcat -->
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat</artifactId>
            <version>${installer.tomcat.version}</version>
            <classifier>linux</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat</artifactId>
            <version>${installer.tomcat.version}</version>
            <classifier>osx</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat</artifactId>
            <version>${installer.tomcat.version}</version>
            <classifier>win32</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>tomcat</artifactId>
            <version>${installer.tomcat.version}</version>
            <classifier>win64</classifier>
            <type>tgz</type>
        </dependency>

        <!-- Java -->
        <dependency>
            <groupId>com.oracle.java</groupId>
            <artifactId>jre</artifactId>
            <version>${installer.java.version}</version>
            <classifier>linux</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>com.oracle.java</groupId>
            <artifactId>jre</artifactId>
            <version>${installer.java.version}</version>
            <classifier>osx</classifier>
            <type>tgz</type>
        </dependency>        
        <dependency>
            <groupId>com.oracle.java</groupId>
            <artifactId>jre</artifactId>
            <version>${installer.java.version}</version>
            <classifier>win32</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>com.oracle.java</groupId>
            <artifactId>jre</artifactId>
            <version>${installer.java.version}</version>
            <classifier>win64</classifier>
            <type>tgz</type>
        </dependency>

        <!-- Installbuilder -->
        <dependency>
            <groupId>com.bitnami</groupId>
            <artifactId>installbuilder</artifactId>
            <version>${installer.installbuilder.version}</version>
            <classifier>linux</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>com.bitnami</groupId>
            <artifactId>installbuilder</artifactId>
            <version>${installer.installbuilder.version}</version>
            <classifier>osx</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>com.bitnami</groupId>
            <artifactId>installbuilder</artifactId>
            <version>${installer.installbuilder.version}</version>
            <classifier>win</classifier>
            <type>tgz</type>
        </dependency>
        
        <!-- Manager -->
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>manager</artifactId>
            <version>${installer.manager.version}</version>
            <classifier>linux</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>manager</artifactId>
            <version>${installer.manager.version}</version>
            <classifier>osx</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>manager</artifactId>
            <version>${installer.manager.version}</version>
            <classifier>win32</classifier>
            <type>tgz</type>
        </dependency>
        <dependency>
            <groupId>org.alfresco</groupId>
            <artifactId>manager</artifactId>
            <version>${installer.manager.version}</version>
            <classifier>win64</classifier>
            <type>tgz</type>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>get-distribution</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-installer-resources</artifactId>
                                    <version>${alfresco.platform.version}</version>
                                    <outputDirectory>${project.build.directory}/classes</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>org.alfresco</groupId>
                                    <artifactId>alfresco-content-services-share-distribution</artifactId>
                                    <version>${project.version}</version>
                                    <type>zip</type>
                                    <outputDirectory>${project.build.directory}/distribution</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <!-- Override local resources - alfresco-global.properties, etc. -->
            <plugin>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>override-local-resources</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}</outputDirectory>
                            <overwrite>true</overwrite>
                            <nonFilteredFileExtensions>
                                <nonFilteredFileExtension>properties</nonFilteredFileExtension>
                            </nonFilteredFileExtensions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <!-- Extract all the binaries: Tomcat, Java, Installbuilder-->
                    <execution>
                        <id>extract-binaries-tgz</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target>
                                <ant antfile="${project.build.directory}/classes/extract-binaries.xml" />
                            </target>
                        </configuration>
                    </execution>
                    <!-- Build installers -->
                    <execution>
                        <id>build-installers</id>
                        <phase>package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <workingDirectory>${project.build.directory}/classes/bitrock</workingDirectory>
                            <target>
                                <ant antfile="${project.build.directory}/classes/build-installers.xml" />
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <!-- Profiles to set the right path to Bitrock Builder executable -->
        <profile>
            <id>win-bitrock</id>
            <activation>
                <os>
                    <family>windows</family>
                </os>
            </activation>
            <properties>
                <bitrock.executable>${bitrock.folder}/bin/builder-cli.exe</bitrock.executable>
            </properties>
        </profile>
        <profile>
            <id>linux-bitrock</id>
            <activation>
                <os>
                    <family>linux</family>
                </os>
            </activation>
            <properties>
                <bitrock.executable>${bitrock.folder}/bin/builder</bitrock.executable>
            </properties>
        </profile>
        <profile>
            <id>osx-bitrock</id>
            <activation>
                <os>
                    <family>mac</family>
                </os>
            </activation>
            <properties>
                <bitrock.executable>${bitrock.folder}/bin/builder</bitrock.executable>
            </properties>
        </profile>
    </profiles>
    
</project>
