<?xml version="1.0" encoding="UTF-8"?>
<!--
    Copyright (c) 2022 Eclipse Foundation and/or its affiliates. All rights reserved.

    This program and the accompanying materials are made available under the
    terms of the Eclipse Public License v. 2.0, which is available at
    http://www.eclipse.org/legal/epl-2.0.

    This Source Code may also be made available under the following Secondary
    Licenses when the conditions for such availability set forth in the
    Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
    version 2 with the GNU Classpath Exception, which is available at
    https://www.gnu.org/software/classpath/license.html.

    SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.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.glassfish.main</groupId>
        <artifactId>glassfish-nucleus-parent</artifactId>
        <version>8.0.0-JDK17-M5</version>
    </parent>

    <groupId>org.glassfish.main.jackson.module</groupId>
    <artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
    <packaging>jar</packaging>

    <name>Jackson Module Jakarta Xmlbind Annotations</name>
    <description>Jackson Module Jakarta Xmlbind Annotations repackaged as OSGi bundle for GlassFish</description>

    <dependencies>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.activation</groupId>
            <artifactId>jakarta.activation-api</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- Generate bundle jar -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <configuration>
                    <supportedProjectTypes>
                        <supportedProjectType>jar</supportedProjectType>
                    </supportedProjectTypes>
                    <instructions>
                        <Embed-Dependency>artifactId=jackson-module-jakarta-xmlbind-annotations;inline=true;</Embed-Dependency>
                        <Import-Package>
                            com.fasterxml.jackson.annotation,
                            com.fasterxml.jackson.core.*,
                            com.fasterxml.jackson.databind.*,
                            jakarta.xml.bind,
                            jakarta.xml.bind.annotation,
                            jakarta.xml.bind.annotation.adapters,
                            javax.xml.parsers,
                            org.w3c.dom
                        </Import-Package>
                        <Export-Package>com.fasterxml.jackson.module.jakarta.xmlbind.*</Export-Package>
                    </instructions>
                    <unpackBundle>true</unpackBundle>
                </configuration>
                <executions>
                    <execution>
                        <id>osgi-bundle</id>
                        <phase>package</phase>
                        <goals>
                            <goal>bundle</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            
            <!-- Get sources for jar we repacaged -->
            <plugin>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-sources</id>
                        <goals>
                            <goal>unpack</goal>
                        </goals>
                        <configuration>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>com.fasterxml.jackson.module</groupId>
                                    <artifactId>jackson-module-jakarta-xmlbind-annotations</artifactId>
                                    <version>${jackson.version}</version>
                                    <classifier>sources</classifier>
                                    <outputDirectory>${project.build.directory}/sources</outputDirectory>
                                </artifactItem>
                            </artifactItems>
                            <excludes>com/fasterxml/jackson/module/jakarta/xmlbind/package-info.java</excludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
            <!-- Generate source jar from unpacked sources -->
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <executions>
                    <execution>
                        <id>source-assembly</id>
                        <phase>package</phase>
                        <goals>
                            <goal>single</goal>
                        </goals>
                        <configuration>
                            <descriptors>
                                <descriptor>src.xml</descriptor>
                            </descriptors>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            
            <!-- Generate javadoc jar from unpacked sources -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-javadoc-plugin</artifactId>
                <executions>
                    <execution>
                        <id>javadoc</id>
                        <phase>package</phase>
                        <goals>
                            <goal>jar</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <sourcepath>${project.build.directory}/sources</sourcepath>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>