<?xml version="1.0" encoding="UTF-8"?>
<!--
  Copyright (C) FuseSource, Inc.
  http://fusesource.com

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
  -->

<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">
    <parent>
        <groupId>com.fusesource.fmc</groupId>
        <artifactId>fmc-project</artifactId>
        <version>0.9.8-beta</version>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.fusesource.fmc</groupId>
    <artifactId>fmc-distro</artifactId>
    <name>${project.artifactId}</name>
    <description>Fuse Management Console :: Binary Distribution</description>

       <prerequisites>
           <maven>2.2.1</maven>
       </prerequisites>

       <properties>
        <assembly-name>fmc-${project.version}</assembly-name>
        <fmc-version>${project.version}</fmc-version>
      </properties>

       <dependencies>
           <!-- Karaf Dependencies -->
           <!--
           <dependency>
               <groupId>org.apache.karaf</groupId>
               <artifactId>apache-karaf</artifactId>
               <version>${karaf-version}</version>
               <type>tar.gz</type>
           </dependency>
           <dependency>
               <groupId>org.apache.karaf</groupId>
               <artifactId>apache-karaf</artifactId>
               <version>${karaf-version}</version>
               <type>zip</type>
           </dependency>
         -->

           <!-- Fabric Dependencies -->
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fuse-fabric</artifactId>
               <version>${fabric.version}</version>
               <type>tar.gz</type>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fuse-fabric</artifactId>
               <version>${fabric.version}</version>
               <type>zip</type>
           </dependency>

           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fabric-zookeeper</artifactId>
               <version>${fabric.version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fabric-zookeeper-commands</artifactId>
               <version>${fabric.version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fabric-linkedin-zookeeper</artifactId>
               <version>${fabric.version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fabric-core</artifactId>
               <version>${fabric.version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fabric-commands</artifactId>
               <version>${fabric.version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fabric-agent</artifactId>
               <version>${fabric.version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>fabric-configadmin</artifactId>
               <version>${fabric.version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric</groupId>
               <artifactId>org.fusesource.fabric.karaf.branding</artifactId>
               <version>${fabric.version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric.virt</groupId>
               <artifactId>org.fusesource.fabric.virt.commands</artifactId>
               <version>${fabric-virt-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric.virt</groupId>
               <artifactId>org.fusesource.fabric.virt.services</artifactId>
               <version>${fabric-virt-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric.virt.bundles</groupId>
               <artifactId>org.fusesource.fabric.virt.bundles.jna</artifactId>
               <version>${jna-bundle-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric.virt.bundles</groupId>
               <artifactId>org.fusesource.fabric.virt.bundles.libvirt</artifactId>
               <version>${libvirt-bundle-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.mq</groupId>
               <artifactId>mq-fabric</artifactId>
               <version>${mq-fabric-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.mq</groupId>
               <artifactId>mq-client</artifactId>
               <version>${mq-fabric-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.insight</groupId>
               <artifactId>insight-log</artifactId>
               <version>${insight-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.insight</groupId>
               <artifactId>insight-graph</artifactId>
               <version>${insight-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.insight</groupId>
               <artifactId>insight-log-elasticsearch</artifactId>
               <version>${insight-version}</version>
           </dependency>
           <dependency>
               <groupId>org.fusesource.fabric.fab</groupId>
               <artifactId>fab-osgi</artifactId>
               <version>${fab-version}</version>
           </dependency>

           <!-- FMC Dependencies -->
           <dependency>
               <groupId>com.fusesource.fmc</groupId>
               <artifactId>fmc-branding</artifactId>
               <version>${project.version}</version>
           </dependency>
           
       </dependencies>

       <build>
           <defaultGoal>install</defaultGoal>
           <resources>
              <!--
                <resource>
                   <directory>../etc</directory>
                   <filtering>true</filtering>
                   <targetPath>distro/etc</targetPath>
                </resource>
                -->
               <resource>
                   <directory>src/main/resources</directory>
                   <filtering>true</filtering>
               </resource>
           </resources>

           <plugins>
               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-resources-plugin</artifactId>
                   <version>2.4.3</version>
                   <executions>
                       <execution>
                           <id>filter</id>
                           <phase>process-resources</phase>
                           <goals>
                               <goal>resources</goal>
                           </goals>
                       </execution>
                   </executions>
               </plugin>

               <plugin>
                   <groupId>org.apache.karaf.tooling</groupId>
                   <artifactId>features-maven-plugin</artifactId>
                   <version>${karaf-version}</version>
                   <executions>
                       <execution>
                           <id>add-features-to-repo</id>
                           <phase>generate-resources</phase>
                           <goals>
                               <goal>add-features-to-repo</goal>
                           </goals>
                           <configuration>
                               <descriptors>
                                   <descriptor>mvn:org.fusesource.esb/fuse-esb/${fabric.version}/xml/features</descriptor>
                                   <descriptor>mvn:org.apache.karaf.assemblies.features/standard/${karaf-version}/xml/features</descriptor>
                                   <descriptor>mvn:org.apache.camel.karaf/apache-camel/${camel-version}/xml/features</descriptor>
                                   <descriptor>mvn:org.apache.activemq/activemq-karaf/${activemq-version}/xml/features</descriptor>
                                   <descriptor>mvn:org.jclouds.karaf/jclouds-karaf/${jclouds-karaf-version}/xml/features</descriptor>
                                   <descriptor>mvn:org.fusesource.fabric/fuse-fabric/${fabric.version}/xml/features</descriptor>
                                   <descriptor>mvn:org.fusesource.fabric.fabric-examples/fabric-activemq-demo/${fabric.version}/xml/features</descriptor>
                                   <descriptor>mvn:org.fusesource.fabric.fabric-examples/fabric-camel-demo/${fabric.version}/xml/features</descriptor>
                                   <descriptor>file:${basedir}/target/classes/features.xml</descriptor>
                               </descriptors>
                               <features>
                                  <feature>fabric-agent</feature>
                                  <feature>fabric-commands</feature>
                                  <feature>fabric-camel</feature>
                                  <feature>fabric-dosgi</feature>
                                  <feature>fabric-bundle</feature>
                                  <feature>fabric-monitor</feature>
                                  <feature>fabric-zeroconf</feature>
                                  <feature>jclouds-commands</feature>
                                  <feature>jclouds-compute</feature>                                   
                                  <feature>fabric-jclouds</feature>
                                  <feature>jclouds-cloudserver-uk</feature>
                                  <feature>jclouds-cloudserver-us</feature>
                                  <feature>jclouds-aws-ec2</feature>
                                  <feature>mq-fabric</feature>
                                  <feature>fabric-activemq-demo</feature>
                                  <feature>fabric-camel-demo</feature>
                                  <feature>insight-elasticsearch</feature>
                                  <feature>insight-log-elasticsearch</feature>
                                  <feature>fmc-webui</feature>
                               </features>                              
                               <includeMvnBasedDescriptors>true</includeMvnBasedDescriptors>
                               <repository>target/features-repo</repository>
                           </configuration>
                       </execution>
                   </executions>
               </plugin>

               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-antrun-plugin</artifactId>
                   <version>1.7</version>
                   <executions>
                       <execution>
                           <id>update-properties</id>
                           <phase>prepare-package</phase>
                           <goals>
                               <goal>run</goal>
                           </goals>
                           <configuration>
                               <target name="update-properties">

                                  <echo message="Updating etc/config.properties in unix assembly" />
                                  <concat destfile="target/dependencies/unix/fuse-fabric-${fabric.version}/etc/config.properties" append="true" eol="unix">
                                  <fileset file="src/main/append-resources/etc/config.properties" />
                                  </concat>
                                  <echo message="Updating etc/config.properties in windows assembly" />
                                  <concat destfile="target/dependencies/win/fuse-fabric-${fabric.version}/etc/config.properties" append="true" eol="dos">
                                      <fileset file="src/main/append-resources/etc/config.properties" />
                                  </concat>

                                  <echo message="Updating etc/custom.properties in unix assembly" />
                                  <concat destfile="target/dependencies/unix/fuse-fabric-${fabric.version}/etc/custom.properties" append="true" eol="unix">
                                  <fileset file="src/main/append-resources/etc/custom.properties" />
                                  </concat>
                                  <echo message="Updating etc/custom.properties in windows assembly" />
                                  <concat destfile="target/dependencies/win/fuse-fabric-${fabric.version}/etc/custom.properties" append="true" eol="dos">
                                      <fileset file="src/main/append-resources/etc/custom.properties" />
                                  </concat>

                                   <echo message="Updating etc/system.properties in unix assembly" />
                                   <concat destfile="target/dependencies/unix/fuse-fabric-${fabric.version}/etc/system.properties" append="true" eol="unix">
                                       <fileset file="src/main/append-resources/etc/system.properties" />
                                   </concat>
                                   <echo message="Updating etc/system.properties in windows assembly" />
                                   <concat destfile="target/dependencies/win/fuse-fabric-${fabric.version}/etc/system.properties" append="true" eol="dos">
                                       <fileset file="src/main/append-resources/etc/system.properties" />
                                   </concat>

                                  <echo message="Updating etc/org.apache.karaf.management.cfg in unix assembly" />
                                  <concat destfile="target/dependencies/unix/fuse-fabric-${fabric.version}/etc/org.apache.karaf.management.cfg" append="true" eol="unix">
                                  <fileset file="src/main/append-resources/etc/org.apache.karaf.management.cfg" />
                                  </concat>
                                  <echo message="Updating etc/org.apache.karaf.management.cfg in windows assembly" />
                                  <concat destfile="target/dependencies/win/fuse-fabric-${fabric.version}/etc/org.apache.karaf.management.cfg" append="true" eol="dos">
                                      <fileset file="src/main/append-resources/etc/org.apache.karaf.management.cfg" />
                                  </concat>
                                  
                                  <echo message="Fixing start/stop scripts in windows assembly" />
                                  <replace file="target/dependencies/win/fuse-fabric-${fabric.version}/bin/start.bat" token="fusefabric.bat" value="fmc.bat" />
                                  <replace file="target/dependencies/win/fuse-fabric-${fabric.version}/bin/stop.bat" token="fusefabric.bat" value="fmc.bat" />
                                  
                                  <echo message="Fixing start/stop scripts in unix assembly" />
                                  <replace file="target/dependencies/unix/fuse-fabric-${fabric.version}/bin/start" token="bin/fusefabric" value="bin/fmc" />
                                  <replace file="target/dependencies/unix/fuse-fabric-${fabric.version}/bin/stop" token="bin/fusefabric" value="bin/fmc" />
                               </target>
                           </configuration>
                       </execution>
                   </executions>
               </plugin>     

               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-assembly-plugin</artifactId>
                   <version>2.2.1</version>
                   <executions>
                       <execution>
                           <id>unix-bin</id>
                           <phase>package</phase>
                           <goals>
                               <goal>single</goal>
                           </goals>
                           <configuration>
                               <descriptors>
                                   <descriptor>src/main/descriptors/unix-bin.xml</descriptor>
                               </descriptors>
                               <finalName>${assembly-name}</finalName>
                               <tarLongFileMode>gnu</tarLongFileMode>
                               <appendAssemblyId>false</appendAssemblyId>
                           </configuration>
                       </execution>
                       <execution>
                           <id>windows-bin</id>
                           <phase>package</phase>
                           <goals>
                               <goal>single</goal>
                           </goals>
                           <configuration>
                               <descriptors>
                                   <descriptor>src/main/descriptors/windows-bin.xml</descriptor>
                               </descriptors>
                               <finalName>${assembly-name}</finalName>
                               <appendAssemblyId>false</appendAssemblyId>
                           </configuration>
                       </execution>
                   </executions>
               </plugin>

               <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>attach-artifacts</id>
                        <phase>package</phase>
                        <goals>
                            <goal>attach-artifact</goal>
                        </goals>
                        <configuration>
                          <artifacts>
                            <artifact>
                              <file>target/classes/features.xml</file>
                              <type>xml</type>
                              <classifier>features</classifier>
                            </artifact>                              
                          </artifacts>
                        </configuration>
                    </execution>
                </executions>
               </plugin>

               <plugin>
                   <groupId>org.apache.maven.plugins</groupId>
                   <artifactId>maven-dependency-plugin</artifactId>
                   <executions>
                       <execution>
                           <id>unpack-unix</id>
                           <phase>generate-resources</phase>
                           <goals>
                               <goal>unpack</goal>
                           </goals>
                           <configuration>
                               <artifactItems>
                                   <artifactItem>
                                       <groupId>org.fusesource.fabric</groupId>
                                       <artifactId>fuse-fabric</artifactId>
                                       <version>${fabric.version}</version>
                                       <type>tar.gz</type>
                                       <outputDirectory>target/dependencies/unix</outputDirectory>
                                   </artifactItem>
                               </artifactItems>
                           </configuration>
                       </execution>
                       <execution>
                           <id>unpack-win</id>
                           <phase>generate-resources</phase>
                           <goals>
                               <goal>unpack</goal>
                           </goals>
                           <configuration>
                               <artifactItems>
                                   <artifactItem>
                                       <groupId>org.fusesource.fabric</groupId>
                                       <artifactId>fuse-fabric</artifactId>
                                       <version>${fabric.version}</version>
                                       <type>zip</type>
                                       <outputDirectory>target/dependencies/win</outputDirectory>
                                   </artifactItem>
                               </artifactItems>
                           </configuration>
                       </execution>
                   </executions>
               </plugin>

           </plugins>
           <pluginManagement>
           	<plugins>
           		<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
           		<plugin>
           			<groupId>org.eclipse.m2e</groupId>
           			<artifactId>lifecycle-mapping</artifactId>
           			<version>1.0.0</version>
           			<configuration>
           				<lifecycleMappingMetadata>
           					<pluginExecutions>
           						<pluginExecution>
           							<pluginExecutionFilter>
           								<groupId>
           									org.apache.karaf.tooling
           								</groupId>
           								<artifactId>
           									features-maven-plugin
           								</artifactId>
           								<versionRange>
           									[2.2.2-fuse-02-06,)
           								</versionRange>
           								<goals>
           									<goal>
           										add-features-to-repo
           									</goal>
           								</goals>
           							</pluginExecutionFilter>
           							<action>
           								<ignore />
           							</action>
           						</pluginExecution>
           					</pluginExecutions>
           				</lifecycleMappingMetadata>
           			</configuration>
           		</plugin>
           	</plugins>
           </pluginManagement>
       </build>
   </project>
