<?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.karaf</groupId>
        <artifactId>karaf</artifactId>
        <version>2.3.0.redhat-60024</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>org.apache.karaf.main</artifactId>
    <packaging>bundle</packaging>
    <name>Apache Karaf :: Main</name>
    <description>This bundle is the main Karaf launcher. It's responsible of the Karaf startup including the console, branding, etc bootstrap.</description>

    <properties>
        <appendedResourcesDirectory>${basedir}/../etc/appended-resources</appendedResourcesDirectory>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.bundles</groupId>
            <artifactId>org.apache.servicemix.bundles.junit</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.ops4j.pax.swissbox</groupId>
            <artifactId>pax-swissbox-tinybundles</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.1</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>org.apache.karaf.util</artifactId>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <filtering>true</filtering>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
        </resources>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
                            <addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <_donotcopy>(CVS|.svn|config.properties)</_donotcopy>
                        <Main-Class>org.apache.karaf.main.Main</Main-Class>
                        <Bundle-Name>Apache Karaf</Bundle-Name>
                        <Bundle-Description>OSGi R4 framework.</Bundle-Description>
                        <Export-Package />
                        <!--
                        <Private-Package>
                            org.apache.felix.*;-split-package:=merge-first,
                            org.eclipse.*;-split-package:=merge-first,
                            org.osgi.*;-split-package:=merge-first,
                            META-INF;-split-package:=merge-first
                        </Private-Package>
                        <Import-Package>!*</Import-Package>
                        -->
                        <Private-Package>
                            org.apache.karaf.main*,
                            org.apache.karaf.util.properties,
                            org.apache.felix.utils.properties,
                            org.osgi.framework*;
                            org.osgi.resource;
                            org.osgi.service.packageadmin;
                            org.osgi.service.startlevel;
                            org.osgi.service.url;
                            org.osgi.util.tracker;-split-package:=merge-first
                        </Private-Package>
                    </instructions>
                    <unpackBundle>true</unpackBundle>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <artifactSet>
                                <includes>
                                    <include>${project.groupId}:${project.artifactId}</include>
                                </includes>
                            </artifactSet>
                            <relocations>
                                <relocation>
                                    <pattern>org.apache.karaf.util.properties</pattern>
                                    <shadedPattern>org.apache.karaf.main.util</shadedPattern>
                                </relocation>
                                <relocation>
                                    <pattern>org.apache.felix.utils.properties</pattern>
                                    <shadedPattern>org.apache.karaf.main.util</shadedPattern>
                                </relocation>
                             </relocations>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>deploy</id>
            <properties>
                <createSourcesJar>true</createSourcesJar>
            </properties>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>unpack-sources</id>
                                <phase>generate-sources</phase>
                                <goals>
                                    <goal>unpack</goal>
                                </goals>
                                <configuration>
                                    <artifactItems>
                                        <artifactItem>
                                            <groupId>org.eclipse</groupId>
                                            <artifactId>osgi</artifactId>
                                            <classifier>sources</classifier>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.osgi</groupId>
                                            <artifactId>org.osgi.core</artifactId>
                                            <classifier>sources</classifier>
                                        </artifactItem>
                                        <artifactItem>
                                            <groupId>org.apache.felix</groupId>
                                            <artifactId>org.apache.felix.framework</artifactId>
                                            <classifier>sources</classifier>
                                        </artifactItem>
                                    </artifactItems>
                                    <outputDirectory>${project.build.directory}/sources</outputDirectory>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>attach-sources</id>
                                <phase>process-classes</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                    </plugin>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                            <execution>
                                <id>package</id>
                                <phase>package</phase>
                                <goals>
                                    <goal>jar</goal>
                                </goals>
                            </execution>
                        </executions>
                        <configuration>
                            <minmemory>128m</minmemory>
                            <maxmemory>512m</maxmemory>
                            <sourcepath>${project.build.directory}/sources</sourcepath>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>

</project>
