<?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>

  <artifactId>{{artifactId}}</artifactId>
  <groupId>{{groupId}}</groupId>
  <version>{{version}}</version>

  <name>{{artifactId}}</name>

  <properties>
    <!-- Startup class -->
    <application.class>{{package}}.App{{#if kotlin}}Kt{{/if}}</application.class>

    <jooby.version>{{joobyVersion}}</jooby.version>

    {{#if kotlin}}
    <kotlin.version>{{kotlinVersion}}</kotlin.version>
    <kotlin.compiler.incremental>true</kotlin.compiler.incremental>
    {{/if}}
    <maven.compiler.source>1.8</maven.compiler.source>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.parameters>true</maven.compiler.parameters>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
  {{#each dependencies}}
    <dependency>
      <groupId>{{groupId}}</groupId>
      <artifactId>{{artifactId}}</artifactId>
    </dependency>

  {{/each}}
    <!-- Tests -->
  {{#each testDependencies}}
    <dependency>
      <groupId>{{groupId}}</groupId>
      <artifactId>{{artifactId}}</artifactId>
      <scope>test</scope>
    </dependency>

  {{/each}}
  </dependencies>

  <build>
  {{#if kotlin}}
     <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
     <testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
  {{/if}}
    <plugins>
    {{#if kotlin}}
      <plugin>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-maven-plugin</artifactId>
        <version>${kotlin.version}</version>
        <configuration>
          <args>
            <arg>-java-parameters</arg>
          </args>
          <jvmTarget>${maven.compiler.target}</jvmTarget>
        </configuration>
        <executions>
        {{#if kapt}}
          <execution>
            <id>kapt</id>
            <goals>
              <goal>kapt</goal>
            </goals>
            <configuration>
              <sourceDirs>
                <sourceDir>src/main/kotlin</sourceDir>
              </sourceDirs>
              <annotationProcessorPaths>
                <annotationProcessorPath>
                  <groupId>io.jooby</groupId>
                  <artifactId>jooby-apt</artifactId>
                  <version>${jooby.version}</version>
                </annotationProcessorPath>
              </annotationProcessorPaths>
            </configuration>
          </execution>
        {{/if}}
          <execution>
            <id>compile</id>
            <goals>
              <goal>compile</goal>
            </goals>
          </execution>
          <execution>
            <id>test-compile</id>
            <goals>
              <goal>test-compile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    {{else}}
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>{{mavenCompilerPluginVersion}}</version>
      {{#if apt}}
        <configuration>
          <annotationProcessorPaths>
            <path>
              <groupId>io.jooby</groupId>
              <artifactId>jooby-apt</artifactId>
              <version>${jooby.version}</version>
            </path>
          </annotationProcessorPaths>
        </configuration>
      {{/if}}
      </plugin>
    {{/if}}
      <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>{{mavenSurefirePluginVersion}}</version>
      </plugin>
      <!-- jooby:run -->
      <plugin>
        <groupId>io.jooby</groupId>
        <artifactId>jooby-maven-plugin</artifactId>
        <version>${jooby.version}</version>
        {{#if openapi}}
        <executions>
          <execution>
            <goals>
              <goal>openapi</goal>
            </goals>
            <configuration>
            </configuration>
          </execution>
        </executions>
        {{/if}}
      </plugin>
      {{#if stork}}
      <plugin>
        <groupId>com.fizzed</groupId>
        <artifactId>stork-maven-plugin</artifactId>
        <version>{{storkMavenPluginVersion}}</version>
        <executions>
          <execution>
            <id>stork-launcher</id>
            <goals>
              <goal>launcher</goal>
            </goals>
            <configuration>
              <inputFiles>${project.basedir}${file.separator}src${file.separator}etc</inputFiles>
            </configuration>
          </execution>
          <execution>
            <id>stork-assembly</id>
            <goals>
              <goal>assembly</goal>
            </goals>
            <configuration>
              <finalName>${project.artifactId}-${project.version}-stork</finalName>
            </configuration>
          </execution>
        </executions>
      </plugin>
      {{else}}
      <!-- Build uber jar -->
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <version>{{mavenShadePluginVersion}}</version>
        <executions>
          <execution>
            <id>uber-jar</id>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>false</createDependencyReducedPom>
              <transformers>
                <transformer
                    implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
                <transformer
                    implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                  <mainClass>${application.class}</mainClass>
                </transformer>
              </transformers>
            </configuration>
          </execution>
        </executions>
      </plugin>
      {{/if}}
    </plugins>
  </build>

  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>io.jooby</groupId>
        <artifactId>jooby-bom</artifactId>
        <version>${jooby.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
</project>
