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-library'
apply plugin: 'maven'
apply plugin: 'robovm'

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

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

ext {
    roboVMVersion = "2.3.3"
}

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

dependencies {
    api project(':vtm-gdx')
    api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"
    api "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion"
    api "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion"
    api "com.mobidevelop.robovm:robovm-rt:$roboVMVersion"
}

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

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


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

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

task nativesJar(type: Jar) {
    classifier = 'natives'
    from('natives')
}

artifacts {
    archives nativesJar
}

if (project.hasProperty("SONATYPE_USERNAME")) {
    afterEvaluate {
        project.apply from: "${rootProject.projectDir}/deploy.gradle"
    }
}
