<?xml version="1.0" encoding="UTF-8"?>
<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.eclipse.jetty.demos</groupId>
    <artifactId>jetty-servlet5-demos</artifactId>
    <version>12.1.0.beta0</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>
  <artifactId>jetty-servlet5-demo-spec-webapp</artifactId>
  <packaging>war</packaging>
  <name>Servlet 5 :: Demo :: Servlet Spec :: WebApp</name>
  <properties>
    <bundle-symbolic-name>${project.groupId}.servlet5.spec.webapp</bundle-symbolic-name>
  </properties>

  <dependencies>
    <dependency>
      <groupId>org.eclipse.jetty.demos</groupId>
      <artifactId>jetty-servlet5-demo-container-initializer</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.demos</groupId>
      <artifactId>jetty-servlet5-demo-web-fragment</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>jakarta.annotation</groupId>
      <artifactId>jakarta.annotation-api</artifactId>
      <version>${ee9.jakarta.annotation.api.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.servlet</groupId>
      <artifactId>jakarta.servlet-api</artifactId>
      <version>${ee9.jakarta.servlet.api.version}</version>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>jakarta.transaction</groupId>
      <artifactId>jakarta.transaction-api</artifactId>
      <version>${ee9.jakarta.transaction-api.version}</version>
      <scope>provided</scope>
    </dependency>
  </dependencies>
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <extensions>true</extensions>
        <configuration>
          <supportedProjectTypes>
            <supportedProjectType>war</supportedProjectType>
          </supportedProjectTypes>
          <instructions>
            <Bundle-Description>Test Webapp for Servlet 5.0 Features</Bundle-Description>
            <Import-Package>jakarta.annotation.*;version="2.0.0", jakarta.transaction*;version="2.0.0", jakarta.servlet*;version="5.0.0", org.eclipse.jetty*;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))", org.eclipse.jetty.webapp;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))";resolution:="optional", org.eclipse.jetty.plus.jndi;version="[$(version;===;${parsedVersion.osgiVersion}),$(version;==+;${parsedVersion.osgiVersion}))";resolution:="optional", org.example;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}", *</Import-Package>
            <_nouses></_nouses>
            <Export-Package>org.example.test;version="${parsedVersion.majorVersion}.${parsedVersion.minorVersion}.${parsedVersion.incrementalVersion}";-noimport:=true</Export-Package>
            <Web-ContextPath>/</Web-ContextPath>
            <Bundle-ClassPath>.,WEB-INF/classes,WEB-INF/lib</Bundle-ClassPath>
          </instructions>
        </configuration>
        <executions>
          <execution>
            <id>ee10</id>
            <goals>
              <goal>manifest</goal>
            </goals>
            <configuration>
              <instructions>
                <Jetty-Environment>ee10</Jetty-Environment>
                <Jetty-ContextFilePath>META-INF/ee10-plugin-context.xml</Jetty-ContextFilePath>
              </instructions>
              <manifestLocation>${project.build.outputDirectory}/META-INF-ee10</manifestLocation>
            </configuration>
          </execution>
          <execution>
            <id>ee11</id>
            <goals>
              <goal>manifest</goal>
            </goals>
            <configuration>
              <instructions>
                <Jetty-Environment>ee11</Jetty-Environment>
                <Jetty-ContextFilePath>META-INF/ee11-plugin-context.xml</Jetty-ContextFilePath>
              </instructions>
              <manifestLocation>${project.build.outputDirectory}/META-INF-ee11</manifestLocation>
            </configuration>
          </execution>
          <execution>
            <id>ee9</id>
            <goals>
              <goal>manifest</goal>
            </goals>
            <configuration>
              <instructions>
                <Jetty-Environment>ee9</Jetty-Environment>
                <Jetty-ContextFilePath>META-INF/ee9-plugin-context.xml</Jetty-ContextFilePath>
              </instructions>
              <manifestLocation>${project.build.outputDirectory}/META-INF-ee9</manifestLocation>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>ee10-web-bundle-assembly</id>
            <goals>
              <goal>single</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <descriptors>
                <descriptor>src/main/assembly/ee10-web-bundle.xml</descriptor>
              </descriptors>
              <archive>
                <manifestFile>${project.build.outputDirectory}/META-INF-ee10/MANIFEST.MF</manifestFile>
              </archive>
            </configuration>
          </execution>
          <execution>
            <id>ee11-web-bundle-assembly</id>
            <goals>
              <goal>single</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <descriptors>
                <descriptor>src/main/assembly/ee11-web-bundle.xml</descriptor>
              </descriptors>
              <archive>
                <manifestFile>${project.build.outputDirectory}/META-INF-ee11/MANIFEST.MF</manifestFile>
              </archive>
            </configuration>
          </execution>
          <execution>
            <id>ee9-web-bundle-assembly</id>
            <goals>
              <goal>single</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <descriptors>
                <descriptor>src/main/assembly/ee9-web-bundle.xml</descriptor>
              </descriptors>
              <archive>
                <manifestFile>${project.build.outputDirectory}/META-INF-ee9/MANIFEST.MF</manifestFile>
              </archive>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>copy</goal>
            </goals>
            <phase>package</phase>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>org.eclipse.jetty.demos</groupId>
                  <artifactId>jetty-servlet5-demo-mock-resources</artifactId>
                  <version>${project.version}</version>
                  <type>jar</type>
                  <includes>**</includes>
                  <overWrite>true</overWrite>
                  <outputDirectory>${project.build.directory}/lib/jndi</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-enforcer-plugin</artifactId>
        <executions>
          <execution>
            <id>enforce-java</id>
            <goals>
              <goal>enforce</goal>
            </goals>
            <configuration>
              <rules>
                <requireUpperBoundDeps>
                  <excludes combine.children="append">
                    <exclude>org.eclipse.jetty:jetty-util</exclude>
                  </excludes>
                </requireUpperBoundDeps>
              </rules>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <!-- also make this webapp an osgi bundle -->
      <plugin>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <archive>
            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
          </archive>
          <webResources>
            <resource>
              <directory>target</directory>
              <includes>
                <include>src/main/templates/plugin-context.xml</include>
              </includes>
              <targetPath>META-INF</targetPath>
            </resource>
          </webResources>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
