<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.garethahealy</groupId>
        <artifactId>plugins-parent</artifactId>
        <version>1.1.0</version>
        <relativePath>../plugins-parent</relativePath>
    </parent>
    <artifactId>osgi-plugins-parent</artifactId>
    <packaging>pom</packaging>
    <name>POMs :: OSGi Plugins Parent</name>

    <properties>
        <!-- Build propertis based on the Apache Camel project -->
        <build.osgi.import.build.version>
            version="[$(version;==;${build.osgi.version.clean}),$(version;=+;${build.osgi.version.clean}))"
        </build.osgi.import.build.version>
        <build.osgi.import.strict.version>
            version="[$(version;===;${build.osgi.version.clean}),$(version;==+;${build.osgi.version.clean}))"
        </build.osgi.import.strict.version>
        <build.osgi.import.default.version>[$(version;==;$(@)),$(version;+;$(@)))</build.osgi.import.default.version>
        <build.osgi.import.defaults/>
        <build.osgi.import.before.defaults/>
        <build.osgi.import.additional/>
        <build.osgi.import.pkg>
            !${build.osgi.export.pkg},
            com.garethahealy.*;${build.osgi.import.build.version},
            ${build.osgi.import.before.defaults},
            ${build.osgi.import.defaults},
            ${build.osgi.import.additional},
            *
        </build.osgi.import.pkg>
        <build.osgi.import.service/>
        <build.osgi.export.service/>
        <build.osgi.export.pkg/>
        <build.osgi.activator/>
        <build.osgi.failok>false</build.osgi.failok>
        <build.osgi.private.pkg>!*</build.osgi.private.pkg>
        <build.osgi.export>${build.osgi.export.pkg};${build.osgi.version}</build.osgi.export>
        <build.osgi.meta.persistence/>
        <build.osgi.version>version=${project.version}</build.osgi.version>
        <build.osgi.split.pkg>-split-package:=first</build.osgi.split.pkg>
        <build.osgi.import>${build.osgi.import.pkg}</build.osgi.import>
        <build.osgi.dynamic/>
        <build.osgi.embed/>
        <build.osgi.exclude.dependencies/>
        <build.osgi.symbolic.name>${project.groupId}.${project.artifactId}</build.osgi.symbolic.name>
        <build.osgi.implementation.title>${project.groupId}</build.osgi.implementation.title>
    </properties>

    <!-- Build plugins -->
    <build>
        <pluginManagement>
            <plugins>
                <plugin>
                    <!-- https://github.com/apache/servicemix-maven-plugins/tree/trunk/depends-maven-plugin -->
                    <groupId>org.apache.servicemix.tooling</groupId>
                    <artifactId>depends-maven-plugin</artifactId>
                    <version>${depends-maven-plugin-version}</version>
                </plugin>
                <plugin>
                    <!-- http://felix.apache.org/site/apache-felix-maven-bundle-plugin-bnd.html -->
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-bundle-plugin</artifactId>
                    <version>${maven-bundle-plugin-version}</version>
                </plugin>
                <plugin>
                    <!-- http://felix.apache.org/documentation/subprojects/apache-felix-maven-scr-plugin.html -->
                    <groupId>org.apache.felix</groupId>
                    <artifactId>maven-scr-plugin</artifactId>
                    <version>${felix-scr-plugin.version}</version>
                </plugin>
                <plugin>
                    <!-- https://www.eclipse.org/m2e/documentation/m2e-execution-not-covered.html -->
                    <groupId>org.eclipse.m2e</groupId>
                    <artifactId>lifecycle-mapping</artifactId>
                    <version>1.0.0</version>
                    <configuration>
                        <lifecycleMappingMetadata>
                            <pluginExecutions>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.felix</groupId>
                                        <artifactId>maven-bundle-plugin</artifactId>
                                        <versionRange>[${maven-bundle-plugin-version},)</versionRange>
                                        <goals>
                                            <goal>cleanVersions</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore/>
                                    </action>
                                </pluginExecution>
                                <pluginExecution>
                                    <pluginExecutionFilter>
                                        <groupId>org.apache.servicemix.tooling</groupId>
                                        <artifactId>depends-maven-plugin</artifactId>
                                        <versionRange>[${depends-maven-plugin-version},)</versionRange>
                                        <goals>
                                            <goal>generate-depends-file</goal>
                                        </goals>
                                    </pluginExecutionFilter>
                                    <action>
                                        <ignore/>
                                    </action>
                                </pluginExecution>
                            </pluginExecutions>
                        </lifecycleMappingMetadata>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>

        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-source-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestEntries>
                            <Bundle-SymbolicName>${project.groupId}.${project.artifactId}.source</Bundle-SymbolicName>
                            <Bundle-Version>${build.osgi.version.clean}</Bundle-Version>
                            <Eclipse-SourceBundle>
                                ${project.groupId}.${project.artifactId};version="${build.osgi.version.clean}"
                            </Eclipse-SourceBundle>
                        </manifestEntries>
                    </archive>
                </configuration>
                <executions>
                    <execution>
                        <id>attach-sources</id>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.servicemix.tooling</groupId>
                <artifactId>depends-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>generate-depends-file</id>
                        <goals>
                            <goal>generate-depends-file</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <inherited>true</inherited>
                <configuration>
                    <excludeDependencies>${build.osgi.exclude.dependencies}</excludeDependencies>
                    <instructions>
                        <Bundle-Name>${project.name}</Bundle-Name>
                        <Bundle-SymbolicName>${build.osgi.symbolic.name}</Bundle-SymbolicName>
                        <Bundle-Activator>${build.osgi.activator}</Bundle-Activator>
                        <Export-Package>${build.osgi.export}</Export-Package>
                        <Import-Package>${build.osgi.import}</Import-Package>
                        <Private-Package>${build.osgi.private.pkg}</Private-Package>
                        <Import-Service>${build.osgi.import.service}</Import-Service>
                        <Export-Service>${build.osgi.export.service}</Export-Service>
                        <Meta-Persistence>${build.osgi.meta.persistence}</Meta-Persistence>
                        <Implementation-Title>${build.osgi.implementation.title}</Implementation-Title>
                        <Implementation-Version>${project.version}</Implementation-Version>
                        <Karaf-Info>${build.osgi.symbolic.name}=${build.osgi.version.clean}</Karaf-Info>
                        <_versionpolicy>${build.osgi.import.default.version}</_versionpolicy>
                        <_failok>${build.osgi.failok}</_failok>
                        <Embed-Dependency>${build.osgi.embed}</Embed-Dependency>
                    </instructions>
                </configuration>
                <executions>
                    <execution>
                        <id>versions</id>
                        <phase>validate</phase>
                        <goals>
                            <goal>cleanVersions</goal>
                        </goals>
                        <configuration>
                            <versions>
                                <build.osgi.version.clean>${project.version}</build.osgi.version.clean>
                            </versions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>
