apply plugin: "java-library"

dependencies {
    api "com.badlogicgames.gdx:gdx:$gdxVersion"
    api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
    api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
    api "com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion"
    api 'com.google.code.gson:gson:2.8.5'
}

task generateVersionInfoClass {
    doFirst {
        def outputDir = file("$buildDir/../generated/com/agateau/pixelwheels")

        Properties versionProps = new Properties()
        versionProps.load(new FileInputStream(file('../version.properties')))

        if (!outputDir.exists()) {
            outputDir.mkdirs()
        }

        def version = versionProps["VERSION"]
        def src = "// Generated file, do not edit!\n" \
            + "package com.agateau.pixelwheels;\n" \
            + "public class VersionInfo {\n" \
            + "    public static final String VERSION = \"$version\";\n" \
            + "}\n"
        new File(outputDir, "VersionInfo.java").write(src)
    }
}

java {
    sourceCompatibility = JavaVersion.VERSION_1_8
}
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

compileJava.dependsOn(generateVersionInfoClass)
sourceSets.main.java.srcDirs = [ "src/", "generated/" ]
