<?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>4.3.7</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>org.apache.karaf.instance</groupId>
    <artifactId>org.apache.karaf.instance.core</artifactId>
    <packaging>bundle</packaging>
    <name>Apache Karaf :: Instance :: Core</name>
    <description>Core implementation of the instance feature to manipulate Karaf child instances.</description>

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

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.apache.karaf</groupId>
                <artifactId>karaf-bom</artifactId>
                <version>${project.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <dependencies>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.core</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.osgi</groupId>
            <artifactId>osgi.cmpn</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.utils</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.karaf.shell</groupId>
            <artifactId>org.apache.karaf.shell.core</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.apache.karaf</groupId>
            <artifactId>org.apache.karaf.util</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>org.apache.karaf.features.command</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.apache.karaf.profile</groupId>
            <artifactId>org.apache.karaf.profile.core</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-jdk14</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <resources>
            <resource>
                <directory>${project.basedir}/src/main/resources</directory>
                <includes>
                    <include>**/*</include>
                </includes>
            </resource>
            <resource>
                <directory>${project.build.directory}/generated-resources</directory>
                <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.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>regex-property</id>
                        <goals>
                            <goal>regex-property</goal>
                        </goals>
                        <configuration>
                            <name>karaf.osgi.version</name>
                            <value>${project.version}</value>
                            <regex>\.*</regex>
                            <replacement />
                            <failIfNoMatch>false</failIfNoMatch>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-resources</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/generated-resources/org/apache/karaf/instance</outputDirectory>
                            <addDefaultExcludes>false</addDefaultExcludes>
                            <useDefaultDelimiters>false</useDefaultDelimiters>
                            <delimiters>
                              <delimiter>@@</delimiter>
                            </delimiters>
                            <resources>
                                <resource>
                                    <directory>${project.basedir}/../assemblies/features/base/src/main/resources</directory>
                                    <excludes>
                                        <exclude>**/etc/system.properties</exclude>
                                    </excludes>
                                </resource>
                                <resource>
                                    <directory>${project.basedir}/../assemblies/features/base/src/main/filtered-resources</directory>
                                    <filtering>true</filtering>
                                    <excludes>
                                        <exclude>**/etc/config.properties</exclude>
                                        <exclude>**/bin/karaf</exclude>
                                        <exclude>**/bin/karaf.bat</exclude>
                                        <exclude>**/bin/start</exclude>
                                        <exclude>**/bin/start.bat</exclude>
                                        <exclude>**/bin/stop</exclude>
                                        <exclude>**/bin/stop.bat</exclude>
                                    </excludes>
                                </resource>
                                <resource>
                                    <directory>${project.basedir}/src/main/resources/org/apache/karaf/instance</directory>
                                    <includes>
                                        <include>**/*</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-services-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <instructions>
                        <Export-Package>
                            org.apache.karaf.instance.core
                        </Export-Package>
                        <!-- We have to avoid importing instance.core.internal and jansi
                             as Execute.java accesses the InstanceServiceImpl and jansi
                             (but only outside OSGi) -->
                        <Import-Package>
                            !org.apache.karaf.shell.impl.action.command,
                            !org.apache.karaf.instance.core.internal,
                            org.osgi.framework;version="[1,3)",
                            *
                        </Import-Package>
                        <Private-Package>
                            org.apache.karaf.jpm,
                            org.apache.karaf.jpm.impl,
                            org.apache.karaf.jpm.impl.unix,
                            org.apache.karaf.jpm.impl.windows,
                            org.apache.karaf.instance.main,
                            org.apache.karaf.instance.command,
                            org.apache.karaf.instance.command.completers,
                            org.apache.karaf.instance.core.internal,
                            org.apache.karaf.instance.core.internal.osgi,
                            org.apache.felix.utils.properties;-split-package:=merge-first,
                            org.apache.karaf.util,
                            org.apache.karaf.util.config,
                            org.apache.karaf.util.locks,
                        </Private-Package>
                    </instructions>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                  <excludes>
                    <!-- this is not a unit test but an application used for testing -->
                    <exclude>**/MainTest.java</exclude>
                  </excludes>
                </configuration>
           </plugin>
        </plugins>
    </build>
</project>
