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

    Copyright (c) 2010, 2026 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/xsd/maven-4.0.0.xsd">

    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.glassfish.jersey.examples</groupId>
        <artifactId>osgi-helloworld-webapp</artifactId>
        <version>3.1.12</version>
    </parent>

    <groupId>org.glassfish.jersey.examples.osgi-helloworld-webapp</groupId>
    <artifactId>war-bundle</artifactId>
    <name>jersey-examples-osgi-helloworld-webapp-wab</name>
    <packaging>war</packaging>

    <description>OSGi Helloworld Webapp WAR bundle</description>

    <dependencies>
        <dependency>
            <groupId>org.glassfish.jersey.containers</groupId>
            <artifactId>jersey-container-servlet-core</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.examples.osgi-helloworld-webapp</groupId>
            <artifactId>lib-bundle</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.examples.osgi-helloworld-webapp</groupId>
            <artifactId>additional-bundle</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>org.glassfish.jersey.examples.osgi-helloworld-webapp</groupId>
            <artifactId>alternate-version-bundle</artifactId>
            <version>${project.version}</version>
        </dependency>
        <dependency>
            <groupId>jakarta.ws.rs</groupId>
            <artifactId>jakarta.ws.rs-api</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>jakarta.servlet</groupId>
            <artifactId>jakarta.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.eventadmin</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.felix</groupId>
            <artifactId>org.apache.felix.framework</artifactId>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <!-- to generate the MANIFEST-FILE required by the bundle -->
            <plugin>
                <groupId>org.apache.felix</groupId>
                <artifactId>maven-bundle-plugin</artifactId>
                <extensions>true</extensions>
                <executions>
                    <execution>
                        <id>bundle-manifest</id>
                        <phase>process-classes</phase>
                        <goals>
                            <goal>manifest</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <manifestLocation>${project.build.directory}/META-INF</manifestLocation>
                    <supportedProjectTypes>
                        <supportedProjectType>bundle</supportedProjectType>
                        <supportedProjectType>war</supportedProjectType>
                    </supportedProjectTypes>
                    <instructions>
                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
                        <Bundle-ClassPath>.,WEB-INF/classes</Bundle-ClassPath>
                        <Import-Package>
                            org.glassfish.jersey.servlet,
                            <!--
                                This package is exported by two different bundle versions of 'additional-bundle'
                                - one is in the maven module 'additional-bundle' with the current ${project.version},
                                - the other one is in the maven module 'alternate-version-bundle' with Bundle-Version 2.2.1
                                (the names of maven artifacts have to be unique, but the name of bundles
                                (defined in the maven-bundle-plugin configuration) is the same for both.

                                Both bundles (additional-bundle 2.2.1 and additional-bundle ${project.version} are loaded into
                                OSGi runtime, so that there are two versions of the same resource available, each one returning
                                different string as a response. If the import version is changed to [2.2,2.3) as prepared below,
                                the test will fail (the response returned from the alternate version of the bundle is different).
                                NOTE - to test this, the version has to be restricted from above, otherwise OSGi can choose any of
                                the two bundles, as version="2.2" actually means "version 2.2. or higher".
                            -->
                            <!-- TODO: newer bundle plugin (3.2.0) generates version string from SNAPSHOTS differently than 2.x version -->
                            org.glassfish.jersey.examples.osgi.helloworld.additional.resource,
                            <!-- org.glassfish.jersey.examples.osgi.helloworld.additional.resource;version="${project.version}",-->
                            <!-- org.glassfish.jersey.examples.osgi.helloworld.additional.resource;version="[2.2,2.3)", -->
                            *
                        </Import-Package>
                        <Export-Package>
                            org.glassfish.jersey.examples.osgi.helloworld,
                            org.glassfish.jersey.examples.osgi.helloworld.resource,
                            org.glassfish.jersey.examples.osgi.helloworld.additional.resource
                        </Export-Package>
                        <Embed-Directory>WEB-INF/lib</Embed-Directory>
                        <Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
                        <Embed-Transitive>true</Embed-Transitive>
                        <Webapp-Context>helloworld</Webapp-Context>
                        <Web-ContextPath>helloworld</Web-ContextPath>
                        <Bundle-Activator>org.glassfish.jersey.examples.osgi.helloworld.WebAppContextListener</Bundle-Activator>
                        <_wab>src/main/webapp</_wab>
                    </instructions>
                </configuration>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <attachClasses>true</attachClasses>
                    <archive>
                        <manifestFile>${project.build.directory}/META-INF/MANIFEST.MF</manifestFile>
                        <manifestEntries>
                            <Bundle-ClassPath>WEB-INF/classes</Bundle-ClassPath>
                        </manifestEntries>
                    </archive>
                </configuration>
            </plugin>
        </plugins>
    </build>

    <profiles>
        <profile>
            <id>release</id>
            <!-- do not create source zip bundles -->
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <configuration>
                            <skipAssembly>true</skipAssembly>
                        </configuration>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <profile>
          <id>moxy</id>
          <activation>
                <property>
                    <name>moxy</name>
                </property>
          </activation>
          <dependencies>
                <dependency>
                    <groupId>org.eclipse.persistence</groupId>
                    <artifactId>org.eclipse.persistence.moxy</artifactId>
                    <version>${moxy.version}</version>
                    <scope>provided</scope>
                </dependency>
            </dependencies>
         </profile>
    </profiles>

</project>
