plugins {
    id 'java'
    id 'application'
}

group = '{{{groupId}}}'
version = '{{{artifactVersion}}}'

{{#appDescription}}
description = """{{.}}"""
{{/appDescription}}


sourceCompatibility = 11
targetCompatibility = 11

tasks.withType(JavaCompile) {
    options.encoding = 'UTF-8'
}

ext {
    helidonVersion = '{{{helidonVersion}}}'
    mainClass='io.helidon.microprofile.cdi.Main'
}

test {
    useJUnitPlatform()
}

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    // import Helidon BOM
    implementation enforcedPlatform("io.helidon:helidon-dependencies:${project.helidonVersion}")
    implementation 'io.helidon.microprofile.bundles:helidon-microprofile-core'
    implementation 'io.helidon.microprofile.cdi:helidon-microprofile-cdi'
    implementation '{{rootJavaEEPackage}}.enterprise:{{rootJavaEEPackage}}.enterprise.cdi-api'
    implementation '{{rootJavaEEPackage}}.ws.rs:{{rootJavaEEPackage}}.ws.rs-api'
{{#jackson}}
    implementation 'org.glassfish.jersey.media:jersey-media-json-jackson'
{{/jackson}}
{{#jsonb}}
    implementation 'org.glassfish.jersey.media:jersey-media-json-binding'
    implementation '{{rootJavaEEPackage}}.json.bind:{{rootJavaEEPackage}}.json.bind-api'
{{/jsonb}}
    testImplementation 'junit:junit'
    testImplementation 'io.helidon.microprofile.tests:helidon-microprofile-tests-junit5'
}

// define a custom task to copy all dependencies in the runtime classpath
// into build/libs/libs
// uses built-in Copy
task copyLibs(type: Copy) {
    from configurations.runtimeClasspath
    into 'build/libs/libs'
}

// add it as a dependency of built-in task 'assemble'
copyLibs.dependsOn jar
assemble.dependsOn copyLibs

// default jar configuration
// set the main classpath
// add each jar under build/libs/libs into the classpath
jar {
    archiveFileName = "${project.name}.jar"
    manifest {
        attributes ('Main-Class': "${project.mainClass}",
                'Class-Path': configurations.runtimeClasspath.files.collect { "libs/$it.name" }.join(' ')
        )
    }
}

application {
mainClass = "${project.mainClass}"
}
