apply plugin: "java"
//apply plugin: 'org.akhikhl.gretty'

gwt {
    gwtVersion='2.8.0' // Should match the gwt version used for building the gwt backend
    maxHeapSize="2G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY
    minHeapSize="1G"

    src = files(file("src/")) // Needs to be in front of "modules" below.
    modules 'io.anuke.mindustry.GdxDefinition'
    devModules 'io.anuke.mindustry.GdxDefinitionSuperdev'
    project.webAppDirName = 'webapp'

    compiler {
        strict = true
        disableCastChecking = true
    }
}

task dist(dependsOn: [clean, compileGwt]) {
    doLast {
        file("build/dist").mkdirs()
        copy {
            from "build/gwt/out"
            into "build/dist"
        }
        copy {
            from "webapp"
            into "build/dist"
            }
        copy {
            from "war"
            into "build/dist"
        }
    }
}

task distZip(type: Zip, dependsOn: dist){
	from "build/dist"
    archiveName appName + "-html5.zip"
    destinationDir(file("build/dist-zipped"))
}

draftWar {
   from "war"
}

task addSource{
	doLast{
		sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs)
	}
}

tasks.compileGwt.dependsOn(addSource)
tasks.draftCompileGwt.dependsOn(addSource)

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