buildscript {
    repositories {
        jcenter()
        maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
    }
    dependencies {
        classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.3'
    }
}

apply plugin: 'java'
apply plugin: 'robovm'

sourceSets.main.java.srcDirs = ["src/"]

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

ext {
    roboVMVersion = "2.3.2"
}

launchIPhoneSimulator.dependsOn build
launchIPadSimulator.dependsOn build
launchIOSDevice.dependsOn build
createIPA.dependsOn build

dependencies {
    implementation project(':vtm')
    implementation project(':vtm-gdx')
    implementation project(':vtm-jts')
    implementation project(':vtm-ios')
    implementation project(':vtm-themes')
    implementation "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
    implementation "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
    implementation "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
    implementation "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
    implementation "org.slf4j:slf4j-simple:$slf4jVersion"
}

task copyVtmResources(type: Copy) {
    from("../vtm/resources")
    into("${buildDir}")
}

task copyVtmThemesResources(type: Copy) {
    from("../vtm-themes/resources")
    into("${buildDir}")
}

task copyVtmPlaygroundResources(type: Copy) {
    from("../vtm-playground/resources")
    into("${buildDir}/assets/")
}

task copyIosNatives(type: Copy) {
    from("../vtm-ios/natives")
    into("${buildDir}/natives/")
}

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn copyVtmResources
}

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn copyVtmThemesResources
}

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn copyVtmPlaygroundResources
}

tasks.withType(JavaCompile) {
    compileTask -> compileTask.dependsOn copyIosNatives
}