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

    Copyright (c) 2013, 2023 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>com.sun.xml.bind.mvn</groupId>
        <artifactId>jaxb-osgi</artifactId>
        <version>4.0.5</version>
        <relativePath>../pom.xml</relativePath>
    </parent>

    <groupId>com.sun.xml.bind</groupId>
    <artifactId>jaxb-osgi</artifactId>

    <packaging>jar</packaging>
    <name>JAXB OSGI</name>
    <description>JAXB OSGI bundle</description>
    <url>https://eclipse-ee4j.github.io/jaxb-ri/</url>

    <dependencies>
        <dependency>
            <groupId>jakarta.xml.bind</groupId>
            <artifactId>jakarta.xml.bind-api</artifactId>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-runtime</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>txw2</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.istack</groupId>
            <artifactId>istack-commons-runtime</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.fastinfoset</groupId>
            <artifactId>FastInfoset</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.jvnet.staxex</groupId>
            <artifactId>stax-ex</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-xjc</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>codemodel</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>xsom</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.istack</groupId>
            <artifactId>istack-commons-tools</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind.external</groupId>
            <artifactId>relaxng-datatype</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.bind.external</groupId>
            <artifactId>rngom</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.dtd-parser</groupId>
            <artifactId>dtd-parser</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.glassfish.jaxb</groupId>
            <artifactId>jaxb-jxc</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>com.github.relaxng</groupId>
            <artifactId>relaxngDatatype</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <!-- CQ #20807 -->
        <dependency>
            <groupId>org.checkerframework</groupId>
            <artifactId>compiler</artifactId>
            <scope>provided</scope>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <properties>
        <dep.sources>${project.build.directory}/generated-sources/dependencies</dep.sources>
    </properties>

    <build>
        <plugins>
            <plugin> <!-- want to unpack sources from individual modules -->
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>unpack-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>unpack-dependencies</goal>
                        </goals>
                        <configuration>
                            <includeGroupIds>org.glassfish.jaxb,com.sun.istack,com.sun.xml.bind.external,com.sun.xml.dtd-parser,com.sun.xml.fastinfoset,org.jvnet.staxex</includeGroupIds>
                            <includeScope>provided</includeScope>
                            <classifier>sources</classifier>
                            <excludeTransitive>true</excludeTransitive>
                            <excludes>module-info.*,META-INF/versions/**,META-INF/MANIFEST.MF</excludes>
                            <outputDirectory>${dep.sources}</outputDirectory>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>build-helper-maven-plugin</artifactId>
                <executions>
                    <execution>
                        <id>add-resource</id>
                        <phase>generate-resources</phase>
                        <goals>
                            <goal>add-resource</goal>
                        </goals>
                        <configuration>
                            <resources>
                                <resource>
                                    <directory>${dep.sources}</directory>
                                    <excludes>
                                        <exclude>**/*.java</exclude>
                                        <exclude>com/sun/tools/jxc/MessageBundle*.properties</exclude>
                                        <exclude>com/sun/tools/xjc/MessageBundle*.properties</exclude>
                                    </excludes>
                                </resource>
                                <resource>
                                    <directory>${dep.sources}</directory>
                                    <includes>
                                        <include>com/sun/tools/jxc/MessageBundle*.properties</include>
                                        <include>com/sun/tools/xjc/MessageBundle*.properties</include>
                                    </includes>
                                    <filtering>true</filtering>
                                </resource>
                                <resource>
                                    <directory>${dep.sources}/com/sun/tools/xjc/runtime</directory>
                                    <targetPath>com/sun/tools/xjc/runtime</targetPath>
                                    <includes>
                                        <include>*.java</include>
                                    </includes>
                                    <excludes>
                                        <exclude>package-info.java</exclude>
                                    </excludes>
                                </resource>
                            </resources>
                        </configuration>
                    </execution>
                    <execution>
                        <id>add-sources</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>add-source</goal>
                        </goals>
                        <configuration>
                            <sources>
                                <source>${dep.sources}</source>
                            </sources>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-compile</id>
                        <configuration>
                            <compilerArgs>
                                <arg>--add-reads</arg>
                                <arg>com.sun.xml.bind.osgi=ALL-UNNAMED</arg>
                            </compilerArgs>
                        </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>
                            <!-- javax.xml.bind.annotation - used by XJC -target < 3.0-->
                            <instructions>
                                <Export-Package>
                                    com.sun.codemodel;version=${jaxb.osgiVersion},
                                    com.sun.codemodel.*;version=${jaxb.osgiVersion},
                                    com.sun.istack;version=${istack.version},
                                    com.sun.istack.*;version=${istack.version},
                                    com.sun.tools.*;version=${jaxb.osgiVersion},
                                    com.sun.xml.dtdparser;version=${dtd-parser.version},
                                    com.sun.xml.dtdparser.*;version=${dtd-parser.version},
                                    com.sun.xml.fastinfoset;version=${fastinfoset.version},
                                    com.sun.xml.fastinfoset.*;version=${fastinfoset.version},
                                    com.sun.xml.txw2;version=${jaxb.osgiVersion},
                                    com.sun.xml.txw2.*;version=${jaxb.osgiVersion},
                                    com.sun.xml.xsom;version=${jaxb.osgiVersion},
                                    com.sun.xml.xsom.*;version=${jaxb.osgiVersion},
                                    org.glassfish.jaxb.core;version=${jaxb.osgiVersion},
                                    org.glassfish.jaxb.core.*;version=${jaxb.osgiVersion},
                                    org.glassfish.jaxb.runtime;version=${jaxb.osgiVersion},
                                    org.glassfish.jaxb.runtime.*;version=${jaxb.osgiVersion},
                                    org.jvnet.fastinfoset;version=${fastinfoset.version},
                                    org.jvnet.fastinfoset.*;version=${fastinfoset.version},
                                    org.jvnet.staxex;version=${stax-ex.version},
                                    org.jvnet.staxex.util;version=${stax-ex.version},
                                    com.sun.tools.rngom.*;version=${jaxb.osgiVersion},
                                </Export-Package>
                                <Bundle-ActivationPolicy>lazy</Bundle-ActivationPolicy>
                                <Import-Package>
                                    jakarta.xml.bind;version=${xml.bind-api.version},
                                    jakarta.xml.bind.annotation;version=${xml.bind-api.version},
                                    jakarta.xml.bind.annotation.adapters;version=${xml.bind-api.version},
                                    jakarta.xml.bind.attachment;version=${xml.bind-api.version},
                                    jakarta.xml.bind.helpers;version=${xml.bind-api.version},
                                    javax.xml.bind.annotation;resolution:=optional,
                                    com.sun.source.tree;resolution:=optional,
                                    com.sun.source.util;resolution:=optional,
                                    org.apache.tools.ant;resolution:=optional,
                                    org.apache.tools.ant.taskdefs;resolution:=optional,
                                    org.apache.tools.ant.taskdefs.compilers;resolution:=optional,
                                    org.apache.tools.ant.types;resolution:=optional,
                                    sun.misc;resolution:=optional,
                                    jdk.internal.misc;resolution:=optional,
                                    *
                                </Import-Package>
                                <DynamicImport-Package>*</DynamicImport-Package>
                                <Require-Capability><![CDATA[
                            osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.processor)
                              (version>=1.0.0)(!(version>=2.0.0)))";resolution:=optional,
                            osgi.serviceloader;
                              filter:="(osgi.serviceloader=com.sun.tools.xjc.Plugin)";
                                osgi.serviceloader="com.sun.tools.xjc.Plugin";
                                cardinality:=multiple;resolution:=optional,
                            osgi.serviceloader;
                              filter:="(osgi.serviceloader=com.sun.tools.rngdatatype.DatatypeLibraryFactory)";
                                osgi.serviceloader="com.sun.tools.rngdatatype.DatatypeLibraryFactory";
                                cardinality:=multiple;resolution:=optional,
                            osgi.extender;filter:="(&(osgi.extender=osgi.serviceloader.registrar)
                              (version>=1.0.0)(!(version>=2.0.0)))";resolution:=optional
                            ]]>
                                </Require-Capability>
                                <Provide-Capability><![CDATA[
                            osgi.serviceloader;
                              osgi.serviceloader="jakarta.xml.bind.JAXBContextFactory",
                            osgi.serviceloader;
                              osgi.serviceloader="com.sun.tools.xjc.Plugin",
                            osgi.serviceloader;
                              osgi.serviceloader="com.sun.tools.rngdatatype.DatatypeLibraryFactory"
                            ]]>
                                </Provide-Capability>
                            </instructions>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
                        <manifestEntries>
                            <Class-Path>jakarta.xml.bind-api.jar</Class-Path>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <executions>
                    <execution>
                        <id>default-test</id>
                        <phase>integration-test</phase>
                        <configuration>
                            <systemPropertyVariables>
                                <jaxb.spec.version>${xml.bind-api.version}</jaxb.spec.version>
                                <osgi.dist>${project.build.directory}/${project.build.finalName}</osgi.dist>
                            </systemPropertyVariables>
                            <classpathDependencyExcludes>
                                <classpathDependencyExclude>com.sun.istack:*</classpathDependencyExclude>
                                <classpathDependencyExclude>com.sun.xml.bind.external:*</classpathDependencyExclude>
                                <classpathDependencyExclude>com.sun.xml.dtd-parser:*</classpathDependencyExclude>
                                <classpathDependencyExclude>com.sun.xml.fastinfoset:*</classpathDependencyExclude>
                                <classpathDependencyExclude>org.glassfish.jaxb:*</classpathDependencyExclude>
                                <classpathDependencyExclude>org.jvnet.staxex:*</classpathDependencyExclude>
                            </classpathDependencyExcludes>
                        </configuration>
                    </execution>
                </executions>
            </plugin>

            <plugin>
                <artifactId>maven-javadoc-plugin</artifactId>
                <configuration>
                    <sourceFileExcludes>
                        <sourceFileExclude>META-INF/versions/**</sourceFileExclude>
                    </sourceFileExcludes>
                    <includeDependencySources>false</includeDependencySources>
                    <additionalJOptions>
                        <additionalJOption>--add-reads</additionalJOption>
                        <additionalJOption>com.sun.xml.bind.osgi=ALL-UNNAMED</additionalJOption>
                    </additionalJOptions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>com.github.spotbugs</groupId>
                <artifactId>spotbugs-maven-plugin</artifactId>
                <configuration>
                    <!-- Use all excludes used for rebundled artifacts -->
                    <excludeFilterFile>
                        exclude-common.xml,
                        ${project.basedir}/exclude.xml,
                        ${project.basedir}/../../../runtime/impl/exclude-runtime.xml,
                        ${project.basedir}/../../../jxc/exclude-jxc.xml
                    </excludeFilterFile>
                </configuration>
            </plugin>

            <!--    Can be used to build everything from sources
                  <plugin>
                      <groupId>org.glassfish.build</groupId>
                      <artifactId>glassfishbuild-maven-plugin</artifactId>
                      <executions>
                          <execution>
                              <id>unpack-sources</id>
                              <phase>process-resources</phase>
                              <goals>
                                  <goal>unpack-sources</goal>
                              </goals>
                              <configuration>
                                  <attachSources>true</attachSources>
                                  <excludes>*.java</excludes>
                                  <excludeTransitive>true</excludeTransitive>
                              </configuration>
                          </execution>
                      </executions>
                  </plugin>
            -->

        </plugins>
    </build>
</project>
