buildscript {
  ext {
    {{#if kotlin}}kotlinVersion = "{{kotlinVersion}}"{{/if}}
    joobyVersion = "{{joobyVersion}}"
  }
}

plugins {
  id "application"
{{#if kotlin}}
  id "org.jetbrains.kotlin.jvm" version "{{kotlinVersion}}"
{{/if}}
{{#if kapt}}
  id "org.jetbrains.kotlin.kapt" version "{{kotlinVersion}}"
{{/if}}
{{#if openapi}}
  id "io.jooby.openAPI" version "${joobyVersion}"
{{/if}}
  id "io.jooby.run" version "${joobyVersion}"
  id "io.spring.dependency-management" version "1.0.9.RELEASE"
  id "com.google.osdetector" version "1.6.2"
  id "com.github.johnrengelman.shadow" version "5.2.0"
}

group "{{groupId}}"
version "{{version}}"
mainClassName = "{{package}}.App{{#if kotlin}}Kt{{/if}}"
sourceCompatibility = 1.8

repositories {
  mavenLocal()
  mavenCentral()
  jcenter()
}

dependencyManagement {
  imports {
    mavenBom "io.jooby:jooby-bom:$joobyVersion"
  }
}

dependencies {
{{#if kapt}}
  kapt "io.jooby:jooby-apt"
{{else if apt}}
  annotationProcessor "io.jooby:jooby-apt"
{{/if}}
{{#each dependencies}}
  implementation "{{this}}"
{{/each}}

{{#each testDependencies}}
  testImplementation "{{this}}"
{{/each}}
}

test {
  useJUnitPlatform()
}

{{#if kotlin}}
/** Kotlin debug information: */
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
  kotlinOptions.javaParameters = true
}
{{else}}
/** Java debug information: */
tasks.withType(JavaCompile) {
  options.compilerArgs << '-parameters'
  options.debug = true
}
{{/if}}

shadowJar {
  mergeServiceFiles()
}

{{#openapi}}
joobyRun.dependsOn openAPI

jar.dependsOn openAPI
{{/openapi}}
