apply plugin: 'java'
apply plugin: 'maven'

dependencies {
    compile project(':vtm-gdx')
    file('natives').eachDir() { dir ->
        compile files(dir.path)
    }
    compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
    compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
    compile 'com.kitfox.svg:svg-salamander:1.0'
}

sourceSets {
    main {
        java.srcDirs = ['src']
    }
}

file('natives').eachDir() { dir ->
    task("nativesJar-${dir.name}", type: Jar) {
        classifier = "natives-${dir.name}"
        from(dir.path)
    }

    artifacts {
        archives tasks["nativesJar-${dir.name}"]
    }
}

task fatJar(type: Jar, dependsOn: classes) {
    classifier = 'jar-with-dependencies'
    from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
    // Natives come from compile configuration
    /*file('natives').eachDir() { dir ->
        fatJar.from(dir.path)
    }*/
    exclude 'META-INF/*.DSA', 'META-INF/*.RSA', 'META-INF/*.SF'
    with jar
}

artifacts {
    archives fatJar
}

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