buildscript {
  ext {
    joobyVersion = System.getProperty("joobyVersion")
  }
}

plugins {
  id "application"
{{#if openapi}}
  id "io.jooby.openAPI" version "${joobyVersion}"
{{/if}}
  id "io.jooby.run" version "${joobyVersion}"
  id "io.spring.dependency-management" version "1.1.0"
  id "com.google.osdetector" version "1.7.3"
  id "com.gradleup.shadow" version "8.3.7"
}

group "{{groupId}}"
version "{{version}}"
mainClassName = "{{package}}.App"
sourceCompatibility = 21

repositories {
  mavenLocal()
  mavenCentral()
}

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

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

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

test {
  useJUnitPlatform()
}

/** Java debug information: */
tasks.withType(JavaCompile) {
  options.compilerArgs += [
    '-parameters',
{{#if apt}}
    '-Ajooby.incremental=true',
    '-Ajooby.debug=false'
{{/if}}
  ]
  options.debug = true
}

shadowJar {
  mergeServiceFiles()
}

joobyRun {
  mainClass = mainClassName
  restartExtensions = ["conf", "properties", "class"]
  compileExtensions = ["java"]
  port = 8080
}
{{#openapi}}
joobyRun.dependsOn openAPI

jar.dependsOn openAPI
{{/openapi}}
