description = "Umbrella : Web"

dependencies{
    implementation(project(":core"))
}

tasks.processResources {
    System.out.println("Copying from dist…")
    from("../frontend/dist") {
        into("web")
    }
    duplicatesStrategy = DuplicatesStrategy.EXCLUDE
}

fun download(url : String, destination : String){
    var destFile = projectDir.toPath().resolve(destination).toFile();
    destFile.parentFile.mkdirs()
    if (!destFile.exists()) {
        System.out.println("Downloading "+url)
        ant.invokeMethod("get", mapOf("src" to url, "dest" to destFile))
    }
}

tasks.register("downloadLib"){
    download("https://bossanova.uk/jspreadsheet/v5/jspreadsheet.js", "src/main/resources/web/js/jspreadsheet-ce.js")
}

tasks.named("compileJava") {
    dependsOn("downloadLib")
}
