<?xml version="1.0" encoding="UTF-8"?>
<!--
  #%L
  com.mobi.distribution
  $Id:$
  $HeadURL:$
  %%
  Copyright (C) 2016 - 2026 iNovex Information Systems, Inc.
  %%
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Affero General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
  
  You should have received a copy of the GNU Affero General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  #L%
  -->

<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.mobi</groupId>
        <artifactId>mobi-parent</artifactId>
        <version>4.3.2</version>
        <relativePath>../mobi-parent/pom.xml</relativePath>
    </parent>
    <modelVersion>4.0.0</modelVersion>

    <artifactId>mobi-distribution</artifactId>

    <name>${project.groupId}.${project.artifactId}</name>

    <packaging>karaf-assembly</packaging>

    <dependencies>
        <dependency>
            <!-- scope is compile so all features are installed into startup.properties and the feature repo itself is not added in etc/org.apache.karaf.features.cfg file -->
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>framework</artifactId>
            <version>${karaf.version}</version>
            <type>kar</type>
        </dependency>
        <dependency>
            <!-- scope is runtime so the feature repo is listed in etc/org.apache.karaf.features.cfg file, and features will installed into the system directory if specify in the plugin configuration -->
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>standard</artifactId>
            <classifier>features</classifier>
            <version>${karaf.version}</version>
            <type>xml</type>
        </dependency>
        <dependency>
            <!-- scope is runtime so the feature repo is listed in etc/org.apache.karaf.features.cfg file, and features will installed into the system directory if specify in the plugin configuration -->
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>enterprise</artifactId>
            <classifier>features</classifier>
            <version>${karaf.version}</version>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <!-- scope is runtime so the feature repo is listed in etc/org.apache.karaf.features.cfg file, and features will installed into the system directory if specify in the plugin configuration -->
            <groupId>org.apache.karaf.features</groupId>
            <artifactId>spring</artifactId>
            <classifier>features</classifier>
            <version>${karaf.version}</version>
            <type>xml</type>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.mobi</groupId>
            <artifactId>mobi-karaf-feature</artifactId>
            <version>${project.version}</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>com.mobi</groupId>
            <artifactId>jaas.proxy</artifactId>
            <version>${project.version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.servicemix.specs</groupId>
            <artifactId>org.apache.servicemix.specs.activation-api-1.2.1</artifactId>
            <version>1.2.1_4-MOBI</version>
        </dependency>
    </dependencies>

    <build>
        <!-- if you want to include resources in the distribution -->
        <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>
        </resources>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
            </plugin>
            <!-- if you want to include resources in the distribution -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <version>2.6</version>
                <executions>
                    <execution>
                        <id>process-resources</id>
                        <goals>
                            <goal>resources</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <!-- Remove old activation-api with bug for java 11-->
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-clean-plugin</artifactId>
                <version>3.2.0</version>
                <executions>
                    <execution>
                        <id>remove-activation-api</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>clean</goal>
                        </goals>
                        <configuration>
                            <excludeDefaultDirectories>true</excludeDefaultDirectories>
                            <filesets>
                                <filesets>
                                    <directory>target/assembly/lib/jdk9plus</directory>
                                    <includes>
                                        <include>org.apache.servicemix.specs.activation-api-1.2.1-1.2.1_3.jar</include>
                                    </includes>
                                </filesets>
                            </filesets>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.mobi</groupId>
                                    <artifactId>jaas.proxy</artifactId>
                                    <outputDirectory>target/classes/lib/boot</outputDirectory>
                                </artifactItem>
                                <artifactItem>
                                    <!-- Add updated activation-api with bug fix for java 11-->
                                    <groupId>org.apache.servicemix.specs</groupId>
                                    <artifactId>org.apache.servicemix.specs.activation-api-1.2.1</artifactId>
                                    <outputDirectory>target/classes/lib/jdk9plus</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.karaf.tooling</groupId>
                <artifactId>karaf-maven-plugin</artifactId>
                <extensions>true</extensions>
                <configuration>
                    <bootRepositories>
                        <bootRepository>mvn:org.apache.karaf.features/spring/${karaf.version}/xml/features</bootRepository>
                        <bootRepository>mvn:org.apache.karaf.features/standard/${karaf.version}/xml/features</bootRepository>
                        <bootRepository>mvn:org.apache.karaf.features/enterprise/${karaf.version}/xml/features</bootRepository>
                        <bootRepository>mvn:org.apache.karaf.features/framework/${karaf.version}/xml/features</bootRepository>
                        <bootRepository>mvn:org.apache.karaf.features/specs/${karaf.version}/xml/features</bootRepository>
                        <bootRepository>mvn:com.mobi/mobi-karaf-feature/${project.version}/xml/features</bootRepository>
                    </bootRepositories>
                    <startupBundles>
                        <bundle>mvn:org.apache.felix/org.apache.felix.metatype/1.2.4</bundle>
                        <bundle>mvn:org.apache.karaf.services/org.apache.karaf.services.eventadmin/${karaf.version}</bundle>
                    </startupBundles>
                    <bootFeatures>
                        <feature>standard</feature>
                        <feature>scr</feature>
                        <feature>http</feature>
                        <feature>http-whiteboard</feature>
                        <feature>pax-web-karaf</feature>
                        <feature>spifly</feature>
                        <feature>scheduler</feature>
                        <feature>aries-blueprint</feature>
                        <feature>mobi-community</feature>
                    </bootFeatures>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-install-plugin</artifactId>
                <version>2.5.2</version>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release-build</id>
            <properties>
                <deploy.bundles.version>,${project.version}</deploy.bundles.version>
            </properties>
        </profile>
    </profiles>
</project>
