plugins {
    id 'com.android.application'
}

def duskRepoDir = rootProject.projectDir.parentFile.parentFile
def duskGeneratedAssetsDir = layout.buildDirectory.dir('generated/assets/dusklight').get().asFile
def syncDuskAssets = tasks.register('syncDuskAssets', Sync) {
    from(new File(duskRepoDir, 'res')) {
        into 'res'
        exclude '**/.DS_Store'
    }
    into duskGeneratedAssetsDir
}

android {
    namespace 'dev.twilitrealm.dusk'
    compileSdk 36

    defaultConfig {
        applicationId 'dev.twilitrealm.dusk'
        minSdk 26
        targetSdk 36
        versionCode 1
        versionName '0.1.0'
    }

    buildTypes {
        debug {
            minifyEnabled false
        }
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

    sourceSets {
        main {
            jniLibs.srcDirs = ['src/main/jniLibs']
            assets.srcDirs = [duskGeneratedAssetsDir]
        }
    }

    splits {
        abi {
            enable true
            reset()
            include 'arm64-v8a', 'x86_64'
            universalApk false
        }
    }

    lint {
        abortOnError false
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
}

tasks.configureEach { task ->
    if ((task.name.startsWith('merge') && task.name.endsWith('Assets')) ||
        task.name.toLowerCase().contains('lint')) {
        task.dependsOn(syncDuskAssets)
    }
}
