<?xml version="1.0" encoding="UTF-8"?>
<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">

    <!--

        Licensed to the Apache Software Foundation (ASF) under one or more
        contributor license agreements.  See the NOTICE file distributed with
        this work for additional information regarding copyright ownership.
        The ASF licenses this file to You 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.
    -->

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <artifactId>assemblies</artifactId>
        <groupId>org.apache.servicemix.assemblies</groupId>
        <version>6.1.3</version>
    </parent>

    <groupId>org.apache.servicemix</groupId>
    <artifactId>apache-servicemix</artifactId>
    <packaging>pom</packaging>
    <name>Apache ServiceMix :: Assemblies :: Default Distribution</name>

    <properties>
        <examples.directory>../../examples</examples.directory>
    </properties>

    <dependencies>

        <!-- Apache Karaf -->
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>framework</artifactId>
            <type>kar</type>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>standard</artifactId>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>spring</artifactId>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>enterprise</artifactId>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>

        <!-- Apache Camel -->
        <dependency>
            <groupId>org.apache.camel.karaf</groupId>
            <artifactId>apache-camel</artifactId>
            <type>xml</type>
            <classifier>features</classifier>
            <scope>runtime</scope>
        </dependency>

        <!-- Apache CXF -->
        <dependency>
            <groupId>org.apache.cxf.karaf</groupId>
            <artifactId>apache-cxf</artifactId>
            <type>xml</type>
            <classifier>features</classifier>
            <scope>runtime</scope>
        </dependency>

        <!-- Apache ActiveMQ -->
        <dependency>
            <groupId>org.apache.activemq</groupId>
            <artifactId>activemq-karaf</artifactId>
            <type>xml</type>
            <classifier>features</classifier>
            <scope>runtime</scope>
        </dependency>

        <!-- Apache ServiceMix -->
        <dependency>
            <groupId>org.apache.servicemix.features</groupId>
            <artifactId>servicemix-internal</artifactId>
            <version>${project.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.features</groupId>
            <artifactId>servicemix-features</artifactId>
            <version>${project.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.features</groupId>
            <artifactId>servicemix-examples</artifactId>
            <version>${project.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.features</groupId>
            <artifactId>servicemix-kie</artifactId>
            <version>${project.version}</version>
            <classifier>features</classifier>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>

        <!-- branding -->
        <dependency>
            <groupId>org.apache.servicemix</groupId>
            <artifactId>org.apache.servicemix.branding</artifactId>
        </dependency>

    </dependencies>
            
    <repositories>
        <!-- SpringSource EBR is necessary to get some Spring OSGi bundles atm -->
        <repository>
            <id>com.springsource.repository.bundles.release</id>
            <name>SpringSource Enterprise Bundle Repository - SpringSource Bundle Releases</name>
            <url>http://repository.springsource.com/maven/bundles/release</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>
                
    <build>
        <resources>
            <resource>
                <directory>src/main/resources</directory>
                <filtering>false</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
            <resource>
                <directory>src/main/filtered-resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
            <resource>
                <directory>${project.basedir}/../..</directory>
                <filtering>false</filtering>
                <includes>
                    <include>README</include>
                    <include>RELEASE*</include>
                </includes>
            </resource>
            <resource>
                <directory>${project.build.directory}/dependencies</directory>
                <filtering>false</filtering>
                <excludes>
                    <exclude>**/*.i??</exclude>
                    <exclude>**/.target</exclude>
                    <exclude>**/.classpath</exclude>
                </excludes>
            </resource>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <version>${karaf.version}</version>
                <executions>
                    <execution>
                        <id>install-kar</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>install-kars</goal>
                        </goals>
                    </execution>
                    <!-- we will use custom assembly
                    <execution>
                        <id>package</id>
                        <goals>
                            <goal>instance-create-archive</goal>
                        </goals>
                    </execution>
                    -->
                </executions>
                <configuration>
                    <installedFeatures>
                        <feature>wrapper</feature>
                        <!-- To ensure the overriden bundles exist in 'system' -->
                        <feature>override-joda-time</feature>
                        <feature>override-fasterxml-jackson</feature>
                    </installedFeatures>
                    <bootFeatures>
                        <feature>cxf</feature>
                        <feature>obr</feature>
                        <feature>config</feature>
                        <feature>standard</feature>
                        <feature>package</feature>
                        <feature>kar</feature>
                        <feature>ssh</feature>
                        <feature>management</feature>
                        <feature>eventadmin</feature>
                        <feature>activemq-broker-noweb</feature>
                        <feature>activemq-service</feature>
                        <feature>camel</feature>
                        <feature>camel-cxf</feature>
                        <feature>activemq-camel</feature>
                        <feature>camel-blueprint</feature>
                        <feature>war</feature>
                        <feature>jaxrs-api</feature>
                    </bootFeatures>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack</id>
                        <phase>process-resources</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <artifactItems>
                        <artifactItem>
                            <groupId>org.apache.karaf</groupId>
                            <artifactId>demos</artifactId>
                            <version>${karaf.version}</version>
                        </artifactItem>
                    </artifactItems>
                    <outputDirectory>${project.build.directory}/dependencies/examples/karaf</outputDirectory>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>process-resources</id>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <!--
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-remote-resources-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enable-obr</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target name="enable-obr">
                                <echo message="Updating etc/startup.properties in assembly" />
                                <concat destfile="${project.build.directory}/assembly/etc/startup.properties" append="true">
                                    <string value="${line.separator}" />
                                    <fileset file="${project.build.outputDirectory}/startup-obr.properties" />
                                </concat>
                            </target>
                        </configuration>
                    </execution>
                    <execution>
                        <id>increase-perm-mem</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>run</goal>
                        </goals>
                        <configuration>
                            <target name="increase-perm-mem">
                                <echo message="Updating bin/setenv in unix assembly" />
                                <concat destfile="${project.build.directory}/assembly/bin/setenv" append="true" eol="unix">
                                    <fileset file="${project.build.outputDirectory}/setenv-unix" />
                                </concat>
                                <echo message="Updating bin/setenv.bat in windows assembly" />
                                <concat destfile="${project.build.directory}/assembly/bin/setenv.bat" append="true" eol="dos">
                                    <fileset file="${project.build.outputDirectory}/setenv-win" />
                                </concat>
                            </target>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-assembly-plugin</artifactId>
                <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>${project.artifactId}-${project.version}</finalName>
                            <tarLongFileMode>gnu</tarLongFileMode>
                            <appendAssemblyId>false</appendAssemblyId>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unix-src</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>attached</goal>
                                </goals>
                                <configuration>
                                    <descriptors>
                                        <descriptor>src/main/descriptors/unix-src.xml</descriptor>
                                    </descriptors>
                                </configuration>
                                <inherited>false</inherited>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
