<?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>
        <groupId>org.apache.servicemix.nmr</groupId>
        <artifactId>nmr-parent</artifactId>
        <version>1.4.0</version>
    </parent>

    <groupId>org.apache.servicemix.nmr</groupId>
    <artifactId>apache-servicemix-nmr</artifactId>
    <packaging>pom</packaging>
    <name>Apache ServiceMix :: NMR :: Assembly</name>

    <dependencies>
    
        <!-- Karaf (distribution and feature) -->
        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>apache-karaf</artifactId>
            <type>tar.gz</type>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>apache-karaf</artifactId>
            <type>zip</type>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>apache-karaf</artifactId>
            <type>xml</type>
            <classifier>features</classifier>
        </dependency>
        
        <!-- Aries -->
        <dependency>
            <groupId>org.apache.aries.transaction</groupId>
            <artifactId>org.apache.aries.transaction.manager</artifactId>
        </dependency>
        
        <!-- ServiceMix NMR -->
        <dependency>
            <groupId>org.apache.servicemix.nmr</groupId>
            <artifactId>org.apache.servicemix.nmr.api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.nmr</groupId>
            <artifactId>org.apache.servicemix.nmr.branding</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.nmr</groupId>
            <artifactId>org.apache.servicemix.nmr.commands</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.nmr</groupId>
            <artifactId>org.apache.servicemix.nmr.core</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.nmr</groupId>
            <artifactId>org.apache.servicemix.nmr.management</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.nmr</groupId>
            <artifactId>org.apache.servicemix.nmr.osgi</artifactId>
        </dependency>
        
        <!-- ServiceMix NMR Document -->
        <dependency>
            <groupId>org.apache.servicemix.document</groupId>
            <artifactId>org.apache.servicemix.document</artifactId>
        </dependency>
        
        <!-- ServiceMix NMR JBI -->
        <dependency>
            <groupId>org.apache.servicemix.jbi</groupId>
            <artifactId>org.apache.servicemix.jbi.commands</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.jbi</groupId>
            <artifactId>org.apache.servicemix.jbi.deployer</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.jbi</groupId>
            <artifactId>org.apache.servicemix.jbi.osgi</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.jbi</groupId>
            <artifactId>org.apache.servicemix.jbi.runtime</artifactId>
        </dependency>
        
        <!-- ServiceMix NMR Naming -->
        <dependency>
            <groupId>org.apache.servicemix.naming</groupId>
            <artifactId>org.apache.servicemix.naming</artifactId>
        </dependency>
        
        <!-- ServiceMix Specs -->
        <dependency>
            <groupId>org.apache.servicemix.specs</groupId>
            <artifactId>org.apache.servicemix.specs.activation-api-1.1</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.specs</groupId>
            <artifactId>org.apache.servicemix.specs.jbi-api-1.0</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.specs</groupId>
            <artifactId>org.apache.servicemix.specs.stax-api-1.0</artifactId>
        </dependency>
        
        <!-- ServiceMix Common and Utils -->
        <dependency>
            <groupId>org.apache.servicemix</groupId>
            <artifactId>servicemix-common</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix</groupId>
            <artifactId>servicemix-utils</artifactId>
        </dependency>
        
        <!-- ServiceMix Bundle Feature Dependencies -->
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.wsdl4j</artifactId>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.ant</artifactId>
        </dependency>
        
        <!-- Other Dependencies -->
        <dependency>
            <groupId>org.codehaus.woodstox</groupId>
            <artifactId>stax2-api</artifactId>
        </dependency>
        <dependency>
            <groupId>org.codehaus.woodstox</groupId>
            <artifactId>woodstox-core-asl</artifactId>
        </dependency>
        <dependency>
            <groupId>org.fusesource.commonman</groupId>
            <artifactId>commons-management</artifactId>    
        </dependency>
    
    </dependencies>
    
    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/filtered-resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
        <filters>
            <filter>target/filter.txt</filter>
        </filters>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-antrun-plugin</artifactId>
                <executions>
                    <execution>
                        <id>create-prop</id>
                        <phase>generate-resources</phase>
                        <configuration>
                            <tasks>
                                <taskdef resource="net/sf/antcontrib/antcontrib.properties" classpathref="maven.plugin.classpath" />
                                <property name="ant.regexp.regexpimpl" value="org.apache.tools.ant.util.regexp.Jdk14RegexpRegexp" />
                                <property name="mv" value="${karaf.version}" />
                                <echo message="Maven version: ${mv}" />
                                <propertyregex property="ov.p1" input="${mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace="\1" defaultValue="0" />
                                <propertyregex property="ov.p2" input="${mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\2" defaultValue=".0" />
                                <propertyregex property="ov.p3" input="${mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\3" defaultValue=".0" />
                                <propertyregex property="ov.p4" input="${mv}" regexp="(\d+)(?:\.(\d+)(?:\.(\d+))?)?(?:[^a-zA-Z0-9](.*))?" replace=".\4" defaultValue="" />
                                <propertyregex property="ov.p1a" input="${ov.p1}" regexp="(.+)" replace="\1" defaultValue="0" />
                                <propertyregex property="ov.p2a" input="${ov.p2}" regexp="(\..+)" replace="\1" defaultValue=".0" />
                                <propertyregex property="ov.p3a" input="${ov.p3}" regexp="(\..+)" replace="\1" defaultValue=".0" />
                                <propertyregex property="ov.p4a" input="${ov.p4}" regexp="(\..+)" replace="\1" defaultValue="" />
                                <property name="ov" value="${ov.p1a}${ov.p2a}${ov.p3a}${ov.p4a}" />
                                <echo message="OSGi version: ${ov}" />
                                <mkdir dir="target" />
                                <echo message="karaf.osgi.version = ${ov}" file="target/filter.txt" />
                            </tasks>
                        </configuration>
                        <goals>
                            <goal>run</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>filter</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </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.apache.karaf</groupId>
                                    <artifactId>apache-karaf</artifactId>
                                    <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.apache.karaf</groupId>
                                    <artifactId>apache-karaf</artifactId>
                                    <type>zip</type>
                                    <outputDirectory>target/dependencies/win</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                    <execution>
                        <id>copy</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>org.apache.servicemix.nmr</groupId>
                                    <artifactId>org.apache.servicemix.nmr.branding</artifactId>
                                    <outputDirectory>target/dependencies</outputDirectory>
                                    <destFileName>nmr-version.jar</destFileName>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </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.apache.karaf/apache-karaf/${karaf.version}/xml/features</descriptor>
                                <descriptor>file:${basedir}/target/classes/features.xml</descriptor>
                            </descriptors>
                            <features>
                                <feature>nmr</feature>
                                <feature>nmr-audit</feature>
                                <feature>jbi</feature>
                                <feature>jbi-cluster</feature>
                            </features>
                            <repository>target/features-repo</repository>
                        </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>
                        </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>${project.artifactId}-${project.version}</finalName>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unix-src</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/descriptors/unix-src.xml</descriptor>
                            </descriptors>
                            <tarLongFileMode>gnu</tarLongFileMode>
                        </configuration>
                    </execution>
                    <execution>
                        <id>windows-src</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src/main/descriptors/windows-src.xml</descriptor>
                            </descriptors>
                        </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>
        </plugins>
    </build>

</project>

