plugins {
    id 'java'
}

group 'games.rednblack'
version '0.1.4'

ext {
    pack = ["assets/textures", "assets/pack/", "tiled"]
}

repositories {
    mavenCentral()
    maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
}

dependencies {
    implementation "com.badlogicgames.gdx:gdx:$gdxVersion"
    implementation "com.kotcrab.vis:vis-ui:$visuiVersion"
    implementation "net.onedaybeard.artemis:artemis-odb:$artemisVersion"

    implementation "com.esotericsoftware.spine:spine-libgdx:$spineVersion"

    implementation "games.rednblack.puremvc:core:$pureMvcVersion"

    implementation 'net.mountainblade:modular:1.0'

    implementation project(":hyperlap2d-common-api")
    implementation project(":hyperlap2d-runtime-libgdx")
    implementation project(":h2d-libgdx-spine-extension")

    testImplementation group: 'junit', name: 'junit', version: '4.12'
}

import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.tools.texturepacker.TexturePacker

task packTextures {
    TexturePacker.Settings settings = new TexturePacker.Settings()
    settings.legacyOutput = false
    settings.filterMin = Texture.TextureFilter.Linear
    settings.filterMag = Texture.TextureFilter.Linear
    settings.duplicatePadding = true
    if (project.ext.has('pack')) {
        logger.info "Calling TexturePacker: " + pack
        TexturePacker.processIfModified(settings, file(pack[0]).absolutePath, file(pack[1]).absolutePath, pack[2] as String)
    }
}

project.ext.assetsDir = new File("assets/pack");

task dist(type: Jar) {
    from files(sourceSets.main.output.classesDirs)
    from files(sourceSets.main.output.resourcesDir)
    from files(project.assetsDir)

    destinationDirectory = file("../build/lib/plugins")

    doLast {
        def jarToCopy = archiveFileName.get()
        copy {
            from "../build/lib/plugins/$jarToCopy"
            into "../assets/plugins"
        }
    }
}