<?xml version="1.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>

  <artifactId>basex-api</artifactId>

  <parent>
    <groupId>org.basex</groupId>
    <artifactId>basex-parent</artifactId>
    <version>13.0-SNAPSHOT</version>
    <relativePath>..</relativePath>
  </parent>

  <properties>
    <jettyVersion>12.1.14</jettyVersion>
  </properties>

  <name>BaseX API</name>

  <dependencies>
    <dependency>
      <groupId>org.basex</groupId>
      <artifactId>basex</artifactId>
      <version>${project.version}</version>
    </dependency>
    <dependency>
      <groupId>net.xqj</groupId>
      <artifactId>basex-xqj</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty</groupId>
      <artifactId>jetty-server</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.ee10</groupId>
      <artifactId>jetty-ee10-servlet</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.ee10</groupId>
      <artifactId>jetty-ee10-servlets</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.ee10</groupId>
      <artifactId>jetty-ee10-webapp</artifactId>
    </dependency>
    <dependency>
      <groupId>jakarta.websocket</groupId>
      <artifactId>jakarta.websocket-api</artifactId>
    </dependency>
    <dependency>
      <groupId>jakarta.websocket</groupId>
      <artifactId>jakarta.websocket-client-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.ee10.websocket</groupId>
      <artifactId>jetty-ee10-websocket-jakarta-server</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.compression</groupId>
      <artifactId>jetty-compression-server</artifactId>
    </dependency>
    <dependency>
      <groupId>org.eclipse.jetty.compression</groupId>
      <artifactId>jetty-compression-gzip</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-simple</artifactId>
    </dependency>
    <dependency>
      <groupId>org.junit.jupiter</groupId>
      <artifactId>junit-jupiter</artifactId>
    </dependency>
    <!-- web applications: build order for the bundling executions below -->
    <dependency>
      <groupId>org.basex.modules</groupId>
      <artifactId>modules-chat</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.basex.modules</groupId>
      <artifactId>modules-dba</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
    <dependency>
      <groupId>org.basex.modules</groupId>
      <artifactId>modules-webdav</artifactId>
      <version>${project.version}</version>
      <scope>test</scope>
    </dependency>
  </dependencies>

  <build>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-jar-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-source-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-deploy-plugin</artifactId>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <configuration>
          <includeScope>compile</includeScope>
          <excludeArtifactIds>xstream</excludeArtifactIds>
        </configuration>
        <executions>
          <!-- web applications as archives (ZIP distribution) -->
          <execution>
            <id>web-archives</id>
            <phase>package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <outputDirectory>${project.build.directory}/webapp</outputDirectory>
              <artifactItems>
                <artifactItem>
                  <groupId>org.basex.modules</groupId>
                  <artifactId>modules-chat</artifactId>
                  <destFileName>chat.zip</destFileName>
                </artifactItem>
                <artifactItem>
                  <groupId>org.basex.modules</groupId>
                  <artifactId>modules-dba</artifactId>
                  <destFileName>dba.zip</destFileName>
                </artifactItem>
                <artifactItem>
                  <groupId>org.basex.modules</groupId>
                  <artifactId>modules-webdav</artifactId>
                  <destFileName>webdav.zip</destFileName>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <!-- web applications as directories (WAR file) -->
          <execution>
            <id>web-directories</id>
            <phase>package</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <excludes>META-INF/**</excludes>
              <artifactItems>
                <artifactItem>
                  <groupId>org.basex.modules</groupId>
                  <artifactId>modules-chat</artifactId>
                  <outputDirectory>${project.build.directory}/webapps/chat</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>org.basex.modules</groupId>
                  <artifactId>modules-dba</artifactId>
                  <outputDirectory>${project.build.directory}/webapps/dba</outputDirectory>
                </artifactItem>
                <artifactItem>
                  <groupId>org.basex.modules</groupId>
                  <artifactId>modules-webdav</artifactId>
                  <outputDirectory>${project.build.directory}/webapps/webdav</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <configuration>
          <webResources>
            <resource>
              <directory>${project.build.directory}/webapps</directory>
            </resource>
          </webResources>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.eclipse.jetty.ee10</groupId>
        <artifactId>jetty-ee10-maven-plugin</artifactId>
        <version>${jettyVersion}</version>
        <configuration>
          <stopKey>keyToStopJetty</stopKey>
          <stopPort>8081</stopPort>
          <supportedPackagings>
            <supportedPackaging>jar</supportedPackaging>
          </supportedPackagings>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>
