<?xml version="1.0" encoding="UTF-8"?>
<!--

    Copyright (c) 1997, 2020 Oracle and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Distribution License v. 1.0, which is available at
    http://www.eclipse.org/org/documents/edl-v10.php.

    SPDX-License-Identifier: BSD-3-Clause

-->

<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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.glassfish.metro</groupId>
        <artifactId>bundles</artifactId>
        <version>2.4.4</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <artifactId>webservices-api-osgi</artifactId>
    <packaging>jar</packaging>
    <name>Metro Web Services API OSGi Bundle</name>
    <description>Metro Web Services API OSGi Bundle</description>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-classes</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <excludeTransitive>true</excludeTransitive>
                            <outputDirectory>${project.build.directory}/classes</outputDirectory>
                            <includes>javax\/jws\/**,javax\/xml\/ws\/**,javax\/xml\/soap\/**</includes>
                        </configuration>
                    </execution>
                    <execution>
                        <id>unpack-sources</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>${project.groupId}</groupId>
                                    <artifactId>webservices-api</artifactId>
                                    <version>${project.version}</version>
                                    <classifier>sources</classifier>
                                    <overWrite>false</overWrite>
                                    <outputDirectory>${generated.sources.dir}</outputDirectory>
                                    <includes>javax\/jws\/**,javax\/xml\/ws\/**,javax\/xml\/soap\/**</includes>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${generated.sources.dir}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-enforcer-plugin</artifactId>
                <executions>
                    <execution>
                        <id>enforce-property</id>
                        <goals>
                            <goal>enforce</goal>
                        </goals>
                        <phase>initialize</phase>
                        <configuration>
                            <rules>
                                <requireProperty>
                                    <property>jaxb-api.osgiVersion</property>
                                    <message>Property jaxb-api.osgiVersion not imported or set!</message>
                                </requireProperty>
                                <requireProperty>
                                    <property>jaxws-api.osgiVersion</property>
                                    <message>Property jaxws-api.osgiVersion not imported or set!</message>
                                </requireProperty>
                                <requireProperty>
                                    <property>saaj-api.osgiVersion</property>
                                    <message>Property saaj-api.osgiVersion not imported or set!</message>
                                </requireProperty>
                            </rules>
                            <fail>true</fail>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>prepare-package</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                        <configuration>
                            <manifestLocation>${manifest.folder}/META-INF</manifestLocation>
                            <instructions>
                                <Export-Package>
                                    javax.jws.*;version=2.0,
                                    javax.xml.ws.*;version=${jaxws-api.osgiVersion},
                                    javax.xml.soap.*;version=${saaj-api.osgiVersion}
                                </Export-Package>
                                <Import-Package>
                                    javax.activation;version=!;resolution:=optional,
                                    javax.xml.bind;version=${jaxb-api.osgiVersion},
                                    javax.xml.bind.*;version=${jaxb-api.osgiVersion},
                                    *
                                </Import-Package>
                                <DynamicImport-Package>org.glassfish.hk2.osgiresourcelocator</DynamicImport-Package>
                            </instructions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-resources-plugin</artifactId>
                <executions>
                    <execution>
                        <id>copy-manifest</id>
                        <goals>
                            <goal>copy-resources</goal>
                        </goals>
                        <phase>prepare-package</phase>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${manifest.folder}</directory>
                                    <filtering>true</filtering>
                                </resource>
                            </resources>
                            <outputDirectory>${mf.dir}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${mf.dir}/META-INF/MANIFEST.MF</manifestFile>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <dependencies>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>webservices-api</artifactId>
            <version>${project.version}</version>
            <optional>true</optional>
        </dependency>
    </dependencies>

    <properties>
        <generated.sources.dir>${project.build.directory}/generated-sources</generated.sources.dir>
        <manifest.folder>${project.build.directory}/generated-manifest</manifest.folder>
    </properties>
</project>
