apply plugin: 'kotlin-platform-js'

sourceSets {
	main.resources.srcDirs = [ '../common/src/main/resources', '../common/src/generated/resources' ]
}

dependencies {
	implement project(":korge-tic-tac-toe:common")

	compile "com.soywiz:korge-js:$korVersion"
	compile "com.soywiz:korge-ext-swf-js:$korVersion"
	compile "com.soywiz:korau-mp3-js:$korVersion"
	testCompile "com.soywiz:korge-tests-js:$korVersion"
}

compileKotlin2Js {
	kotlinOptions.outputFile = "${projectDir}/web/output.js"
	kotlinOptions.sourceMap = false
}


clean {
	delete new File("${projectDir}/web")
}

compileKotlin2Js.doLast {
	configurations.compile.each { File file ->
		copy {
			includeEmptyDirs = false

			from zipTree(file.absolutePath)
			into "${projectDir}/web"
			include { fileTreeElement ->
				def path = fileTreeElement.path
				(path.endsWith(".js") || path.endsWith(".js.map")) && (path.startsWith("META-INF/resources/") || !path.startsWith("META-INF/"))
			}
		}
	}

	copy {
		from sourceSets.main.resources.srcDirs
		into "${projectDir}/web"
	}
}

jar.enabled = false
