buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
    }
}

apply plugin: 'java-library'
apply plugin: 'maven'
apply plugin: 'gwt-base'

sourceSets {
    main.java.srcDirs = ['src', 'src/org/oscim/gdx/emu']
}

dependencies {
    api project(':vtm-gdx')
    api "com.badlogicgames.gdx:gdx:$gdxVersion:sources"
    api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion"
    api "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"
}

// explicit dependencies for org.gradle.configureondemand=true
evaluationDependsOn(':vtm')
evaluationDependsOn(':vtm-themes')
evaluationDependsOn(':vtm-gdx')
evaluationDependsOn(':vtm-extras')

gwt {
    gwtVersion = project.ext.gwtVersion
    modules 'org.oscim.gdx.VtmWeb'

    superDev {
        noPrecompile = true
    }
    compiler {
        enableClosureCompiler = false // activates -XenableClosureCompiler
        disableClassMetadata = true // activates -XdisableClassMetadata
        disableCastChecking = true // activates -XdisableCastChecking
    }

    src += files(sourceSets.main.java.srcDirs)
    src += files(project(':vtm').sourceSets.main.allJava.srcDirs)
    src += files(project(':vtm-themes').sourceSets.main.allJava.srcDirs)
    src += files(project(':vtm-themes').sourceSets.main.resources.srcDirs)
    src += files(project(':vtm-gdx').sourceSets.main.allJava.srcDirs)
}

// Run jetty with draft compiled war
//task jettyDraftWar(type: JettyRunWar) {
//  dependsOn draftWar
//  dependsOn.remove('war')
//  webApp=draftWar.archivePath
//}

//task copyThemeAssets(type: Copy) {
//    from "$rootDir/vtm-themes/resources/assets"
//    into "assets"
//    include '**/*'
//}

//task copyVtmAssets(type: Copy) {
//    from "$rootDir/vtm/resources/assets"
//    into "assets"
//    include '**/*'
//}

//tasks.withType(JavaCompile) { compileTask ->
//  compileTask.dependsOn copyThemeAssets
//  compileTask.dependsOn copyVtmAssets
//}

javadoc {
    options.addStringOption("sourcepath", "")
}

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