<?xml version="1.0" encoding="UTF-8"?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<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.apache.any23</groupId>
    <artifactId>apache-any23</artifactId>
    <version>0.7.0-incubating</version>
    <relativePath>../pom.xml</relativePath>
  </parent>

  <artifactId>apache-any23-service</artifactId>
  <packaging>war</packaging>

  <name>Apache Any23 :: Service</name>

  <properties>
    <!-- the following property is used in the bash script as well, don't remove it! -->
    <jetty.runner.version>8.1.4.v20120524</jetty.runner.version>
  </properties>

  <dependencies>
    <!-- Core Module -->
    <dependency>
      <groupId>org.apache.any23</groupId>
      <artifactId>apache-any23-core</artifactId>
      <version>${project.version}</version>
    </dependency>

    <!-- BEGIN: Servlet Deps. -->
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>servlet-api-3.0</artifactId>
      <scope>provided</scope>
    </dependency>
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-servlet-tester</artifactId>
      <scope>test</scope>
    </dependency>
    <!-- END:   Servlet Deps. -->

    <!-- BEGIN: Jetty Deps. -->
    <dependency>
      <groupId>org.mortbay.jetty</groupId>
      <artifactId>jetty-runner</artifactId>
      <version>${jetty.runner.version}</version>
      <scope>provided</scope>
      <optional>true</optional>
    </dependency>
    <!-- END:   Jetty Deps. -->
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.mortbay.jetty</groupId>
        <artifactId>jetty-maven-plugin</artifactId>
        <version>8.0.0.M2</version>
        <configuration>
          <webAppConfig>
            <contextPath>/${project.artifactId}</contextPath>
          </webAppConfig>
        </configuration>
      </plugin>

      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-war-plugin</artifactId>
        <version>2.2</version>
        <configuration>
          <webResources>
            <resource>
              <directory>${basedir}/src/main/resources/</directory>
              <targetPath>/resources</targetPath>
              <filtering>true</filtering>
            </resource>
            <resource>
              <directory>${basedir}/../</directory>
              <targetPath>/META-INF</targetPath>
              <includes>
                <include>DISCLAIMER.txt</include>
              </includes>
            </resource>
          </webResources>
        </configuration>
        <executions>
          <execution>
            <id>self-contained-war</id>
            <phase>package</phase>
            <goals>
              <goal>war</goal>
            </goals>
            <configuration>
              <webResources>
                <resource>
                  <directory>${project.build.directory}/war-legals/with-deps/</directory>
                  <targetPath>/META-INF</targetPath>
                </resource>
              </webResources>
            </configuration>
          </execution>
          <execution>
            <id>war-without-deps</id>
            <phase>package</phase>
            <goals>
              <goal>war</goal>
            </goals>
            <configuration>
              <classifier>without-deps</classifier>
              <packagingExcludes>WEB-INF/lib/*.jar</packagingExcludes>
              <archive>
                <manifest>
                  <addClasspath>true</addClasspath>
                  <classpathPrefix>lib/</classpathPrefix>
                </manifest>
              </archive>
              <webResources>
                <resource>
                  <directory>${project.build.directory}/war-legals/without-deps/</directory>
                  <targetPath>/META-INF</targetPath>
                </resource>
              </webResources>
            </configuration>
          </execution>
        </executions>
      </plugin>

      <!-- Generates the distribution package -->
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>prepare-package</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <attach>false</attach>
              <finalName>war-legals</finalName>
              <appendAssemblyId>false</appendAssemblyId>
              <descriptors>
                <descriptor>${basedir}/src/main/assembly/prepare-war-legals.xml</descriptor>
              </descriptors>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <descriptors>
            <descriptor>${basedir}/src/main/assembly/with-deps.xml</descriptor>
            <descriptor>${basedir}/src/main/assembly/without-deps.xml</descriptor>
            <descriptor>${basedir}/src/main/assembly/server-embedded.xml</descriptor>
          </descriptors>
        </configuration>
      </plugin>
    </plugins>
  </build>

  <profiles>
    <profile>
      <id>release</id>
      <build>
        <resources>
          <resource>
            <directory>${basedir}/../</directory>
            <targetPath>${project.build.directory}/apidocs/META-INF</targetPath>
            <includes>
              <include>DISCLAIMER.txt</include>
              <include>LICENSE.txt</include>
              <include>NOTICE.txt</include>
            </includes>
          </resource>
        </resources>
      </build>
    </profile>
  </profiles>

</project>
