<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.jeudego.pairgoth</groupId>
    <artifactId>engine-parent</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>
  <artifactId>application</artifactId>
  <packaging>pom</packaging>
  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <serverManifestDirectory>${project.build.directory}/servermanifest</serverManifestDirectory>
  </properties>
  <dependencies>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>api-webapp</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>view-webapp</artifactId>
      <version>${project.version}</version>
      <type>war</type>
    </dependency>
    <dependency>
      <groupId>${project.groupId}</groupId>
      <artifactId>webserver</artifactId>
      <version>${project.version}</version>
    </dependency>
  </dependencies>
  <build>
    <finalName>pairgoth-engine</finalName>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
          <!--
            <configuration>
                <archive>
                    <manifest>
                        <mainClass>
                            org.jeudego.pairgoth.application.PairgothKt
                        </mainClass>
                    </manifest>
                </archive>
            </configuration>
            -->
        </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-dependency-plugin</artifactId>
        <executions>
          <execution>
            <id>use-server-manifest</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>unpack</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>webserver</artifactId>
                  <version>${project.version}</version>
                  <outputDirectory>${serverManifestDirectory}</outputDirectory>
                  <includes>META-INF/MANIFEST.MF</includes>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <!--
          <execution>
            <id>copy-api-war</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>api-webapp</artifactId>
                  <version>${project.version}</version>
                  <outputDirectory>webapps</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          <execution>
            <id>copy-view-war</id>
            <phase>prepare-package</phase>
            <goals>
              <goal>copy</goal>
            </goals>
            <configuration>
              <artifactItems>
                <artifactItem>
                  <groupId>${project.groupId}</groupId>
                  <artifactId>view-webapp</artifactId>
                  <version>${project.version}</version>
                  <outputDirectory>webapps</outputDirectory>
                </artifactItem>
              </artifactItems>
            </configuration>
          </execution>
          -->
        </executions>
      </plugin>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-assembly-plugin</artifactId>
        <executions>
          <execution>
            <id>build-livewar</id>
            <phase>package</phase>
            <goals>
              <goal>single</goal>
            </goals>
            <configuration>
              <appendAssemblyId>false</appendAssemblyId>
              <descriptors>
                <descriptor>src/assembly/livewar.xml</descriptor>
              </descriptors>
              <archive>
                <manifestFile>${serverManifestDirectory}/META-INF/MANIFEST.MF</manifestFile>
              </archive>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>
