<?xml version="1.0"?>
<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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.diirt</groupId>
        <artifactId>pvmanager-all</artifactId>
        <version>3.1.7</version>
    </parent>
    <artifactId>service-jdbc</artifactId>
    <name>org.diirt.service.jdbc</name>
    <description>Support for database based services.</description>
    <dependencies>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.25</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>vtype</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>service</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.postgresql</groupId>
            <artifactId>postgresql</artifactId>
            <version>42.1.4</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <profiles>
        <!-- This profile adds postgres JDBC drivers, to the org.diirt.service.jdbc.JDBCServiceProvider
             Apache Aries SPIfly http://aries.apache.org/modules/spi-fly.html is used to register SPI service to the OSGI service registry
             This way class loading problems of the JDBC drivers are fixed. 
             https://github.com/ControlSystemStudio/cs-studio/wiki/OSGi-and-ServiceLoaders
             Apache Aries SPIFly bundles must be added to the product, to satisfy dependencies 
        -->
        <profile>
            <id>postgres</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.felix</groupId>
                        <artifactId>maven-bundle-plugin</artifactId>
                        <extensions>true</extensions>
                        <configuration>
                            <instructions>
                                <Require-Bundle>org.postgresql.jdbc42</Require-Bundle>
                                <Require-Capability>osgi.extender;filter:="(osgi.extender=osgi.serviceloader.registrar)"</Require-Capability>
                                <Provide-Capability>osgi.serviceloader;osgi.serviceloader=org.diirt.service.jdbc.JDBCServiceProvider</Provide-Capability>
                            </instructions>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
    <build>
        <plugins>
            <plugin>
                <groupId>eu.somatik.serviceloader-maven-plugin</groupId>
                <artifactId>serviceloader-maven-plugin</artifactId>
                <version>${serviceloader.maven.plugin.version}</version>
                <configuration>
                    <services>
                        <param>org.diirt.service.ServiceProvider</param>
                    </services>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>
