<?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>io.hawt</groupId>
    <artifactId>project</artifactId>
    <version>4.0.0</version>
    <relativePath>../../pom.xml</relativePath>
  </parent>

  <artifactId>hawtio-example-war-plugin</artifactId>
  <name>${project.artifactId}</name>
  <description>Hawtio :: Simple WAR plugin example</description>
  <packaging>war</packaging>

  <dependencies>
    <!--
      We only need to embed this dependency in the war. This contains
      a nice helper class that our plugin can use to export its plugin
      mbean.
    -->
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-plugin-mbean</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!--
      Hawtio example plugin project
      Since static resources are packaged under META-INF/resources in the JAR,
      it's enough to add this dependency to the project to load the plugin resources.
    -->
    <dependency>
      <groupId>io.hawt.examples</groupId>
      <artifactId>hawtio-example-sample-plugin</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- hawtio-war-minimal is needed to ensure build order for the example -->
    <dependency>
      <groupId>io.hawt</groupId>
      <artifactId>hawtio-war-minimal</artifactId>
      <version>${project.version}</version>
      <scope>provided</scope>
      <type>war</type>
    </dependency>

    <!-- Servlet API is provided by the container -->
    <dependency>
      <groupId>jakarta.servlet</groupId>
      <artifactId>jakarta.servlet-api</artifactId>
      <version>${servlet-api-version}</version>
      <scope>provided</scope>
    </dependency>

    <!-- Logging -->
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
      <version>${slf4j-version}</version>
    </dependency>
  </dependencies>

  <build>
    <finalName>war-plugin</finalName>

    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>copy</id>
            <phase>test-compile</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>io.hawt</groupId>
                  <artifactId>hawtio-war-minimal</artifactId>
                  <version>${project.version}</version>
                  <type>war</type>
                  <outputDirectory>${project.build.directory}/deploy</outputDirectory>
                  <destFileName>hawtio.war</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.eclipse.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <configuration>
          <deployMode>EMBED</deployMode>
          <scan>10</scan>
          <webApp>
            <contextPath>/</contextPath>
          </webApp>
          <contextHandlers>
            <contextHandler implementation="org.eclipse.jetty.maven.plugin.MavenWebAppContext">
              <war>${project.build.directory}/deploy/hawtio.war</war>
              <contextPath>/hawtio</contextPath>
            </contextHandler>
          </contextHandlers>
          <modules>
            <module>jmx</module>
          </modules>
          <systemProperties>
            <hawtio.authenticationEnabled>false</hawtio.authenticationEnabled>
          </systemProperties>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
